Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
Problem:
Encounter this error message :
Failed to start php5-fpm.service: Unit php5-fpm.service is masked.
after upgrading Ubuntu with do-release-upgrade
command. The problem was caused by php5 being upgraded to php7.
NOTE: Putting this down as a note for myself for future reference. You might need to change the solution given below to suit your own server's environment.
!! Always backup first before upgrade and write down the steps/commands taken !!
Solution:
1) Execute
sudo apt-get install php-fpm
2) Execute
sudo service php7.0-fpm restart
3) From /var/log/nginx :
2016/04/26 18:15:47 [crit] 1526#0: *10 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 121.122.88.176, server: example.com, request: "GET /admin HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "example.com"
4) Did a ps -ef | grep fpm
and the grab the configuration file used by the fpm master process
and found out that it has include=/etc/php/7.0/fpm/pool.d/*
5) Go to /etc/php/7.0/fpm/pool.d/www.conf
and found
listen = /run/php/php7.0-fpm.sock
6) Go to /etc/nginx/ and change nginx.conf
change this line:
fastcgi_pass unix:/var/run/php5-fpm.sock;
to
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
7) Restart nginx
8) New problem
2016/04/26 18:27:58 [crit] 3403#0: *1 connect() to unix:/run/php/php7.0-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 121.122.88.176, server: example.com, request: "GET /admin HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "example.com"
9) Edit /etc/php/7.0/fpm/pool.d/www.conf ( please change according to your own configuration )
change
user = www-data
group = www-data
to
user = nginx
group = nginx
and
listen.owner = www-data
listen.group = www-data
to
listen.owner = nginx
listen.group = nginx
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+6.3k Android Studio : AlertDialog to get user attention example
+17.9k Golang : Clearing slice
+5.1k PHP : How to check if an array is empty ?
+5k Java : Human readable password generator
+15.1k Golang : Check if a string contains multiple sub-strings in []string?
+17.7k Golang : Read input from console line
+38.8k Golang : How do I convert int to uint8?
+38.2k Golang : UDP client server read write example
+6.4k Golang : Rename part of filename
+18k Mac OSX : Homebrew and Golang
+7.9k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference
+9.1k Golang : Read file and convert content to string