
这是一系列的错误,在上一篇里遇到了lnmp.org环境安装innoshop0.5版本的情况,分开说:
1.lnmp.org脚本安装innoshop报http error 500错误及安装php多版本失败
起初遇到这个问题,是由于lnmp.org后台只安装了php7.3,所以放入代码后直接报http error 500的错误,经自查发现是php版本低了。于是使用./install.sh mphp安装多版本时,又遇到configure: error: *** A compiler with support for C++17 language features is required,这是系统的c++运行库版本低了。
辗转又去安装DevToolset,最终成功安装了php8.2,具体情况看这一篇:
http://www.784533.xyz/archives/224/
2.composer install安装错误
Fatal error: Uncaught Error: Failed opening required '/home/wwwroot/www.ledmore.cn/public/../vendor/autoload.php' (include_path='.:/usr/local/php8.2/lib/php') in /home/wwwroot/www.ledmore.cn/public/index.php:21 Stack trace: #0 {main} thrown in /home/wwwroot/www.ledmore.cn/public/index.php on line 21
判断上面错误来自于laravel框架的报错,由于innoshop使用了comoser组件,正常情况下只使用的是完整程序包,丢进去就直接杺看到安装界面。
到网站根目录删除composer.lock文件,重启执行composer install,运行了几十条之后出现新报错:
Problem 1 - Root composer.json requires php ^8.2 but your php version (7.4.33) does not satisfy that requirement.
Problem 2 - Root composer.json requires aws/aws-sdk-php ^3.342 -> satisfiable by aws/aws-sdk-php[3.342.0, ..., 3.350.1]. - aws/aws-sdk-php[3.342.0, ..., 3.350.1] require php >=8.1 -> your php version (7.4.33) does not satisfy that requirement.
Problem 3 - Root composer.json requires phpunit/php-timer ^7.0 -> satisfiable by phpunit/php-timer[7.0.0, 7.0.1]. - phpunit/php-timer 7.0.1 requires php >=8.2 -> your php version (7.4.33) does not satisfy that requirement.
Problem 4 - Root composer.json requires laravel/pint 1.18.2 -> satisfiable by laravel/pint[v1.18.2]. - laravel/pint v1.18.2 requires php ^8.1.0 -> your php version (7.4.33) does not satisfy that requirement.
Problem 5 - intervention/image[3.5.0, ..., 3.11.3] require php ^8.1 -> your php version (7.4.33) does not satisfy that requirement.
这里就奇怪了,lnmp.org明明是升级了php8.2,但为什么显示 的是php7.4.33 ,不过转念一想,composer install是在shell中执行的,lnmp.org环境是配置了多版本,但是这并不是centos的系统默认配置,使用php -v一查,果然是php7.4.33,接下来就是要把系统配置php版本改成php8.2。
# 移除旧PHP链接
sudo rm /usr/bin/php
# 创建新链接到PHP 8.2
sudo ln -s /usr/local/php8.2/bin/php /usr/bin/php
# 验证版本
php -v # 应显示 8.2.x
重启系列,执行comoser install直至完成。至此composer问题解决。
3.The Process class relies on proc_open
刷新页面,新问题出现:
[Symfony\Component\Process\Exception\RuntimeException] The Process class relies on proc_open, which is not available on your PHP installation.
这个好解决,这是lnmp.org为了安全,默认关闭了几个高危php函数。找到对应版本的php.ini文件,修改即可:
disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
删除proc_open,proc_get_status,proc_open put_env,重启nginx问题解决。
//此处感谢innoshop创始人空山补充。
4. open_basedir相关报错
继续出现报错:
Warning: file_exists(): open_basedir restriction in effect.
File(/home/wwwroot/www.xxx.cn/public/../storage/installed) is not within the allowed path(s): (/home/wwwroot/www.xxx.cn/public/:/tmp/:/proc/) in /home/wwwroot/www.xxx.cn/public/index.php on line 9
Warning: file_exists(): open_basedir restriction in effect. File(/home/wwwroot/www.xxx.cn/public/../storage/framework/maintenance.php) is not within the allowed path(s): (/home/wwwroot/www.xxx.cn/public/:/tmp/:/proc/) in /home/wwwroot/www.xxx.cn/public/index.php on line 16
Warning: require(/home/wwwroot/www.xxx.cn/vendor/autoload.php):
Failed to open stream: Operation not permitted in /home/wwwroot/www.xxx.cn/public/index.php on line 21
Fatal error: Uncaught Error: Failed opening required '/home/wwwroot/www.xxx.cn/public/../vendor/autoload.php' (include_path='.:/usr/local/php8.2/lib/php') in /home/wwwroot/www.ledmore.cn/public/index.php:21 Stack trace: #0 {main} thrown in /home/wwwroot/www.ledmore.cn/public/index.php on line 21
由于laravel框架在设计上目录结构不同,举例一般网站/www/wwwroot/aaa_com这个就是根目录,但laravel thinphp这些不是,会把框架文件放在这个目录,但要把网站根目录指向/www/wwwroot/aaa_com/public,也许是为了为安全。但对于php来说,从一个文件访问向上的目录本就是一个跨站安全漏洞,为了正常使用laravel或innoshop,就不能做 open_basedir()限制。
可以通过phpinfo()查看是否启用跨站目录限制,这种限制有可能会出现在三个地方,一个是nginx的配置中,另一个在框架目录中的.usr.ini文件,或者在php.ini中。
首选清空或者删除.usr.ini文件,这个文件有只读属性,直接是删不掉的。
lsattr .usr.ini查看只否只读,chattr -i .usr.ini去掉只读属性。
然后将文件清空或者删除。
其次查看php.ini是否有限制,有就去掉。
最后检查 nginx.conf,如果有就一并清除。
重启系统,不再报错。
5.innoshop 500 Server Error报错
在经历上面的曲折后,又继续到了下一个报错,一个innoshop粉红色背景的500 Server Error,好在已经不是在php上面报错,程序已经在laravel中执行了,只是报的是500错误。
innoshop或者laravel对底层的报错进行了屏蔽,想看看具体的报错怎么办呢? 这时候不知道是去laravel中开启bebug还是到innoshop开启bebug,innoshop后台是有debug开关的,但我们目前还没有安装成功。
经咨询开发者,得知在框架目录下有一个.evn的文件,将APP_DEBUG=false修改为ture,刷新界面,神奇的是,这里没有看到报错,反而看到了正常的innoshop安装引导页面。
按步骤安装成功。
ps.至此说明还是有少少问题的,也许跟php err_reporting显示级别太低有关,此处暂时不深究。
文末感言,纵然lnmp.org是一个不错的lnmp运行环境,但是对于laravel和innoshop来说,并不是太合适,有时间我再测试一下宝塔的一些版本。