Installing WordPress is not all to it. For WordPress to function properly, one must make sure all the correct settings are in place. This brief tutorial shows you how to correctly configure Nginx or Apache2 webservers to allow WordPress permalinks.
On this site, we’ve written many detailed tutorials on installing WordPress on Nginx and Apache2. Many of our tutorials written are done so that new students and users don’t experience issues after setting things up.
To read a previous post on installing WordPress, please search our site. There are many well written posts that will help you do that.
Step 1: Setting up Apache2 to allow WordPress Permalinks
To setup Apache2 to allow WordPress Permalinks you first need to enable Apache2 rewrite module. This can be done by running the commands below
sudo a2enmod rewrite
Then restart Apache2 server by running the commands below
sudo systemctl restart apache2.service
After restarting Apache2, go and add the below directory block into Apache2 VirtualHost file for WordPress. On Ubuntu the default file is at
sudo nano /etc/apache2/sites-available/000-default.conf
The the block below and save the file.
Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
Directory>
The change your changes and restart Apache2
Step 2: Setting up Nginx to allow WordPress Permalinks
The steps above showed you how to do it with Apache2. The ones below show you how to do it with Nginx.
The good thing about Nginx is it’s usually built with its rewrite module enabled so you don’t need to first enable it. All you have to do it add a single rewrite line into the site configuration file and you’re done.
Open WordPress site configuration file, usually at the path below
sudo nano /etc/nginx/sites-available/default.conf
The add the line below to enable rewrite for WordPress permalinks
location / { index index.php index.html index.htm; try_files $uri $uri/ /index.php?$args;
Save your changes and and restart Nginx webserver and you’re done.
sudo systemctl restart nginx.service
These are the steps the correctly configure Apache2 or Nginx webservers to allow WordPress permalinks.
Enjoy!
Related posts:
- Redirect HTTP to HTTPS using Nginx or Apache2 on Ubuntu 17.04
- Apache2 301 Redirect Without htaccess File on Ubuntu 17.04
- Setup Varnish and Apache2 on Ubuntu 17.04 / 17.10
- Setup Apache2 Virtual Hosting on Ubuntu 17.04 / 17.10
- Install WordPress on Ubuntu 17.04 / 17.10 with Apache2 HTTP/2 and Let’s Encrypt SSL
- Running Multiple WordPress Sites on Ubuntu 16.04 LTS with Apache2, MariaDB and PHP 7.1 Support
- Install Ghost CMS on Ubuntu 16.04 / 17.10 / 18.04 with MariaDB and Apache2 Proxy
- Install the Latest Apache2 HTTP Server ( 2.4.34 ) on Ubuntu 16.04 / 17.10 / 18.04 LTS Servers
- Apache2 HTTP Server ( 2.4.35 ) Released — Here’s How to Install / Upgrade on Ubuntu 16.04 / 18.04 LTS