1. Installation and operation of nginx (Mac OS environment)1. Install nginx Can be installed directly via Homebrew: $brew install nginx After installation, the default homepage file is in the The default configuration file address is Nginx uses port 8080 by default. If you find that the port is occupied (check the port occupancy through 2. Start nginx $brew services start nginx Or go to the directory After successful startup, visit 3. Stop nginx $ nginx -s stop 4. Restart nginx $ nginx -s reload 5. View nginx configuration path information $brew info nginx 2. nginx rule configurationMore configurations can be viewed https://www.nginx.com/resources/wiki/start/#pre-canned-configurations http://nginx.org/en/docs/ http://www.nginx.cn/doc/ 1. location location grammar articles 2. root and alias In nginx, you can specify the access path of resources through root and alias. 1) root: location / { root /usr/local/var/www/; index index.html index.htm; } In the above rule, when the address When requesting the address In other words, the resource address accessed is actually the path specified by root + the path matched by location. 2) alias: alias is an alias, and its matching rules are slightly different from those of root. location /a/ { alias /usr/local/var/www/b/; } In the above rule, when requesting the address When requesting the address In other words, the resource address accessed is the path specified by alias, and has nothing to do with the path matched by location (the path matched by location will be discarded). 3) The difference between root and alias: Alias can only be used in location, while root can exist in server, http and location. The alias must be followed by a “/”, otherwise the file will not be found, while the “/” is optional for root. 3. try_file location /test/ { try_files $uri $uri/ /a/1.png; } try_files tries to read the files accessed by the user from the website directory. If the first variable exists, it returns directly; if it does not exist, it continues to read the second variable. If it exists, it returns directly; if it does not exist, it jumps to the third parameter. $uri is an nginx variable that stores the address accessed by the user. For example, when visiting http://www.xxx.com/index.html, \$uri is /index.html. $uri/ represents a directory being accessed, for example: http://www.xxx.com/hello/test/, then \$uri/ is /hello/test/. For example, in the above rule: when requesting the address More usage: https://www.jb51.net/article/156899.htm 4. rewrite rewrite syntax The rewrite function is to implement URL rewriting and redirection. Syntaxrewrite rewrite can only be placed in The execution order of rewrite is:
flag flag:
location /home/ { rewrite ^/home/test/ http://www.baidu.com; } The above rule: when you access the address Some tips: How to redirect url in nginx without changing the url display in the browser? proxy_pass can specify a reverse proxy More usage: https://www.jb51.net/article/134233.htm 3. Some command line configuration (mac OS)1. How to open a file with vscode in the command line cd /usr/local/bin/ ln -s "/Applications/Visual Studio Code.app/Contents/MacOS/Electron" vscode Among them, The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: How to avoid the trap of URL time zone in MySQL
>>: React gets input value and submits 2 methods examples
Today's screen resolutions range from as smal...
In this article, I will show you how to develop a...
As shown below: XML/HTML CodeCopy content to clip...
1. Going around in circles After going around in ...
Slideshows are often seen on web pages. They have...
This article uses an example to describe the erro...
The so-called connection limit in Nginx is actual...
Table of contents Preface Setting up with Vue CLI...
1. Background Netplan is a new command-line netwo...
When deploying uwsgi+nginx proxy Django, access u...
Suddenly, I needed to build a private service for...
Table of contents 1. How to use mixin? 2. Notes o...
Recently, I used vuethink in my project, which in...
Overview I have been using Docker for more than a...
In MySQL database operations, we always hope to a...