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

The realization method of installing nginx under Linux

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Nginx is developed in C language. It is recommended to run on Linux. Of course, you can also install the Windows version.

Installation dependency

Yum install gccyum install pcre-develyum install zlib zlib-develyum install openssl openssl-devel

When installing these four dependencies, there will be some inquiries in the middle, just enter Y

Download the tar package for nginx

/ / enter the / usr/local directory cd / usr/local// to create a folder nginxmkdir nginx// enter the nginx folder cd nginx// download tar package wget http://nginx.org/download/nginx-1.13.7.tar.gz// extract tar package tar-xvf nginx-1.13.7.tar.g

Install nginx

/ / enter the nginx directory cd / usr/local/nginx// to execute the command. / configure// execute the make command make// execute the make install command make install

Start nginx

/ usr/local/nginx/sbin/nginx

Note: this path is based on your own installation path, just change it to your own path.

After the execution of the console without any response, you can access your installed nginx server address in the browser, you can see the nginx welcome interface, and this nginx installation is complete.

Start nginx

Because it is possible that apeache occupies port 80, the apeache port should not be modified as far as possible, so we choose to modify the nginx port.

Linux modify the installation directory\ conf\ nginx.conf under the path / usr/local/nginx/conf/nginx.conf,Windows.

Change the port to 8090 _ localhost and change it to your server ip address. Success is just around the corner! )

Start nginx

Netstat-ano | grep 80

If the execution result is not found, ignore the previous step (under ubuntu, you must start it with sudo, otherwise you can only run it in the foreground)

Nginx restart, shutdown, startup

Start

Startup code format: nginx installation directory address-c nginx configuration file address

For example:

[root@LinuxServer sbin] # / usr/local/nginx/sbin/nginx-c / usr/local/nginx/conf/nginx.conf

Stop it

There are three ways to stop nginx:

Stop calmly

1. Check the process number

[root@LinuxServer ~] # ps-ef | grep nginx

2. Kill the process

[root@LinuxServer ~] # kill-QUIT 2072

Quick stop

1. Check the process number

[root@LinuxServer ~] # ps-ef | grep nginx

2. Kill the process

[root@LinuxServer ~] # kill-TERM 2132 or [root@LinuxServer ~] # kill-INT 2132

Forced stop

[root@LinuxServer] # pkill-9 nginx

Restart

1. Verify that the nginx configuration file is correct

Method 1: enter the nginx installation directory sbin and enter the command. / nginx-t

See the following display of nginx.conf syntax is ok

Nginx.conf test is successful

Indicates that the configuration file is correct!

Method 2: add-t before the startup command-c

2. Restart the Nginx service

Method 1: enter the nginx executable directory sbin and enter the command. / nginx-s reload

Method 2: find the current nginx process number, and then enter the command: kill-HUP process number to restart the nginx service

If you start nginx, the following error is reported:

The port address is already in use. It is very likely that the nginx service process is stuck, resulting in port 80 being occupied. The default port of nginx is 80. Execute the command and query the port occupancy.

Netstat-ntpl

You can see that port 80 is occupied by nginx, and then execute kill-9 5347 (5347 is the PID of this process as can be seen from the figure above) to kill the process. This is enough to start nginx again.

If you purchased an Ali CVM and you started nginx correctly, but you still cannot see the nginx Welcome screen when you visit nginx, please read:

Https://www.jb51.net/article/159514.htm, port 80 needs to be set under the Aliyun security level group.

If still can not start nginx, it can only go according to the error message Baidu, specific issues to deal with.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

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