Home > Backend Development > PHP Tutorial > Install nginx under linux

Install nginx under linux

WBOY
Release: 2016-08-08 09:21:30
Original
1082 people have browsed it

Linux system is Centos 64-bit

Step 1: Download the corresponding version from http://nginx.org/download/ (or wget http://nginx.org/download/nginx-1.5 .9.tar.gz can be downloaded directly with the command on Linux)

Step 2: Unzip tar -zxvf nginx-1.5.9.tar.gz

Step 3: Set the configuration information ./ configure --prefix=/usr/local/nginx, or do not perform this step, directly configure the default configuration

Step 4:

make compile (the process of make is to convert source code files written in various languages ​​into into executable files and various library files)

make install installation (make install is to copy these compiled executable files and library files to the appropriate place)

When configuring information, that is In the third step, an error occurred:

The error is: ./configure: error: the HTTP rewrite module requires the PCRE library.

Install pcre-devel to solve the problem
yum -y install pcre-devel

may also appear:

Error message: ./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl= options.

Solution:

yum -y install openssl openssl-devel

Start and shut down nginx under linux after installation:

Start operation

/usr/nginx/sbin / nginx (/usr/nginx/sbin/nginx -t Check whether the configuration information is correct)

Stop the operation
The stop operation is performed by sending a signal to the nginx process (for what a signal is, please refer to the linux article)
Step 1: Query the nginx main process number
ps -ef | grep nginx
Look for the master process in the process list, and its number is the main process number.
Step 2: Send signal
Stop Nginx gracefully:
kill -QUIT main process number
Stop Nginx quickly:
kill -TERM main process number
Force stop Nginx:
pkill -9 nginx
In addition, if the pid file storage path is configured in nginx.conf, the file will store the Nginx main process number. If not specified, it will be placed in the nginx logs directory. With the pid file, we do not need to query the main process number of Nginx first, but directly send a signal to Nginx. The command is as follows:
kill -Signal type '/usr/nginx/logs/nginx.pid'
Smooth restart
If you change the configuration, you need to restart Nginx. Do you need to close Nginx first and then open it? No, you can send a signal to Nginx to restart smoothly.
Smooth restart command:
kill -HUP Enter the name or process number file path

or use

/usr/nginx/sbin/nginx -s reload

Note, after modifying the configuration file, it is best to check whether the modified configuration file is correct to avoid Nginx errors after restarting that will affect the stable operation of the server. The command to determine whether the Nginx configuration is correct is as follows:
nginx -t -c /usr/nginx/conf/nginx.conf

or

/usr/nginx/sbin/nginx -t

as follows Picture:

The above introduces the installation of nginx under Linux, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template