Hi
I have a server running Ubuntu 16.04 with Nginx and php 7.0 Server is running and Nginx is serving pages fine for existing virtual servers.
I needed to have php 5.6 running as well, so I installed it as php-fpm and manually changed the location of the socket for one virtual server that needed php 5.6.
Now, when I create new servers I get a Bad Gateway 502 error:
2016/10/18 00:23:06 [crit] 2818#2818: 5 connect() to unix:/var/php-nginx/14767429362197.sock/socket failed (2: No such file or directory) while connecting to upstream, client: *..., server: ************, request: "GET /phpinfo.php HTTP/1.1", upstream: "fastcgi://unix:/var/php-nginx/14767429362197.sock/socket:", host: "*****************"
The folder 14767429362197.sock exists, but without content (no socket).
What did I mess up ? :-) Any help is much appreciated.
Thanks
I don't think you can use multiple versions of PHP with nginx.
I do have sites running on the server, running php 7 and php 5.6 - problem is when creating new virtual servers
This might help, https://tjosm.com/5105/502-bad-gateway-error-after-reboot-virtualmin-ngi...
I provide FREE Server Management Services in exchange of money
Freddy63 I was just looking at that page :-)
When I looked at the "/etc/init.d/php-domainname-ext" files that is created for each virtual server:
Before I installed php5.6-fpm:
#!/bin/sh
### BEGIN INIT INFO
# Provides: php-fcgi-domainname-dk
# Required-Start: $network $syslog
# Required-Stop: $network
# Default-Start: 2 3 5
# Default-Stop:
# Description: Start Nginx PHP fcgi server for domainname.dk
### END INIT INFO
case "$1" in
'start')
su domainname\.dk -c PHPRC\=\/home\/domainname\.dk\/etc\/php7\.0\ PHP_FCGI_CHILDREN\=4\ \/usr\/bin\/php\-loop\.pl\ \/usr\/bin\/php\-cgi7\.0\ \-b\ \/var\/php\-nginx\/139964521415052\.sock\/socket\ \>\>\/home\/domainname\.dk\/logs\/php\.log\ 2\>\&1\ \<\/dev\/null\ \&\ echo\ \$\!\ \>\/var\/php\-nginx\/139964521415052\.php\.pid
RETVAL=$?
;;
'stop')
su domainname\.dk -c kill\ \`cat\ \/var\/php\-nginx\/139964521415052\.php\.pid\` ; sleep 1
RETVAL=$?
;;
'restart')
$0 stop ; $0 start
RETVAL=$?
;;
*)
echo "Usage: $0 { start | stop }"
RETVAL=1
;;
esac
exit $RETVAL
after
#!/bin/sh
### BEGIN INIT INFO
# Provides: php-fcgi-test-domainname-dk
# Required-Start: $network $syslog
# Required-Stop: $network
# Default-Start: 2 3 5
# Default-Stop:
# Description: Start Nginx PHP fcgi server for test.domainname.dk
### END INIT INFO
case "$1" in
'start')
su test\.domainname\.dk -c PHP_FCGI_CHILDREN\=4\ PHPRC\=\/home\/test\.domainname\.dk\/etc\/php5\.6\ \/usr\/bin\/php\-loop\.pl\ \/usr\/bin\/php5\.6\ \-b\ \/var\/php\-nginx\/14767447216070\.sock\/socket\ \>\>\/home\/test\.domainname\.dk\/logs\/php\.log\ 2\>\&1\ \<\/dev\/null\ \&\ echo\ \$\!\ \>\/var\/php\-nginx\/14767447216070\.php\.pid
RETVAL=$?
;;
'stop')
su test\.domainname\.dk -c kill\ \`cat\ \/var\/php\-nginx\/14767447216070\.php\.pid\` ; sleep 1
RETVAL=$?
;;
'restart')
$0 stop ; $0 start
RETVAL=$?
;;
*)
echo "Usage: $0 { start | stop }"
RETVAL=1
;;
esac
exit $RETVAL
So it seems, it now tries to connect to php 5.6, not php 7 for new sites... ? NB: I have Webmin 1.820 installed on the server.
Removed php5.6-fpm and installed it again using: apt-get install php5.6 php5.6-cgi php5.6-fpm Now, I disabled Nginx website for the virtual server and enabled it again.
This has partly solved the issue - now my old PHP 7 virtual servers are running and also new servers I create are running. So I have PHP 7 and PHP 5.6 running together witch is fine.
Problem now is new servers is created with PHP 5.6, not PHP 7. Wondering how I can change that?