Install and configure Nginx under MacOS

17100844:

1. Install brew

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

After pressing Enter, follow the prompts: Enter the image serial number --> Enter Y, press Enter and wait for the brew installation to complete.

After entering brew -v in the terminal, you will be prompted to execute two configuration commands. Just copy and execute them and it will be OK!

git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask
Homebrew/homebrew-cask

git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
Homebrew/homebrew-core

2. Install Nginx

brew install

Nginx server default path: /opt/homebrew/var/www

Configuration file path:/opt/homebrew/etc/nginx/nginx.conf

Installation path:/opt/homebrew/opt/nginx

Start nginx: sudo nginx

Shut down nginx: sudo nginx -s stop

Reload: sudo nginx -s reload

3. Attention

1. Whether the startup is successful

Enter in the terminal

ps -ef|grep nginx

If the execution result isimage-20230509214943665

Indicates successful startup

2. Stop

Shut down nginx: sudo nginx -s stop

If the above doesn't work

ps -ef|grep nginx Enter the process number of nginx in the terminal . Note that it is nginx:masterthe process number where " " is found.

image-20230509214943665
kill -QUIT 26781 (从容的停止,即不会立刻停止)
Kill -TERM 26781 (立刻停止)
Kill -INT 26781 (和上面一样,也是立刻停止)

3. Restart

Reload: sudo nginx -s reload

If the above doesn't work, use step 2 to kill the process first and then start it again.

4. Uninstall brew and common commands

2. brew uninstall script

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"

3. Commonly used commands

Install software: brew install xxx
Uninstall software: brew uninstall xxx
Search software: brew search xxx
Update software: brew upgrade xxx
View list: brew list
Update brew: brew update
Clean old versions of all packages: brew cleanup
Clean old versions of specified packages: brew cleanup $FORMULA
View old versions of packages that can be cleaned, without performing actual operations:brew cleanup -n

  • Uninstall nodejs under MacOS: https://pythonjishu.com/rktpzdtbkn/

Guess you like

Origin blog.csdn.net/weixin_45864704/article/details/130589841