close up shot of a typewriter

Fix WordPress HTTP 500 with Caddy2

Views: 735
0 0
Read Time:1 Minute, 30 Second

I upgraded my Unbuntu recently to 22.04LTS. In the process, the php-fpm was updated too to 8.1. This resulted in 500 errors for WordPress and permission issues to update WordPress themes as it requires FTP info “To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host”.

To fix the issue, I have to update the php-fpm configs similar to this post when I first set up WordPress on Caddy 2.

Fix the Caddyfile to point to the updated php-fpm

$ sudo vim Caddyfile

Change the lines where Caddy calls the php-fpm listener, replace the correct version of php-fpm located under /run/php

php_fastcgi unix//run/php/php8.1-fpm.sock

Don’t forget to reload the Caddyfile to apply the changes

$ sudo systemctl reload caddy

Configure php-fpm to work with Caddy2

To ensure WordPress has the correct write permission after being served by Caddy, we need to update the PHP-FPM config. Otherwise, WordPress might throw out “error occurred while updating” during theme update, or require FTP access to install any themes or plugins, or plainly throw HTTP 500. To do this, you will need to modify the FPM pool config.

In the FPM Pool config file, change the listen.grouplisten.useruser and group to caddy, or the username created to run the Caddy server.

$ sudo vim /etc/php/8.1/fpm/pool.d/www.conf

Then restart PHP-FPM service to apply the changes

$ sudo service php8.1-fpm restart

Check if WordPress is Working with Caddy 2

In browser, go to https://yourdomain.com/wordpress and WordPress should be running.

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

One Reply to “Fix WordPress HTTP 500 with Caddy2”

Leave a Reply