Create a virtual server for you domain

In this lesson, I will use the domain name, example.com, for my domain.

To start, from Virtualmin, click on Create Virtual Server.

That will take you to the page where you can enter your domain name, your password, and some optional stuff.

The only information that is required is your domain name and a password.

Also, since Nginx can only have one SSL website per IP address, make sure that you uncheck the box next to "Enable Nginx SSL website?" if you already have an SSL website on the IP address that you're going to use. You will get an error if you try to set up an SSL site on an IP that already has an SSL site.

Click on "Create Server" when you've entered all information. Virtualmin will set up your virtual server, along with MySQL databases, mail users, and everything else.

So far, everything except for the "1 SSL site per IP" is exactly like setting up an Apache based virtual server in Virtualmin.

If you've followed my tutorial that shows how to set up Nginx with Virtualmin, you might want to install a Wordpress site. Here is where I'll show you how to do that.

Install Wordpress (the normal way)

Wordpress is now installed the normal way. There is nothing different that needs to be done. 

You can use FTP to transfer the Wordpress install files to your server, or use wget or curl. I use wget. 

However you do it, it doesn't matter. Just make sure you took note of the username that Virtualmin created for your virtual server. You'll need it to tell the Wordpress installer what your username is for your database. 

So complete a regular Wordpress install. Almost everything so far in this lesson has been the same as it is with installing Wordpress on Apache. The only difference being that, as mentioned earlier, nginx can only have one SSL site per IP.

You'll now have a functional Wordpress install working on your Virtualmin managed server running nginx. It should work right out of the box. 

Fixing Permalinks

Permalinks will not work right away when Wordpress is installed on Virtualmin with Nginx. But to make permalinks work only requires one line to be added to your Nginx configuration.

You can go ahead right now and set your Permalink format to how you want them in the Wordpress backend at Settings -> Permalinks. Permalinks won't work yet though until you make a small modification to your Nginx settings. You'll get 404 errors for all of your links until you do the next step.

Modify Nginx Configuration

Now go back to Virtualmin where you're going to edit your nginx configuration. 

From the main Virtualmin page that you can get to by clicking the word Virtualmin at the top of the page, scroll down to where it says "Status" at the bottom of the page.

Click on "Status" to expand it and then click on Nginx Webserver.

Now you'll be in the Nginx Webserver module of Virtualmin and you can click on "Edit Configuration Files" to get to where you will make an addition to your nginx configuration. 

You should now be looking at a text area which shows your /etc/nginx/nginx.conf file. If that's not the file that is indicated, then switch to that file. 

Now, look for the lines that look like:

location ~ \.php$ {

try_files $uri =404;

fastcgi_pass unix:/var/php-nginx/146342183325130.sock/socket;

}

The number in the fastcgi_pass line will vary.

 

Right below those lines, paste the following text on a new line:

                location / { try_files $uri $uri/ /index.php?$args; }

 Then click "Save".

 

Finally, on the resulting page, click on the button that says "Apply Nginx Configuration". 

That's the last thing you need to do in order to get Wordpress, Nginx, and Virtualmin working together - with permalink functionality.

 

Finished

Wordpress with permalinks should now be fully functional on your Virtualmin server running Nginx. I hope it was easy.

If you're going to use a caching plugin, you'll need to make other tweaks to your Nginx configuration. The Wordpress documentation covers some of what is required to make those plugins work on their dedicated nginx page. The Nginx site also has a lot of information about making various Wordpress features work with Nginx.