Article directory
Linux——centos7 version
Installation environment configuration
-
Nginx is written in C language, so you need to configure the C language compilation environment (to be connected to the Internet)
-
Install the gcc environment
[root@a ~]# yum install gcc-c++ 已加载插件:fastestmirror, langpacks Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com base
-
Solve the problems that occur when installing the gcc environment:
Another app is currently holding the yum locak......
the above problems occur because yum is in a locked state, and it is enough to force the yum process to be shut downrm -f /var/run/yum.pid
Installing Nginx requires installing a third-party development package
Installing Nginx requires installing third-party development packages, which are required before compiling
-
PCRE : The http module in nginx uses pcre to parse regular expressions, so the pcre library needs to be installed on linux
[root@a ~]# yum install -y pcre pcre-devel 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com
-
zlib : nginx uses zlib to gzio the contents of the http package, so this package needs to be installed
[root@a ~]# yum install -y zlib zlib-devel 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com
-
openssl : openssl is a powerful secure socket layer cipher library, nginx not only supports http protocol, but also supports https, so you need to install openssl library on linux
[root@a ~]# yum install -y openssl openssl-devel 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com
Install Nginx
-
Upload the Nginx source package to Linux
-
Unzip Nginx:
[root@a ~]# tar -xvf nginx-1.14.2.tar.gz
-
Create a temporary directory
mkdir /var/temp/nginx/client -p
-
Execute the command configure to generate a Mikefile file
./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
-
Execute the make command to compile:
make
-
Install Nginx:
make install
Start and access Nginx
-
Go to the nginx installation directory:
[root@a nginx-1.14.2]# cd /usr/local/nginx/ [root@a nginx]# ll 总用量 4 drwxr-xr-x. 2 root root 4096 10月 20 10:50 conf drwxr-xr-x. 2 root root 40 10月 20 08:02 html drwxr-xr-x. 2 root root 6 10月 20 14:57 logs drwxr-xr-x. 2 root root 36 11月 25 02:44 sbin [root@a nginx]#
-
Go to the sbin directory and execute the nginx command
[root@a nginx]# cd sbin/ [root@a sbin]# ll 总用量 7472 -rwxr-xr-x. 1 root root 3778520 11月 25 02:44 nginx -rwxr-xr-x. 1 root root 3870512 10月 20 08:02 nginx.old [root@a sbin]#
./nginx 启动 ./nginx -s stop 关闭 ./nginx -s reload 重启 ps aux | grep nginx 查看进程
Installed
- Open your client ip address, the following interface appears to indicate that the installation is complete