Saturday, December 3, 2016

Installing Nginx in MAC OS


You can easily install Nginx with Homebrew and visit the site through http://brew.sh/

Installation

  • Install brew.
          Command: /usr/bin/ruby -e "$(curl -fsSL             
                              https://raw.githubusercontent.com/Homebrew/install/master/install)"

          you can take the command from the brew site and past it in the terminal.
  • Then give the brew command.
           Command :brew
  • Update The brew.    
          Command :brew update  
  • Install the Nginx with brew.
           Command :brew install nginx
  • After install the Nginx run it by
           Command :sudo nginx

Testing

       Test the Nginx by going through the http://localhost:8080
     

Configuration

       Default place of nginx.conf is on Mac after install with the brew is
     
       /usr/local/etc/nginx/nginx.conf


       You can change the default 8080 to 80. First you need to stop the server, if its already running.
     
        sudo nginx -s stop
     
        vim /usr/local/etc/nginx/nginx.conf

        From:
     
        server {
        listen       8080;
        server_name  localhost;

         #access_log  logs/host.access.log  main;

         location / {
         root   html;
         index  index.html index.htm;
        }
     
       To:
        server {
        listen       80;
        server_name  localhost;

        #access_log  logs/host.access.log  main;

        location / {
        root   html;
        index  index.html index.htm;
       }


No comments:

Post a Comment