您的位置:首页 > 运维架构 > Nginx

Nginx隐藏index.php和配置vhost

2018-02-20 16:11 417 查看

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

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: