How to Install & Configure Latest Nginx Mainline Version on Ubuntu 16.04 / 18.04

Switch Your VPS Hosting! Our SSD powered servers are both faster and cheaper than the competition, if not we'll match it!

Get Faster Hosting Today!

Why am I writing this tutorial?

Hi there again! I choose to write this tutorial because I have gotten very frustrated looking around for tutorials that actually work for the latest version of Nginx. All other guides only works for Nginx 1.12 and below, even though the current version is 1.15.8. This is simply dumb and I hope that with this you do not have to look around for hours upon end without any progress whatsoever!

Install Nginx

To install the current version of Nginx, simply follow the documentation on its offical website seen here or do the following commands:

sudo apt install curl gnupg2 ca-certificates lsb-release
echo "deb `lsb_release -cs` nginx" \     | sudo tee /etc/apt/sources.list.d/nginx.list
curl -fsSL | sudo apt-key add - 

Now that we have downloaded & verified its authnicity lets install it!

sudo apt update
sudo apt install nginx

Useful Commands

That’s it! You have now installed the latest release of Nginx. You should now start it and make it start on reboot.sudo systemctl start nginx.service
sudo systemctl enable nginx.service

sudo systemctl start nginx.service
sudo systemctl enable nginx.service

To restart or stop nginx:

sudo systemctl stop nginx.service
sudo systemctl restart nginx.service

Setup Your Website

You should now verify that nginx has started and is correctly installed by visiting it. Http://YourServerIp. If everything is correctly setup you should see something like this:

Image result for welcome to nginx
The default index page for nginx.

Your website configuration is located at/etc/nginx/conf.d/default.conf
Your website HTML files are located at/usr/share/nginx/html

Now what?

Well now you can upload your own files or install wordpress as shown here

If you should happen to want to install PHP you need to configure Nginx a little bit more. Otherwise it can cause permission problems later down the road, like returning permission denied errors.

Add nginx to www-data group

sudo usermod -a -G www-data nginx

Change owner of directory to www-data

sudo chown -R www-data /usr/share/nginx/html
0 0 vote
Article Rating

David Berndtsson

Retired member at HostUp and loves to write tutorials that actually work.

Need VPS Hosting? Give HostUp a go! Our SSD powered servers will give you a blazing fast experience. From $3.50 / month.

View Plans

Notify of
Newest Most Voted
Inline Feedbacks
View all comments

[…] web server to run the WordPress software. To do this is quite simple. Just follow this tutorial on How to Install Nginx. There is a few basic things that you need to know if you have never done this before. The $ […]


[…] there again! If you are like me and want to use the friendly URLs option with Nginx on WHMCS, but noticed that it does not work, then you have come to the right […]

Copy link