nginx 绑定域名方法很简单,只要在 nginx 中 vhost 中加入 vhost 而后把 server_name 写上你的域名就实现域名绑定了。
一、首先打开nginx域名配置文件存放目录:/usr/local/nginx/conf/vhost ,如要绑定域名 lx.vxiaoxiao.cn 则在此目录建一个文件:lx.vxiaoxiao.cn.conf 而后在此文件中写规则,如:php
server
{
listen 80;
#listen [::]:80;
server_name lx.vxiaoxiao.cn;
index index.html index.php;
root /www/lx.vxiaoxiao.cn;css
include none.conf;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}html
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}nginx
location ~ .*\.(js|css)?$
{
expires 12h;
}服务器
access_log /home/wwwlogs/lx.vxiaoxiao.cn.log access;
}
二、而后重启nginx服务器,域名就绑定成功了,nginx服务器重启命令:/etc/rc.d/rc1.d/nginx restart。unix
从新启动过 cd /usr/local/nginx/sbin ./nginx -s reload