The previous period of contact with the proxy server, in the groping under the installation of Nginx environment, next to introduce you on the MAC installed Nginx environment basic steps.
- This article is to use homebrew to install Nginx, first open the Terminal Input installation command line
Ruby-e "$ (curl-fssl https://raw.githubusercontent.com/Homebrew/install/master/install)"
To install the homebrew. Official website: http://brew.sh/.
If the following prompt appears, the MAC is installed Nginx or the last installation Nginx failed to leave a residue
It appears Homebrew is already installed. If your intent is to reinstall Youshould does the following before running this installer again: Rm-rf/usr/local/cella R/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.
- After download homebrew will automatically install homebrew, with brew one click Install Nginx
Brew Install Nginx
- Test Nginx after installation to work properly
NGINX-T correct hint: nginx:the configuration file/usr/local/etc/nginx/nginx.conf syntax is OK nginx:configuration file/us R/local/etc/nginx/nginx.conf Test is successful
- If you have insufficient prompt permission, you need to open the permissions of the file under Nginx
chmod 777 Filefile for file paths that require open access
- Nginx can work properly, first 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/(the file path to deploy the application); index index.html index.htm; }
- After the configuration file has changed, start Nginx
sudo nginx
- Basic usage of Nginx
Nginx-s Reload #重新加载配置nginx-S reopen #重启nginx-S Stop #停止nginx-s quit #退出
Options: -?,-H : Open Help message -V: Displays version information and exits -V: Displays version and configuration options information, and then exits- t : Detects if a configuration file has a syntax error and then exits -Q: Masking non-error messages during configuration file- s signal : Sends a signal to an nginx main process: Stop (stop), quit (quit), reopen (restart), Reload (reload config file)- p prefix : Set prefix path (default is:/usr/local/cellar/nginx/1.2.6/)- c filename : Set configuration file (default:/usr/local/etc/nginx/nginx.conf) -G directives : set global directives outside the configuration file
The above describes the server Mac installation Nginx environment, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.