nginx配置
http://www.cnblogs.com/knowledgesea/p/5175711.html
注意,修改了配置文件后最好先检查一下修改过的配置文件是否正 确,以免重启后Nginx出现错误影响服务器稳定运行。判断Nginx配置是否正确命令如下:
nginx -t -c /usr/local/nginx/conf/nginx.conf
或者
/usr/local/nginx/sbin/nginx -t
平滑重启
/usr/local/nginx/sbin/nginx -s reload
或者
$ nginx -s reload
nginx 配置文件
1、打开配置文件
$ cd /usr/local/nginx/conf/
$ ls
$ vim nginx.conf
server
{
listen 80 default_server;
index index.html index.htm index.php;
root /home/wwwroot/laravel54/public/;
include enable-php.conf;#移动到这里
#添加的内容
location / {
try_files $uri $uri/ /index.php?$query_string;
}
#添加的内容
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
:wq保存退出
2、修改配置enable-php.conf
$ vim enable-php.conf
location ~ [^/]\.php(/|$) {
try_files $uri = 404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
3、重启nginx
$ nginx -s reload