linux nginx tp5

本文详细介绍如何在Linux环境下配置Nginx与PHP-FPM来部署ThinkPHP 5框架的应用,包括修改Nginx和PHP配置文件、设置open_basedir参数、调整权限等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

linux nginx tp5在入口文件添加下列两行,打印错误信息(调试错误)
error_reporting(E_ALL);

ini_set('display_errors', '1');

 

vi /usr/local/nginx/conf/fastcgi.conf
fastcgi_param PHP_ADMIN_VALUE"open_basedir=$document_root/:/tmp/:/proc/";
改成:

fastcgi_param PHP_ADMIN_VALUE "open_basedir=NULL"; 

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

在server数组中配置:

修改:

        server_name 222.222.222.222;
        index index.html index.htm index.php;

        root  /home/wwwroot/you/public;

添加:

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_params;
            set $real_script_name $fastcgi_script_name;
            if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                set $real_script_name $1;
                set $path_info $2;
            }
            fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
            fastcgi_param SCRIPT_NAME $real_script_name;
            fastcgi_param PATH_INFO $path_info;

        }

 

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

open_basedir = 的注释去掉

cgi.fix_pathinfo = 1

allow_url_fopen = on
user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"

upload_max_filesize = 100M

memory_limit = 512M
post_max_size = 100M
max_execution_time = 86400
max_input_time = 86400

disable_functions = (去掉 system , exec )

权限

给项目目录权限chmod -Rf 777 项目名称

最后重启 
service nginx restart
/etc/init.d/php-fpm restart
service mysql restart

nginx -s reload
 

多域名设置就在/usr/local/nginx/conf/vhost/域名.conf中配置,不改nginx.conf,配置项同上。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值