Ubuntu16.04.1 method of installing Nginx
- 2020-05-12 06:55:51
- OfStack
Nginx ("engine x") is a high performance HTTP and reverse proxy server as well as an IMAP/POP3/SMTP proxy server. Nginx was developed by Igor Sysoev, the second most visited Rambler.ru site in Russia. The first public version 0.1.0 was released on October 4, 2004. It distributes its source code as an BSD license and is known for its stability, rich feature set, sample configuration files, and low system resource consumption.
Install the Nginx dependent library
Install the gcc g++ dependency library
The ubuntu platform can be used with the following command.
apt-get install build-essential
apt-get install libtool
The centeros platform can be used with the following command.
The centos platform builds the environment using the following instructions
Install make:
yum -y install gcc automake autoconf libtool make
Install g + + :
yum install gcc gcc-c++
Install pcre dependent libraries (http: / / www. pcre. org /)
sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev
Install zlib dependent libraries (http: / / www. zlib. net)
apt-get install zlib1g-dev
Install the ssl dependent library
apt-get install openssl
Install Nginx (http:// nginx.org)
# Download the latest version:
wget http://nginx.org/download/nginx-1.11.3.tar.gz
# Extract:
tar -zxvf nginx-1.11.3.tar.gz
# Enter unzip directory:
cd nginx-1.11.3
# Configuration:
./configure --prefix=/usr/local/nginx
# The editor nginx :
make
Note: an error may be reported here." pcre.h No such file or directory " , See details: http://stackoverflow.com/questions/22555561/error-building-fatal-error-pcre-h-no-such-file-or-directory
You need to install libpcre3-dev, Command as follows: sudo apt-get install libpcre3-dev
# The installation nginx :
sudo make install
# Start the nginx :
sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
Note: -c Specify the path to the configuration file, if not, nginx Will automatically load the default path of the configuration file, can be through -h See the help command.
# To view nginx Process:
ps -ef|grep nginx
Nginx common commands
Start the Nginx
/usr/local/nginx/sbin/nginx
./sbin/nginx
Stop Nginx
./sbin/nginx -s stop
./sbin/nginx -s quit
-s is used to send signals to Nginx.
Nginx reloads the configuration
./sbin/nginx -s reload
Specify configuration files
yum -y install gcc automake autoconf libtool make
0
-c represents configuration, specifying the configuration file
See the Nginx version
There are two types of parameters for viewing version information for Nginx. The first is as follows:
yum -y install gcc automake autoconf libtool make
1
The other one shows detailed version information:
yum -y install gcc automake autoconf libtool make
2
Check that the configuration file is correct
poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -t
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
2012/01/09 16:45:09 [emerg] 23898#0: open() "/usr/local/nginx/logs/nginx.pid" failed (13: Permission denied)
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
If the above prompt message appears, indicating that the error log file and process are not accessed, sudo (super user do) 1 can be used:
yum -y install gcc automake autoconf libtool make
4
If displayed as above, the configuration file is correct. Otherwise, there will be relevant hints.
Show help
yum -y install gcc automake autoconf libtool make
5
Or:
yum -y install gcc automake autoconf libtool make
6