I ran into an issue with this migration from Ubuntu Server 18.04 LTS to Ubuntu Server 24.04 LTS because I decided to get rid of my hybrid Nginx-Apache reverse proxy install and use straight up Nginx.
When setting the permalinks to from plain
to /%year%/%monthnum%/%day%/%postname%/
, the site would not re-write the URLs and every link on the site was broken.
As it turns out, all this is done with the .htaccess
file in Apache and this doesn’t work in Nginx. Since my site predates the use of Nginx (which was an add-on necessary for FoundryVTT server), every site I was hosting used the .htaccess
file.
Here is a rundown to configure Nginx for proper WordPress functionality Ubuntu Server 24.04 LTS. I am assuming you have Nginx, mariaDB, PHP-FPM, and virtual hosts all setup and have your WordPress site up and running.
- SSH into to your server.
- Sudo Edit your
/etc/nginx/sites-enabled/example-site.conf
file and change following line in your default vhost location directive from=404;
to/index.php?$args;
# sudo nano /etc/nginx/sites-enabled/example-site.conf
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?$args;
- Save and Exit the file.
- Test your configuration files with
sudo nginx -t
. - Reload nginx with
sudo systemctl reload nginx
.
You can read more about this in the advanced server configuration guide for Nginx at the developers.wordpress.org site.