{"id":523,"date":"2016-11-13T23:56:31","date_gmt":"2016-11-13T15:56:31","guid":{"rendered":"https:\/\/www.techcoil.com\/blog\/?p=523"},"modified":"2018-09-05T00:13:16","modified_gmt":"2018-09-04T16:13:16","slug":"setting-up-nginx-server-on-windows-10","status":"publish","type":"post","link":"https:\/\/www.techcoil.com\/blog\/setting-up-nginx-server-on-windows-10\/","title":{"rendered":"Setting up Nginx server on Windows 10"},"content":{"rendered":"<p>Recently, I got my wife an <a target=\"_blank\" href=\"https:\/\/www.amazon.com\/s\/ref=as_li_ss_tl?url=search-alias=electronics&field-keywords=Asus+ROG+GL552VW+gaming+laptop&rh=n:172282,k:Asus+ROG+GL552VW+gaming+laptop&linkCode=ll2&tag=clivsperswebs-20&linkId=7089a979a1724e2de716199c4f2b46eb&language=en_US\">Asus ROG 15-Inch Gaming laptop<\/a> as a development machine (so that I can have a machine to use when I feel like gaming). Since the <a href=\"http:\/\/nginx.org\/\">Nginx server<\/a> is one of my favorite servers for building web applications, it is something that I will always setup first when I get a new development machine. <\/p>\n<p>I will set up my Nginx server to listen on port 80 and serve as a reverse proxy to web applications listening on other port numbers. And since the <a target=\"_blank\" href=\"https:\/\/www.amazon.com\/gp\/product\/B015ZG997I\/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B015ZG997I&linkCode=as2&tag=clivsperswebs-20&linkId=406a44925a096eb61127d7cc4c1f2dd1\">ROG GL552VW-DH74 15-Inch Gaming laptop<\/a> came with Windows 10, this post documents the steps that I went through to set up Nginx server on Windows 10.<\/p>\n<h2>Downloading a copy of Nginx<\/h2>\n<p>The first thing that I did was to download a copy of Nginx for Windows. To do so, I go to the <a href=\"http:\/\/nginx.org\/en\/download.html\" target=\"_blank\">Nginx download page<\/a> and click on the link labelled as <strong>nginx\/WindowsXXX<\/strong> located under the section named <strong>Stable version<\/strong>. As of this writing, I downloaded <a href=\"http:\/\/nginx.org\/download\/nginx-1.10.2.zip\" title=\"Link to download nginx\/Windows-1.10.2 \">nginx\/Windows-1.10.2<\/a> and unzipped the contents to <code>D:\\servers<\/code>. This will create the folder <code>D:\\servers\\nginx-1.10.2<\/code> which contains everything that is needed for me to run Nginx on Windows 10.<\/p>\n<h2>Starting Nginx for the first time<\/h2>\n<p>To test whether the copy of Nginx that I had downloaded is working, I opened up command prompt and typed the following commands:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncd \/d D:\\servers\\nginx-1.10.2\r\nnginx\r\n<\/pre>\n<p>Running the above commands triggered the following dialog box:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/windows-security-alert-after-starting-nginx-for-the-first-time.jpg\" alt=\"Windows Security Alert after starting Nginx for the first time\"\/><\/p>\n<p>I clicked on the <strong>Allow Access<\/strong> button to get my Windows 10 firewall to associate port 80 to my Nginx server. I then opened up my browser and type <strong>localhost<\/strong> in the location bar and saw the following message:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/nginx-welcome-page-on-chrome-windows-10.jpg\" alt=\"Nginx welcome page on Chrome Windows 10\" width=\"640px\"\/> <\/p>\n<h2>Stopping Nginx server<\/h2>\n<p>Once I had ensured that my Nginx server is able to run in my Windows 10 machine, I opened up another command prompt and typed the following commands to stop the Nginx server:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncd \/d D:\\servers\\nginx-1.10.2\r\nnginx -s stop\r\n<\/pre>\n<h2>Setting up Nginx server to start automatically when Windows 10 starts<\/h2>\n<p>Having to open up the command prompt to start Nginx every time I do my development work is cumbersome. Hence, I proceeded to set up my Nginx server to start automatically whenever my Windows 10 starts. Since the Nginx binary is not a windows service executable, I set it up to start automatically via the common Startup folder.<\/p>\n<p>To do so, I created a shortcut of the <code>nginx.exe<\/code> binary and copied it to <code>C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp<\/code>. This will ensure that my Nginx server starts automatically whenever I log into my Windows 10 machine.<\/p>\n<h2>Restarting Nginx server<\/h2>\n<p>To restart my Nginx server on my Windows 10, I open up my Windows prompt and type the following commands:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncd \/d D:\\servers\\nginx-1.10.2\r\nnginx -s stop\r\nnginx \r\n<\/pre>\n<p>For convenience, I created a <code>.bat<\/code> file that contains the above commands on the desktop so that I can quickly restart my Nginx server when I need to do so in the future.<\/p>\n\n      <ul id=\"social-sharing-buttons-list\">\n        <li class=\"facebook\">\n          <a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fwp.me%2Fp245TQ-8r\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n            <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Facebook.png\" alt=\"Facebook icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"twitter\">\n          <a href=\"https:\/\/twitter.com\/intent\/tweet?text=&url=https%3A%2F%2Fwp.me%2Fp245TQ-8r&via=Techcoil_com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Twitter.png\" alt=\"Twitter icon\"> Tweet\n          <\/a>\n        <\/li>\n        <li class=\"linkedin\">\n          <a href=\"https:\/\/www.linkedin.com\/shareArticle?mini=1&title=&url=https%3A%2F%2Fwp.me%2Fp245TQ-8r&source=https:\/\/www.techcoil.com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/linkedin.png\" alt=\"Linkedin icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"pinterest\">\n          <a href=\"https:\/\/pinterest.com\/pin\/create\/button\/?url=https%3A%2F%2Fwww.techcoil.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F523&description=\" class=\"pin-it-button\" target=\"_blank\" role=\"button\" rel=\"nofollow\" count-layout=\"horizontal\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Pinterest.png\" alt=\"Pinterest icon\"> Save\n          <\/a>\n        <\/li>\n      <\/ul>\n    ","protected":false},"excerpt":{"rendered":"<p>Recently, I got my wife an <a target=\"_blank\" href=\"https:\/\/www.amazon.com\/gp\/product\/B015ZG997I\/ref=as_li_tl?ie=UTF8&#038;camp=1789&#038;creative=9325&#038;creativeASIN=B015ZG997I&#038;linkCode=as2&#038;tag=clivsperswebs-20&#038;linkId=406a44925a096eb61127d7cc4c1f2dd1\">Asus ROG GL552VW-DH74 15-Inch Gaming laptop<\/a> as a development machine (so that I can have a machine to use when I feel like gaming). Since the <a href=\"http:\/\/nginx.org\/\">nginx server<\/a> is one of my favorite servers for building web applications, it is something that I will always setup first when I get a new development machine. <\/p>\n<p>I will set up my nginx server to listen on port 80 and serve as a reverse proxy to web applications listening on other port numbers. And since the <a target=\"_blank\" href=\"https:\/\/www.amazon.com\/gp\/product\/B015ZG997I\/ref=as_li_tl?ie=UTF8&#038;camp=1789&#038;creative=9325&#038;creativeASIN=B015ZG997I&#038;linkCode=as2&#038;tag=clivsperswebs-20&#038;linkId=406a44925a096eb61127d7cc4c1f2dd1\">ROG GL552VW-DH74 15-Inch Gaming laptop<\/a> came with Windows 10, this post documents the steps that I went through to set up nginx server on Windows 10.<\/p>\n","protected":false},"author":1,"featured_media":1240,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"footnotes":""},"categories":[4],"tags":[225,195,347],"jetpack_featured_media_url":"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/Nginx-Logo.jpg","jetpack_shortlink":"https:\/\/wp.me\/p245TQ-8r","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/523"}],"collection":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/comments?post=523"}],"version-history":[{"count":0,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/523\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media\/1240"}],"wp:attachment":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media?parent=523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/categories?post=523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/tags?post=523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}