Linux version: CentOS 7 64-bit
nginx version: nginx-1.9.5
nginx is a lightweight web server that can be used as a load balancer and web server. The performance of nginx is very good. A single machine can theoretically support 50,000 concurrency
1. Install the libraries required for nginx:
yum install -y gcc gcc-c++ zlib zlib-devel pcre pcre-devel openssl openssl-devel
Analysis:
gcc: gcc compiler
gcc-c++: c++ compiler used to compile nginx http module
zlib, zlib-devel: used to gzip compress the contents of http packages
pcre, pcre-devel: pcre library, required by the rewrite module in nginx
openssl, openssl-devel: used to support HTTP transmission over SSL protocol2, user and user group:
groupadd www #Create www user group
useradd -g www www -s /sbin/nologin #Create www users into the www group, and prohibit www users from logging into the system
mkdir -p /alidata/server/nginx #Create nginx installation directory
cd /alidata/server/source
wget http://nginx.org/download/nginx-1.9.5.tar.gz #Get nginx source code
tar -zxvf nginx-1.9.5.tar.gz #Unzip
cd nginx-1.9.5 #Enter the source directory
./configure –user=www –group=www –prefix=/alidata/server/nginx –with->http_stub_status_module
–with-http_ssl_module –with-pcre
Use ./configure –help to check what compilation options are available. The nginx module must be added during compilation and cannot be added dynamically
If it displays like this after executing the above, it is successful. Then execute the following command to complete the installation:
make && make install #Compile and install
Now nginx is installed.
Start ngin: (Make sure no other program in Linux occupies port 80)
cd /alidata/server/nginx #Enter the installation directory
./sbin/nginx #Start
If no error is reported, it means the startup is successful,
Enter the IP address of Linux in the browser, mine is: http://192.168.186.130. If the following information is displayed, it means the installation is successful.
Attached are some learning materials for nginx: http://yun.baidu.com/share/link?shareid=309794494&uk=3156731279
The above has introduced the second part of the Linux server setup - installing the web server Nginx from the source code, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.