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

Nginx部署ThinkPHP3.x心得

2015-12-23 00:00 766 查看
使用LNMP一键安装之后,由于Nginx不支持pathinfo,所以对nginx和php做了修改

修改/usr/local/nginx/conf/nginx.conf

server
{
listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
server_name www.lnmp.org;
index index.html index.htm index.php;
root  /home/wwwroot/default;

#error_page   404   /404.html;
#        include enable-php.conf;

location /nginx_status
{
stub_status on;
access_log   off;
}

location / {
try_files $uri @rewrite;
}
location @rewrite {
set $static 0;
if  ($uri ~ \.(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css\.map|min\.map)$) {
set $static 1;
}
if ($static = 0) {
rewrite ^/(.*)$ /index.php?s=/$1;
}
}
location ~ /Uploads/.*\.php$ {
deny all;
}
location ~ \.php/ {
if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { }
fastcgi_pass unix:/tmp/php-cgi.sock;
include fastcgi_params;
fastcgi_param SCRIPT_NAME     $1;
fastcgi_param PATH_INFO       $2;
fastcgi_param SCRIPT_FILENAME $document_root$1;
}
location ~ \.php$ {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.
{
deny all;
}

access_log  /home/wwwlogs/access.log  access;
}

修改 /usr/local/php/etc/php.ini

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