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.6k Mac OSX : Find large files by size
+13.5k Golang : How to determine if a year is leap year?
+17.3k Golang : Defer function inside init()
+35.1k Golang : Integer is between a range
+23.7k Golang : Call function from another package
+11k Golang : How to pipe input data to executing child process?
+5.7k Golang : Detect variable or constant type
+19.3k Golang : Close channel after ticker stopped example
+6.4k Golang : Check if password length meet the requirement
+25.7k Mac/Linux and Golang : Fix bind: address already in use error
+6.6k Android Studio : Hello World example