After deploying based on LNMP 2.1, the interface responds to 500 because the configuration of .user.ini is incorrect
1. The interface response is 500. as shown in Figure 1
2. Check the error log of nginx. Error report: php message: php warning: require(): open_basedir restriction in effect. file(/home/wwwroot/object/src/vendor/autoload.php) is not within the allowed path(s): as shown in Figure 2
2025/03/11 10:46:31 [error] 323148#0: *3 FastCGI sent in stderr: "PHP message: PHP Warning: require(): open_basedir restriction in effect. File(/home/wwwroot/object/src/vendor/autoload.php) is not within the allowed path(s): (/home/wwwroot/object/src/api/web/:/tmp/:/proc/) in /home/wwwroot/object/src/api/web/index.php on line 6PHP message: PHP Warning: require(/home/wwwroot/object/src/vendor/autoload.php): failed to open stream: Operation not permitted in /home/wwwroot/object/src/api/web/index.php on line 6PHP message: PHP Fatal error: require(): Failed opening required '/home/wwwroot/object/src/api/web/../../vendor/autoload.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/object/src/api/web/index.php on line 6" while reading response header from upstream, client: 101.204.100.38, server: objectapi.ikhw.cn, request: "POST /unregistered-user/get-id HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi.sock:", host: "objectapi.ikhw.cn"
3. Reference:lnmp add and delete virtual host and pseudo-static use tutorial to prevent cross-directory settings View content in .user.ini
[root@iZ2zeaj7tnbv8d3gsoy1w5Z object]# cat .user.ini
open_basedir=/home/wwwroot/object:/tmp/:/proc/
4. Edit .user.ini. The .user.ini file cannot be modified directly, if you want to repair or delete it, you need to execute it first: chattr -i /home/wwwroot/object/.user.ini
[root@iZ2zeaj7tnbv8d3gsoy1w5Z object]# cat .user.ini
open_basedir=/home/wwwroot/object/src:/tmp/:/proc/
5. Still reporting an error. The final decision to delete .user.ini. Reference:Anti-cross-site and cross-directory security settings under LNMP, only PHP 5.3.3 or above is supported Edit directly in php.ini
2025/03/11 10:53:59 [error] 323149#0: *5 FastCGI sent in stderr: "PHP message: PHP Warning: require(): open_basedir restriction in effect. File(/home/wwwroot/object/src/vendor/autoload.php) is not within the allowed path(s): (/home/wwwroot/object/src/api/web/:/tmp/:/proc/) in /home/wwwroot/object/src/api/web/index.php on line 6PHP message: PHP Warning: require(/home/wwwroot/object/src/vendor/autoload.php): failed to open stream: Operation not permitted in /home/wwwroot/object/src/api/web/index.php on line 6PHP message: PHP Fatal error: require(): Failed opening required '/home/wwwroot/object/src/api/web/../../vendor/autoload.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/object/src/api/web/index.php on line 6" while reading response header from upstream, client: 101.204.100.38, server: objectapi.ikhw.cn, request: "POST /unregistered-user/get-id HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi.sock:", host: "objectapi.ikhw.cn"
2025/03/11 10:53:59 [error] 323149#0: *5 FastCGI sent in stderr: "PHP message: PHP Warning: require(): open_basedir restriction in effect. File(/home/wwwroot/object/src/vendor/autoload.php) is not within the allowed path(s): (/home/wwwroot/object/src/api/web/:/tmp/:/proc/) in /home/wwwroot/object/src/api/web/index.php on line 6PHP message: PHP Warning: require(/home/wwwroot/object/src/vendor/autoload.php): failed to open stream: Operation not permitted in /home/wwwroot/object/src/api/web/index.php on line 6PHP message: PHP Fatal error: require(): Failed opening required '/home/wwwroot/object/src/api/web/../../vendor/autoload.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/object/src/api/web/index.php on line 6" while reading response header from upstream, client: 101.204.100.38, server: objectapi.ikhw.cn, request: "POST /unregistered-user/get-id HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi.sock:", host: "objectapi.ikhw.cn"

