: 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.
- 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.
- Homebrew is automatically installed after homebrew is downloaded, and nginx is installed with brew with one click.
brew install nginx
- 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
- 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
- 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 ;}
- After the configuration file is changed, start nginx
sudo nginx
- 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.