当前位置:Gxlcms > PHP教程 > 在lnmp环境下thinkphp5的一些必要配置

在lnmp环境下thinkphp5的一些必要配置

时间:2021-07-01 10:21:17 帮助过:18人阅读

我们都知道的,tp5 默认在 nginx 服务器 是不能正常工作的,需要我们手动配置 nginx 服务器 以便对 tp 5 的支持!这篇文章主要介绍了在lnmp环境下thinkphp5的一些必要配置,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

打开 Nginx 站点配置文件

  1. $ sudo vi /etc/nginx/vhost/vhost_siteA.conf

编辑站点配置文件

  1. #自定义服务器配置开始
  2. server {
  3. listen 80; # 监听端口
  4. server_name www.test.com test.com; # 站点域名
  5. set $root /var/www/html/shengteng-group/public/; # 站点根目录
  6. location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
  7. {
  8. root $root;
  9. }
  10. location / {
  11. root $root;
  12. index index.html index.php;
  13. if ( -f $request_filename) {
  14. break;
  15. }
  16. if ( !-e $request_filename) {
  17. rewrite ^(.*)$ /index.php/$1 last;
  18. break;
  19. }
  20. }
  21. location ~ .+\.php($|/) {
  22. fastcgi_pass unix:/run/php/php7.0-fpm.sock;
  23. fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
  24. fastcgi_param PATH_INFO $fastcgi_path_info;
  25. fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
  26. fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;
  27. include fastcgi_params;
  28. }
  29. }#自定义服务器配置结束

重启 Nginx 服务器 即可

  1. $ service nginx restart

相关推荐:

以上就是在lnmp环境下thinkphp5的一些必要配置的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行