FreeBSD: Nginx Virtual Hosting Configuration
2009-05-13 15:23:38来源:未知 阅读 ()
Q. How do I configure
[url=javascript:;]Nginx[/url]
Web server for
[url=javascript:;]virtual[/url]
hosting (
[url=javascript:;]host[/url]
multiple websites under same IP address - name based virtual hosting)?
A. Nginx allows you to host more than one domain name on the same computer and on the same IP address. There are two basic methods of accomplishing virtual hosting: name-based, and IP address or ip-based. This tutorial covers name-based virtual hosting i.e.
you can hosts multiple websites (host names) for the same webserver IP address.
Nginx name-based virtual hosting configurations
You need to create directory structure as follows to host more than two websites under same IP address:
a] /websites : Host each domain under this directory. You need to create dirs as follows:
/websites/examples.com/http - Html /
[url=javascript:;]php[/url]
/ wordpress / forums files for example.com goes here.
/websites/examples.com/logs - Log files for example.com goes here.
/websites/examples.com/stats - awstats stats files for example.com goes here.
b] /usr/local/etc/nginx/vhosts: Host each domains configuration under this directory.
Your sample setup
IP address: 202.54.1.2
HTTP Port: 80
Domain1 : theos.in hosted at /websites/theos.in/http
Domain2 : cyberciti.biz hosted at /websites/cyberciti.biz/http
Create necessary directories
Type the following commands:
# D=/websites
# NROOT=/usr/local/etc/nginx
# mkdir $D
# mkdir $NROOT/vhosts
# mkdir /var/log/nginx/
# chow
[url=javascript:;]root[/url]
:www /var/log/nginx/
Create / update default cache all ngnix config file
Open /usr/local/etc/nginx/nginx.conf file, enter:
# vi /usr/local/etc/nginx/nginx.conf
Update it as follows:
user www www;
worker_processes 1;
# main server error log
error_log /var/log/nginx/error.log ;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
# main server config
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
#tcp_nopush on;
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:调整服务启动顺序的方法
- freebsd7 RAID0, Geom方式 成功 2009-05-13
- netbsd启动gnome失败! 2009-05-13
- 提示:bad kernel: arp : 内网IP地址 is on em0 but got rep 2009-05-13
- OpenBSD 4.5 2009-05-13
- DragonFly BSD 2.2.1发布 2009-05-13
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash