lnmp 线上部署 thinkphp

环境介绍

php 7.3.23
mysql 5.7
系统 lnmp一键安装包 配置域名
项目目录 "/root/www/项目名"

描述

  1. 进入工作空间 /root/www
  2. 克隆项目
  3. 赋予权限
  4. composer更新依赖
  5. 填坑
  6. 访问项目

操作

cd /root/www
git clone https://gitee.com/xxxx/thinkphp.git
chmod -R 777 /root
cd /root/www/thinkphp
composer update  #遇到【坑1】

访问域名 www.xxx.com 无法访问 【坑2】

填坑

【坑1】 [ErrorException] Undefined index: process


【解决方案】:

cd /usr/local/php/etc/
vim php.ini

搜索 proc_open,找到下面这些代码,把 proc_open 删除掉(下面代码是删除过的)

disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server

lnmp restart 重启服务器
【坑1.2】然后又报第二个错误 [ErrorException] proc_get_status() has been disabled for security reasons

继续在php.ini中 删除 proc_get_status 这些函数是干什么的
lnmp restart 重启服务器
然后继续执行composer update 成功

【坑2】500错误

如果是404的错误,文件没有找到,那么你需要调整一下nginx。在这里不阐述了
如果是500错误,在项目根目录/public/index.php开始调试

namespace think;
error_reporting(E_ALL);
ini_set('display_errors', '1');
echo 123;

输出结果

123
Warning: require(): open_basedir restriction in effect. File(/root/www/tpapi/vendor/autoload.php) is not within the allowed path(s): (/root/www/tpapi/public/:/tmp/:/proc/) in /root/www/xxxx/public/index.php on line 18

Warning: require(/root/www/tpapi/vendor/autoload.php): failed to open stream: Operation not permitted in /root/www/xxxx/public/index.php on line 18

Fatal error: require(): Failed opening required '/root/www/tpapi/public/../vendor/autoload.php' (include_path='.:/usr/local/php/lib/php') in /root/www/xxxx/public/index.php on line 18

【解决方案】 修改fastcgi的配置文件 vim /usr/local/nginx/conf/fastcgi.conf

fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
修改为
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/../:/tmp/:/proc/";

【解决方案二】 直接把这行注释
lnmp restart 重启服务器

其他

如何用phpstorm编辑远程项目
在线Apache(Htaccess)转换Nginx工具
LNMP 开启MySQL数据库远程访问

原文地址:https://www.cnblogs.com/zhaoyang-1989/p/14229159.html