nginx绑定多域名的方法: 假如要绑定的域名是:it.net.cn 按以下步骤即可搞定: cd /usr/local/nginx/conf mkdir vhost vi it.net.cn.conf #内容如下 server { listen 80; server_name it.net.cn; server_name www.it.net.cn; index index.htm index.html index.php; root /home/wwwroot/itnetcn; } #然后将新网站文件上传到目录/home/wwwroot/itnetcn #然后重启 /root/lnmp restart #最后把域名解析过来,就OK了。 以上配置只能访问到/home/wwwroot/itnetcn目录下的html文件,若想访问php文件,则必须如下配置: server { listen 80; server_name it.net.cn; server_name www.it.net.cn; index index.html index.htm index.php; root /home/wwwroot/itnetcn; location ~ .*\.(php|php5)?$ { fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include /usr/local/nginx/conf/fcgi.conf; } location /status { stub_status on; access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } log_format gevinme_access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for'; access_log /home/wwwlogs/access.log access; } (责任编辑:IT) |