如何在CentOS下安装Nginx

1.PCRE库依赖库,解压并安装【可选】
1
2
3
4
5
6
7
8
9
10
11
12
13

# 这里使用了镜像库加速
wget https://kkgithub.com/PCRE2Project/pcre2/releases/download/pcre2-10.44/pcre2-10.44.tar.gz

tar -zxvf pcre2-10.44.tar.gz

cd pcre2-10.44/

./configure --prefix=/usr/local/pcre

make && make install

pcre2-config --version
2. OpenSSL依赖库,解压并安装【可选】
1
2
3
4
5
6
7
8
9
10
11
12
13
14

wget https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz

tar -zxvf openssl-1.1.1w.tar.gz

cd openssl-1.1.1w/

./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl shared zlib

perl configdata.pm --dump

make && make install

openssl version
3. 下载并安装Nginx官方的 Yum Repository
1
wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.26.1-2.el7.ngx.x86_64.rpm
4. 安装‌
1
rpm -ivh nginx-1.26.1-2.el7.ngx.x86_64.rpm
5. 启动
1
systemctl start nginx
5. 启动
1
systemctl start nginx
6. 设置开机自启动
1
systemctl enable nginx