相关连接:https://nginx.org/download/nginx-1.6.3.tar.gz
https://nginx.org/download/nginx-1.16.1.tar.gz
官网:https://nginx.org/en/download.html
- nginx安装
3.1 安装nginx所需的pcre库,openssl 以及检查
[root@cowboy ~]# rpm -qa |grep openssl
openssl-libs-1.0.2k-19.el7.x86_64
openssl-1.0.2k-19.el7.x86_64
openssl-devel-1.0.2k-19.el7.x86_64
xmlsec1-openssl-1.2.20-7.el7_4.x86_64
[root@cowboy ~]# rpm -qa |grep openssl-devel
openssl-devel-1.0.2k-19.el7.x86_64
[root@cowboy ~]# rpm -q pcre
pcre-8.32-17.el7.x86_64
[root@cowboy ~]# rpm -q pcre-devel
pcre-devel-8.32-17.el7.x86_64
3.2 检查当前的系统环境[root@cowboy ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@cowboy ~]# uname -r
3.10.0-1062.el7.x86_64
[root@cowboy ~]# uname -m
x86_64
3.2 开始安装Nginx
[root@cowboy ~]# mkdir -p /home/cowboy/tools/ 创建下载目录
[root@cowboy ~]# cd /home/cowboy/tools/
[root@cowboy tools]#
[root@cowboy tools]# wget https://nginx.org/download/nginx-1.16.1.tar.gz
[root@cowboy tools]# tar -xzf nginx-1.16.1.tar.gz
[root@cowboy tools]# useradd -s /sbin/nologin/ nginx 创建服务用户
[root@cowboy tools]# cd nginx-1.16.1/ cd到解压后目录下
root@cowboy nginx-1.16.1]# mkdir -p /application/nginx/ 创建安装目录
[root@cowboy nginx-1.16.1]# ./configure --user=nginx --group=nginx --prefix=/application/nginx/ --with-http_stub_status_module --with-http_ssl_module 预编译
[root@cowboy nginx-1.16.1]# echo $?
0
查询是否编译成功
Make
Make install
[root@cowboy nginx-1.16.1]# echo $?
0
查询是否安装成功
[root@cowboy nginx-1.16.1]# /application/nginx/sbin/nginx -t 检查语法
nginx: the configuration file /application/nginx//conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx//conf/nginx.conf test is successful
[root@cowboy nginx-1.16.1]# /application/nginx/sbin/nginx 启动成功
[root@cowboy nginx-1.16.1]# netstat -lntup|grep nginx 查看端口
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 63475/nginx: master
[root@cowboy nginx-1.16.1]# wget 127.0.0.1 检测
--2020-03-20 03:09:22-- http://127.0.0.1/
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 612 [text/html]
Saving to: ‘index.html’
100%[=============================================================>] 612 --.-K/s in 0s
2020-03-20 03:09:22 (45.1 MB/s) - ‘index.html’ saved [612/612]
关闭selinux
[root@cowboy nginx-1.16.1]# getenforce
Enforcing
[root@cowboy nginx-1.16.1]# setenforce 0
[root@cowboy nginx-1.16.1]# getenforce
Permissive
关闭防火墙
[root@cowboy nginx-1.16.1]# systemctl stop firewalld
[root@cowboy nginx-1.16.1]# systemctl status firewalld