Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install, start, restart, and shut down Nginx on MAC

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to install, start, restart and shut down Nginx on MAC. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

I. installation

Execute the following command

Brew search nginxbrew install nginx

After installation, you can see some configuration paths in the terminal output:

/ usr/local/etc/nginx/nginx.conf (profile path) / usr/local/var/www (server default path) / usr/local/Cellar/nginx/1.8.0 (installation path)

If it is a system above macOS 1.12, "warning" may appear during the installation process, saying that this version of the operating system is not supported, so you can ignore it for the time being.

2. Start

Enter in the terminal

Ps-ef | grep nginx

If the result of the execution is

501 15800 10 12:17 nginx: master process / usr/local/Cellar/nginx/1.8.0/bin/nginx-c / usr/local/etc/nginx/nginx.conf 501 15801 15800 0 12:17 nginx: worker process 501 15848 15716 0 12:21 morning ttys000 00.00 grep nginx

Indicates that it has been started successfully. If it is not the result of the above figure, execute it in the terminal.

/ usr/local/Cellar/nginx/1.8.0/bin/nginx-c / usr/local/etc/nginx/nginx.conf

Command to start nginx.

If you successfully access localhost:8080 at this time, it means that you have successfully installed and started.

3. Stop

Enter ps-ef in the terminal | grep nginx gets the process number of nginx. Note that the process number of "nginx:master" is found. For example, the following process is 15800.

501 15800 10 12:17 nginx: master process / usr/local/Cellar/nginx/1.8.0/bin/nginx-c / usr/local/etc/nginx/nginx.conf 501 15801 15800 0 12:17 nginx: worker process 501 15848 15716 0 12:21 morning ttys000 00.00 grep nginx

You can stop by entering the following commands in the terminal

Kill-QUIT 15800 (stop calmly, that is, not immediately) Kill-TERM 15800 (stop immediately) Kill-INT 15800 (as above, also stop immediately) 4. Restart

If the configuration file is incorrect, the startup will fail, so before starting nginx, you need to verify the correctness of the configuration file. The following indicates that the configuration file is correct

Promote:bin yangqianhua$ / usr/local/Cellar/nginx/1.8.0/bin/nginx-t-c / usr/local/etc/nginx/nginx.confnginx: the configuration file / usr/local/etc/nginx/nginx.conf syntax is oknginx: configuration file / usr/local/etc/nginx/nginx.conf test is successful

There are two ways to restart

1) enter the following command at the terminal to restart

Promote:~ yangqianhua$ cd / usr/local/Cellar/nginx/1.8.0/bin/promote:bin yangqianhua$. / nginx-s reloadpromote:bin yangqianhua$

2) restart according to the process number, execute the command kill-HUP process number

This is the end of the article on "how to install, start, restart and shut down Nginx on MAC". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report