Install nginx on the mac Server

Source: Internet
Author: User
Tags install homebrew
: This article describes how to install the nginx environment on the mac server. if you are interested in the PHP Tutorial, refer to it. Some time ago, I came into contact with the proxy server and tried to build the nginx environment. next I will introduce you to the basic steps for installing the nginx environment on mac.

  1. This article uses homebrew to install nginx. first open the terminal and enter the installation command line.
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    To install homebrew. Official website: http://brew.sh /.
    If the following prompt appears, it indicates that nginx has been installed on mac or that the last installation of nginx has left a residue.
    It appears Homebrew is already installed. If your intent is to reinstall youshould do the following before running this installer again:    rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
    Follow the prompts to enter the Delete command line:
    rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
    After deletion, enter the installation command line.
  2. Homebrew is automatically installed after homebrew is downloaded, and nginx is installed with brew with one click.
    brew install nginx
  3. Check whether nginx works properly after installation
    Nginx-t: nginx: the configuration file/usr/local/etc/nginx. conf syntax is OK nginx: configuration file/usr/local/etc/nginx. conf test is successful
  4. If you are prompted that the permission is insufficient, you need to open the file permission under nginx
    Chmod 777 filefile is the file path that requires open permissions
  5. After nginx works properly, change the nginx configuration file.
    vim /usr/local/etc/nginx/nginx.conf
    Server {listen 9999 (custom port number); server_name localhost; # charset KOI8-R; # access_log logs/host. access. log main; location/{root/Users/loki/Desktop/web/(file path for deploying the application); index index.html index.htm ;}
  6. After the configuration file is changed, start nginx
    sudo nginx
  7. Basic nginx usage
    Nginx-s reload # reload and Configure nginx-s reopen # restart nginx-s stop # stop nginx-s quit # exit
    Option :-?, -H: turn on the help information-v: Display the version information and exit-V: Display the version and configuration option information, and then exit-t: Check whether the configuration file has a syntax error, then exit-q: During the detection of the configuration file, shield the non-error message-s signal: send a signal to an nginx master process: stop, quit ), reopen (restart), reload (reload configuration file)-p prefix: Set the prefix path (default:/usr/local/Cellar/nginx/1.2.6/)-c filename: set the configuration file (default:/usr/local/etc/nginx. conf)-g directives: sets global commands outside the configuration file.

The above describes how to install the nginx environment on the server mac, including some content, and hope to be helpful to anyone interested in the PHP Tutorial.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.