Common issues running WordPress with Caddy 2

This article covers the common issues and errors while setting up WordPress to run on the Caddy 2 web server. If you have not set up WordPress on Caddy 2, you can follow this guide.

Error installing theme or plugins or requesting FTP credentials

With Caddy, while updating WordPress themes, or installing WordPress plugins, WordPress might show an error message of “An expected error occurred.” In other cases, WordPress would ask for FTP credentials when installing plugins or theme. This is because to perform the requested action, WordPress would need access your web server, but it does not have the write permission configured to change the files on the file system.

To address this, make sure the Caddy server has PHP-FPM configured, and the PHP-FPM shares the same user with the Caddy server. Also, make sure the WordPress folder are owned by the same user as the Caddy server. To address the issue, you could follow Section 5.2 of this guide.

Error while enable WordPress Jetpack plugin

While enabling the Jetpack plugin, the activation might fail due to "XR -32300: transport error: http_request_failed cURL error 35: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure". Please check if the Caddyfile to see if it has any special clause for the tls{} block, that specifies the TLS version, or the cipher method. If so, remove those and try again.

WordPress upload limit is only 2MB, how do I increase it?

WordPress will automatically show the maximum file upload size limit when you are uploading images or media. To check it, you can go to Media » Add New page and you will see the maximum file uplaod size limit for your WordPress site.

To increase the upload size with Caddy 2, find the php.ini file being used by PHP-FPM, following Section 5.1 of this guide, then update the file to add/change the following code:

upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300

The apply the changes by restarting PHP-FPM.

$ sudo service php7.4-fpm restart

SEO Plugin Yoast index.php/sitemap_index.xml 404, not found, with Caddy

Yoast gave instructions to configure rewrite rules on NGINX servers. But it needs a little adaptation to work with Caddy 2. Try adding the following lines to your Caddyfile, usually located under /etc/caddy/. Note that the below works with Caddy v2.

# Sitemap for Yoast plugin 
@sitemap_index {
    path_regexp ^/wordpress/index.php/sitemap_index.xml$
}
rewrite @sitemap_index /wordpress/index.php?sitemap=1
@sitemap {
    path_regexp sitemap ^/wordpress/index.php/([^/]+?)-sitemap([0-9]+)?.xml$
}
rewrite @sitemap /wordpress/index.php?sitemap={http.regexp.sitemap.1}&sitemap_n={http.regexp.sitemap.2}

Other questions?

Feel free to leave a comment below, if you run into other issues setting up WordPress on Caddy 2.

Leave a Reply