Php 在openresty和nginx之间切换时出现问题
我正在尝试使用Php 在openresty和nginx之间切换时出现问题,php,bash,nginx,openresty,Php,Bash,Nginx,Openresty,我正在尝试使用php使用exec在nginx和openresty之间切换 我用它来切换到openresty,exec('/bin/systemctl stop nginx;/usr/local/openresty/nginx/sbin/nginx-p/usr/local/openresty/nginx') 这个exec('/usr/local/openresty/nginx/sbin/nginx-s stop;/bin/systemctl start nginx')切换到nginx 两者都是从s
php
使用exec
在nginx
和openresty
之间切换
我用它来切换到openresty,exec('/bin/systemctl stop nginx;/usr/local/openresty/nginx/sbin/nginx-p/usr/local/openresty/nginx')代码>
这个exec('/usr/local/openresty/nginx/sbin/nginx-s stop;/bin/systemctl start nginx')代码>切换到nginx
两者都是从sshssh
,但是,从php我无法启动nginx。此/bin/systemctl start nginx
似乎未执行。我尝试从.sh
文件执行代码,但没有成功。尝试使用
exec('/usr/local/openresty/nginx/sbin/nginx -s stop && /bin/systemctl start nginx');
我用它来切换到openresty
:
shell_exec('/bin/systemctl stop nginx; /usr/local/openresty/nginx/sbin/nginx -p /usr/local/openresty/nginx');
然后切换到nginx
:
shell_exec('/usr/local/openresty/nginx/sbin/nginx -s stop; /bin/systemctl restart nginx');
您好,首先启动此服务需要特权,特别是它们需要特权端口(只能由root用户打开)。第二,你能说出你在使用哪个发行版吗?可能存在多个问题,如apparmor或SELinux。有可能得到改变服务的php代码吗?服务是否已更改为置于后台并与会话分离?@AlexBaranowski我正在使用Centos 7
,php
正在以root权限运行。您可以尝试以下技巧吗<代码>执行('/usr/bin/nohup$(sleep 2;/usr/local/openresty/nginx/sbin/nginx-s stop;/bin/systemctl start nginx)&')代码>。这将使子shell与nginx分离。