1.编辑nginx配置文件,在http里添加如下行
# vim/usr/local/nginx/conf/nginx.conf
http {
include vhost/*.conf;
}
2.创建存放主机的目录
# mkdir #vim /usr/local/nginx/conf/vhost
3.编辑虚拟主机,名字为osa.conf
# cd /usr/local/nginx/conf/vhost
# vimosa.conf
server
{
listen 90;
server_name www.benet.com;
root /usr/local/nginx/benet;
index index.html index.htm index.php;
location ~ \.php$ {
root /usr/local/nginx/benet; #此处目录是nginx的网站根目录
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
4.编辑虚拟主机,名字为cc.conf
# cd /usr/local/nginx/conf/vhost
# vimosa.conf
server
{
listen 9090;
server_name www.accp.com;
root /usr/local/nginx/accp;
index index.html index.htm index.php;
location ~ \.php$ {
root /usr/local/nginx/accp;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
5.验证nginx是否有错误
# /usr/local/nginx/sbin/nginx -t
# /usr/local/nginx/sbin/nginx -s reload 重启nginx
原文:http://lxw66.blog.51cto.com/5547576/1361861