How to Install & Configure Latest Nginx Mainline Version on Ubuntu 16.04 / 18.042 min read

February 16, 2019 2 min read


How to Install & Configure Latest Nginx Mainline Version on Ubuntu 16.04 / 18.042 min read

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

If you don’t already have a VPS, or want to reward us for hard work and ad free experience you can buy a VPS from us. We would really appreciate it as we don’t have any donation buttons and this is our only source of income. Our VPSes are located in Stockholm, and we even have a Swedish branded site if you’re from Sweden.

Notify of
Inline Feedbacks
View all comments