{"id":39,"date":"2019-02-16T18:21:00","date_gmt":"2019-02-16T18:21:00","guid":{"rendered":"https:\/\/hostup.org\/blog\/?p=39"},"modified":"2024-08-09T13:41:24","modified_gmt":"2024-08-09T13:41:24","slug":"how-to-install-configure-latest-nginx-mainline-version-on-ubuntu","status":"publish","type":"post","link":"https:\/\/hostup.se\/en\/blog\/how-to-install-configure-latest-nginx-mainline-version-on-ubuntu\/","title":{"rendered":"How to Install &#038; Configure Latest Nginx Mainline Version on Ubuntu 16.04 \/ 18.04"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Why am I writing this tutorial?<\/h2>\n\n\n\n<p>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!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install Nginx<\/h2>\n\n\n\n<p>To install the current version of Nginx, simply follow the documentation on its offical website seen <a href=\"https:\/\/nginx.org\/en\/linux_packages.html#Ubuntu\" target=\"_blank\" rel=\"noopener\">here<\/a> or do the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt install curl gnupg2 ca-certificates lsb-release<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">echo \"deb http:\/\/nginx.org\/packages\/mainline\/ubuntu `lsb_release -cs` nginx\" \\     | sudo tee \/etc\/apt\/sources.list.d\/nginx.list<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -fsSL https:\/\/nginx.org\/keys\/nginx_signing.key | sudo apt-key add - <\/pre>\n\n\n\n<p>Now that we have downloaded &amp; verified its authnicity lets install it!<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt update<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt install nginx<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Useful Commands<\/h2>\n\n\n\n<p>That&#8217;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<br>sudo systemctl enable nginx.service<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl start nginx.service<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl enable nginx.service<\/pre>\n\n\n\n<p>To restart or stop nginx:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl stop nginx.service<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl restart nginx.service<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Setup Your Website<\/h2>\n\n\n\n<p>You should now verify that nginx has started and is correctly installed by visiting it. <strong>Http:\/\/YourServerIp<\/strong>. If everything is correctly setup you should see a website saying that nginx is installed.<\/p>\n\n\n\n<p>Your website configuration is located at<code><strong>\/etc\/nginx\/conf.d\/default.conf<\/strong><\/code><br>Your website HTML files are located at<code><strong>\/usr\/share\/nginx\/html<\/strong><\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Now what?<\/h3>\n\n\n\n<p>Well now you can upload your own files or install wordpress as shown <a href=\"https:\/\/hostup.se\/en\/blog\/install-wordpress-on-latest-nginx-mainline-version\/\">here<\/a><\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>Add nginx to www-data group<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo usermod -a -G www-data nginx<\/pre>\n\n\n\n<p>Change owner of directory to www-data<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo chown -R www-data \/usr\/share\/nginx\/html<\/pre>\n\n\n\n<p>If you don&#8217;t already have a VPS, or want to reward us for hard work and ad free experience you can buy a <a href=\"https:\/\/hostup.se\/en\/vps\/\">VPS<\/a> from us. We would really appreciate it as we don&#8217;t have any donation buttons and this is our only source of income. Our VPSes are located in Stockholm, and we even have a <a href=\"https:\/\/hostup.se\/vps\/\">Swedish branded site <\/a>if you&#8217;re from Sweden.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":156,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-39","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/posts\/39","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/comments?post=39"}],"version-history":[{"count":4,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/posts\/39\/revisions"}],"predecessor-version":[{"id":426,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/posts\/39\/revisions\/426"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/media\/156"}],"wp:attachment":[{"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/media?parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/categories?post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostup.se\/en\/blog\/wp-json\/wp\/v2\/tags?post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}