记录Nginx怎么配置TP5.1及所遇问题

广告:宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取~~~

记录Nginx怎么配置TP5.1及所遇问题

下面thinkphp框架教程栏目将给大家介绍关于Nginx怎么配置ThinkPHP5.1以及遇到的问题的解决方法,希望对需要的朋友有所帮助!

1.Nginx用户对项目目录的访问权限
cd /usr/local/nginx/html/setfacl -m u:nginx:rwx -R ../html
登录后复制2.确保访问路径是正确的,最好在本地测过访问URL路径能正确访问到文件

3.nginx支持tp的pathinfo
vi /usr/local/nginx/conf/nginx.conf
登录后复制登录后复制

nginx.conf配置文件找到位置修改内容为

 location ~ \.php$ {            #root           html;            #这段路径指向是必须加的           root       /usr/local/nginx/html/zh/public;           fastcgi_index index.php;           fastcgi_pass   127.0.0.1:9000;           #fastcgi_pass   unix:/usr/local/php/var/run/www.sock;           fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;            fastcgi_split_path_info ^(.+\.php)(.*)$;     #增加这一句            fastcgi_param PATH_INFO $fastcgi_path_info;    #增加这一句           include        fastcgi_params;        }
登录后复制4.nginx rewrite重写规则
vi /usr/local/nginx/conf/nginx.conf
登录后复制登录后复制

nginx.conf配置文件找到位置修改内容为

server {        listen       80;        server_name  www.liuyuanshan.top;        #charset koi8-r;        #access_log  logs/host.access.log  main;        location / {            #root   html;            # 设置www.liuyuanshan.top默认访问路径为/usr/local/nginx/html/zh/public/             root    /usr/local/nginx/html/zh/public/;            index index.php  index.html index.htm;                if (!-e $request_filename) {                        rewrite  ^(.*)$  /index.php?s=/$1  last;                }        }
登录后复制

推荐学习:《最新的10个thinkphp视频教程》

以上就是记录Nginx怎么配置TP5.1及所遇问题的详细内容,更多请关注9543建站博客其它相关文章!

9543建站博客
一个专注于网站开发、微信开发的技术类纯净博客。
作者头像
admin创始人

肥猫,知名SEO博客站长,14年SEO经验。

上一篇:Unix套接字通信技术,Swoole一探究竟
下一篇:yii怎么生成超链接

发表评论

关闭广告
关闭广告