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; //80端口 server_name linux.com; //项目网址 #直接输入域名进入的目录和默认解析的文件 location / { index index.php; root /usr/htdocs/linux; //项目入口文件所在的绝对路径 } #解析.php的文件 location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/htdocs/linux/$fastcgi_script_name; //前面半截跟上面的绝对路劲保持一致 include fastcgi_params; } }