Nginx is developed in C language and is recommended to run on Linux. Of course, you can also install the Windows version. Install Dependencies yum install gcc yum install pcre-devel yum install zlib zlib-devel yum install openssl openssl-devel When installing these 4 dependencies, there will be some questions in the middle, just enter Y Download the nginx tarball //Enter the /usr/local directory cd /usr/local //Create a folder nginx mkdir nginx //Enter the nginx folder cd nginx //Download the tarball wget http://nginx.org/download/nginx-1.13.7.tar.gz //Unzip the tar package tar -xvf nginx-1.13.7.tar.g Install nginx //Enter the nginx directory cd /usr/local/nginx //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 executing the command, there is no response in the console. Visit the address of the nginx server you installed in the browser, and you can see the nginx welcome interface. At this point, nginx is installed. Start nginx Because apeache may occupy port 80, try not to modify the apeache port. We choose to modify the nginx port. In Linux, modify the path /usr/local/nginx/conf/nginx.conf. In Windows, modify the installation directory\conf\nginx.conf. Change the port to 8090 and localhost to your server IP address. (Success is just around the corner!!) Start nginx netstat -ano|grep 80 If no execution results are found, ignore the previous step (Ubuntu must be started with sudo, otherwise it can only run in the foreground) nginx restart, shutdown, and startup start up 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 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 Force Stop [root@LinuxServer ~]# pkill -9 nginx Restart 1. Verify whether the nginx configuration file is correct Method 1: Enter the nginx installation directory sbin and enter the command ./nginx -t The following shows that nginx.conf syntax is ok nginx.conf test is successful This indicates that the configuration file is correct! Method 2: Add -t before the startup command -c 2. Restart 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 general meaning is: 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 to check the port occupancy. netstat -ntpl As you can see, port 80 is occupied by nginx. At this time, execute kill -9 5347 (5347 is the PID of this process as shown in the above figure) to kill the process, and then start nginx again. If you purchased an Alibaba Cloud server and there is no error when starting nginx, but the nginx welcome interface still does not appear when accessing nginx, please read: https://www.jb51.net/article/159514.htm , you need to set port 80 in the Alibaba Cloud security level group. If you still cannot start nginx, you can only search Baidu based on the error message and deal with the specific problem specifically. 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:
|
<<: MySQL uninstall and install graphic tutorial under Linux
>>: jQuery plugin to implement minesweeper game (2)
This article example shares the specific code of ...
It mainly shows how to configure X-Frame-Options,...
Image Accelerator Sometimes it is difficult to pu...
Table of contents Overview From Binary Tree to B+...
Table of contents Preface Find the problem solve ...
Table of contents background What is the Metavers...
This article shares the specific code of JS to ac...
Table of contents 1. Sub-route syntax 2. Examples...
Table of contents Business scenario: Effect demon...
Phrase elements such as <em></em> can ...
Table of contents 2. Comma operator 3. JavaScript...
The temperament of a web front-end website is a fe...
Preface As Linux operation and maintenance engine...
Table of contents Creating Arrays in JavaScript U...
Unicode is a character encoding scheme developed ...