tp5项目部署至Linux

1.Linux 添加虚拟主机,访问目录绑定至 public下面

2.更新配置文件,修改你自己的.conf文件,比如a.conf,我的是在 /usr/local/nginx/conf/vhost/目录下,然后添加

location / {

            if (!-e $request_filename) {
                  rewrite  ^(.*)$  /index.php?s=/$1  last;
                break;
            }
        }

        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            include        fastcgi.conf;

        }

3.重启下Nginx,centos的 直接service Nginx restart

4.然后访问你的域名。

5.有些小伙伴的可能会出错,可能会出现error 500的错误,不用慌,

    error_reporting(E_ALL);

    ini_set('display_errors', '1');

直接把这两行代码,放在你的public/index.php 里面,最上面,然后保存,再次访问,看错误。

6.

1)若错误是file_exists(): open_basedir restriction in effect.之类的。

2)不用怕,找到你的conf文件的上一级目录/usr/local/nginx/conf/,直接进入,找到fastcgi.conf 这个文件,

3)然后打开,找到fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";这一行,

修改为fastcgi_param PHP_ADMIN_VALUE "open_basedir=/home/www/:/tmp/:/proc/";  只需要把$document_root,改为你项目的所在目录,比如:/home/wwwroot/然后保存,重启Nginx。注意:不是网站根目录,不要配置到Public下面!!!

7.重新访问,是不是可以了呢,喜欢的小伙伴,留言吧,或者联系QQ:3396475100或群:372319250,替你解决更多小烦恼哦!

8.若是报错 mkdir(): Permission denied,说明,没有权限 chmod -R 777 你的目录就行啦。

猜你喜欢

转载自blog.csdn.net/qq_38997379/article/details/80391501