Supporting an old WordPress on Ubuntu 16.04 it was running PHP 7.3 and we really needed to upgrade it to 7.4. But when we did and switched the fastcgi_pass to point to the new version, the site choked.
All webpages suddenly asked for username and password/FTP details to complete the operation and then said that it couldn’t access the filesystem.
I checked the php7.4-fpm.log and there were no errors, likewise in the nginx error.log. It seems like permissions, but they all seemed to check out in /run/php/php7.4-fpm.sock
Curiously, the previous developer was running PHP 7.3 from /run/php-wp-fpm.sock, and not in the /run/php/ where it is created when you install 7.3 or 7.4. Why would they do that?
After some hours of reading every article in the world on this (there’s a lot!) I thought I’d try and run it in /run/ rather than in /run/php/
So altered the /etc/php/7.4/fpm/pool.d/www.conf like this – altering the config and restarting the service creates the new sock file in that folder.
listen = /var/run/php7.4-fpm.sock
listen.owner = www-data
listen.group = www-data
user = web
group = www-data
And then edit the /etc/nginx/sites-available/my-website.com.conf file to match:
fastcgi_pass unix:/run/php7.4-fpm.sock;
Then we restart both fpm and nginx:
systemctl restart php7.4-fpm
service nginx restart
And voila! It worked. No idea why but I guess this is why the previous developer did this!
For reference this is what I did to install PHP on the creaky old Ubuntu version before this:
sudo apt-get update
sudo apt-add-repository ppa:ondrej/php
(this repo may not have what you need, you could try ppa:jczaplicki/xenial-php74-temp but this it at your own risk)
sudo apt install -y php7.4 php7.4-cli php7.4-common php7.4-fpm
sudo apt install -y php7.4-mysql php7.4-dom php7.4-simplexml php7.4-ssh2 php7.4-xml php7.4-xmlreader php7.4-curl php7.4-exif php7.4-ftp php7.4-gd php7.4-iconv php7.4-imag
sudo apt install -y php7.4-mysqli php7.4-pdo php7.4-sqlite3 php7.4-ctype php7.4-fileinfo php7.4-zip php7.4-exif
sudo update-alternatives --config php (choose 7.4)
(edit your config files as above)
systemctl restart php7.4-fpm
service nginx restart
I’m a complete Linux/nginx novice, so this has truly been a nightmare for me, I hope this helps at least one person!
Comments