Nginx隐藏index.php和配置vhost

nginx启动命令

启动:nginx
停止:nginx -s stop
退出:nginx -s quit
重启:nginx -s reopen
重新加载:nginx -s reload
平滑启动:kill -HUP pid(kill -HUP cat /var/run/nginx.pid)

nginx隐藏 index.php,在nginx.conf里添加:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

配置vhost,在nginx.conf的末尾加上:

include vhosts.conf;

然后把网站配置在 vhosts.conf里面,记得不要超出http{}后面那个花括号。模板:

server {
  listen 80;
  server_name lqawechat.cc;
  root /usr/local/nginx/html/qawechat/public;

location / {
    index index.php;
    try_files $uri $uri/ /index.php?$query_string;
  }

location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
}

重启nginx,记得在host里添加该地址

vim /etc/hosts
上一篇:通过实现System.IComparable接口的CompareTo方法对两个类进行比较


下一篇:java Quartz定时器任务与Spring task定时的几种实现,