安装Nginx

1、登录Linux系统

2、安装make

yum -y install gcc automake autoconf libtool make

3、安装g++:

yum install gcc gcc-c++

4、选定源码目录

可以是任何目录,本文选定的是/home/ebiz/other/nginx

0

5、https://ftp.pcre.org/pub/pcre/ 下载最新的 PCRE 源码包,使用下面命令下载编译和安装 PCRE 包:(wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz)

解决非root用户安装软件中cannot create regular file `/usr/local/lib/libz.a‘: Permission denied_install: cannot create regular file '/usr/local/li_小八四爱吃甜食的博客-CSDN博客

由于无法写入/usr/local/lib,首先自定义编译的输出目录为/***/usr/

$./configure --prefix=/***/usr/ 
 

分别执行如下命令

2

3

4

5

6

7

cd /home/ebiz/other/nginx

wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz

tar -zxvf pcre-8.44.tar.gz

cd pcre-8.44

./configure

make

make install

如果(wget https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz)无法访问,可以先将pcre-8.44.tar.gz 在

Download pcre-8.44.tar.gz (PCRE))地址中下载下来上传到服务器目录下。

配置(configure)、编译(make)、安装(make install)。

6、输入下方指令验证pcre是否安装成功,看到pcre的版本,说明已安装,否则未安装

rpm -qa pcre

7.安装zlib库 (可不装)

http://zlib.net/zlib-1.3.tar.gz 下载最新的 zlib 源码包,使用下面命令下载编译和安装 zlib包:

分别执行如下命令

3

4

5

6

7

8

cd /home/ebiz/other/nginx

wget http://zlib.net/zlib-1.3.tar.gz

tar -zxvf zlib-1.3.tar.gz

cd zlib-1.2.11

./configure

make

make install

如果(wget http://zlib.net/zlib-1.3.tar.gz )报404错误,访问( http://zlib.net/)查看最新的zlib版本并更改获取地址。

8、验证zlib安装是否成功

9、安装ssl(某些vps默认没装ssl)

1

2

3

cd /home/ebiz/other/nginx

wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz

tar -zxvf openssl-1.1.1g.tar.gz

# ./config --prefix=/usr/local/openssl
# make
# make install

yum install -y openssl openssl-devel

如果报错 cannot verify www.openssl.org's certificate, issued by ‘/C=US/O=Let's Encrypt/CN=R3’:
  Issued certificate has expired.

wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1g.tar.gz

//todo 安装命令

10.安装nginx

Nginx 一般有两个版本,分别是稳定版和开发版,您可以根据您的目的来选择这两个版本的其中一个,下面是把 Nginx 安装到 /usr/local/nginx 目录下的详细步骤:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

cd /home/ebiz/other/nginx

wget http://nginx.org/download/nginx-1.18.0.tar.gz

tar -zxvf nginx-1.18.0.tar.gz

cd nginx-1.18.0

./configure --sbin-path=/usr/local/nginx/nginx \

--conf-path=/usr/local/nginx/nginx.conf \

--pid-path=/usr/local/nginx/nginx.pid \

--with-http_gzip_static_module \

--with-http_stub_status_module \

--with-file-aio \

--with-http_realip_module \

--with-http_ssl_module \

--with-pcre=/home/ebiz/other/nginx/pcre-8.44 \

--with-zlib=/home/ebiz/other/nginx/zlib-1.3 \

--with-openssl=/home/ebiz/other/nginx/openssl-1.1.1g

make -j2

make install

--with-pcre=/home/ebiz/other/nginx/pcre-8.44 指的是pcre-8.44 的源码路径。

--with-zlib=/home/ebiz/other/nginx/zlib-1.2.11指的是zlib-1.2.11 的源码路径。

安装成功后 /usr/local/nginx 目录下如下

1

2

3

4

5

6

fastcgi.conf            koi-win             nginx.conf.default

fastcgi.conf.default    logs                scgi_params

fastcgi_params          mime.types          scgi_params.default

fastcgi_params.default  mime.types.default  uwsgi_params

html                    nginx               uwsgi_params.default

koi-utf                 nginx.conf          win-utf

11、参考如何在Nginx或Tengine服务器安装SSL证书_数字证书管理服务-阿里云帮助中心 (aliyun.com)

nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory),logs目录下缺少pid文件。

解决方法:使用指定nginx.conf文件的方式重启nginx

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

再次使用./nginx -s reload等命令就正常了

访问图片

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值