table of Contents
Nginx install and run
Install Nginx
In Nginx official website to download the corresponding nginx package (recommended Stable [Stable version])
Upload nginx package to the Linux system
Installation depends Environment
Install gcc environment
yum install gcc-c++
Install PCRE library for parsing regular expressions
yum install - y pcre pcre-devel
Install zlib compression and decompression dependence
yum install -y zlib zlib-devel
Installation secure SSL Secure Sockets Layer, HTTP for secure transmission, i.e. https
yum install -y openssl openssl-devel
Nginx unzip the package, after decompression is nginx source, the need to install after compiling
tar -zxvf nginx-1.16.1.tar.gz
Before compiling, first create a temporary directory nginx, if not created, the process will start nginx error
mkdir /var/temp/nginx -p
After the files are decompressed nginx directory, enter the following command is executed, the purpose is to create the makefile
./configure \ --prefix=/usr/local/nginx \ --pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/temp/nginx/client \ --http-proxy-temp-path=/var/temp/nginx/proxy \ --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \ --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \ --http-scgi-temp-path=/var/temp/nginx/scgi
NOTE: \ represents the command line wrap for readability
Configuration command:
command Explanation --prefix Specifies the installation directory nginx –pid-path The point pid nginx –lock-path Lock installation files to prevent malicious tampering or misuse –error-log Error Log –http-log-path http log –with-http_gzip_static_module Enable gzip module, online real-time compression output data stream –http-client-body-temp-path Set temporary directory client requests –http-proxy-temp-path Http proxy set temporary directory –http-fastcgi-temp-path Set temporary directory fastcgi –http-uwsgi-temp-path Uwsgi set temporary directory –http-scgi-temp-path Set temporary directory scgi
make compilation
make
installation
make install
Into the sbin directory to start nginx
./nginx
- stop:
./nginx -s stop
- Reload the configuration:
./nginx -s reload
- stop:
run
Open a browser to access the host ip address to open the nginx default page, shown below would indicate a successful installation:
Precautions
- If the cloud server installation, you need to open the default port nginx: 80
- If you install in a virtual machine, you need to turn off the firewall
- Local win or mac need to turn off the firewall