阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Linux安装Nginx详细步骤

278次阅读
没有评论

共计 1518 个字符,预计需要花费 4 分钟才能阅读完成。

1、创建两台虚拟机,分别为主机和从机,区别两台虚拟机的 IP 地址

2、将 Nginx 素材内容上传到 /usr/local 目录(pcre,zlib,openssl,nginx)

Linux 安装 Nginx 详细步骤

3、安装 pcre 库

3.1 cd 到 /usr/local 目录

Linux 安装 Nginx 详细步骤

3.2 tar -zxvf pcre-8.36.tar.gz 解压

Linux 安装 Nginx 详细步骤

Linux 安装 Nginx 详细步骤

3.3 cd pcre-8.36 目录

3.4 执行./configure 编译 ( 如果编译没有报错直接省略 3.5 与 3.6 步骤)

如果报错 configure: error: no acceptable C compiler found in $PATH

Linux 安装 Nginx 详细步骤

3.5 安装 gcc 库:yum install -y gcc gcc-c++

如果发现进程被占用:kiil -9 PID 然后再次执行 yum 安装 gcc 即可

Linux 安装 Nginx 详细步骤

3.6 安装完 gcc 再次 ./configure 编译

Linux 安装 Nginx 详细步骤

3.7 make 编译

   Linux 安装 Nginx 详细步骤

3.8 make install 安装

Linux 安装 Nginx 详细步骤

3.9 pcre 库安装完毕

4、安装 zlib 库

4.1 cd 到 /usr/local 目录

Linux 安装 Nginx 详细步骤

4.2 tar -zxvf zlib-1.2.8.tar.gz 解压

Linux 安装 Nginx 详细步骤

    Linux 安装 Nginx 详细步骤

4.3 cd zlib-1.2.8 目录

4.4 执行./configure 编译

Linux 安装 Nginx 详细步骤

4.5 make 编译

  Linux 安装 Nginx 详细步骤

4.6 make install 安装

  Linux 安装 Nginx 详细步骤

4.7 zlib 库安装完毕

5、安装 openssl 库

5.1 cd 到 /usr/local 目录

Linux 安装 Nginx 详细步骤

5.2 tar -zxvf openssl-1.0.1j.tar.gz 解压

Linux 安装 Nginx 详细步骤

     Linux 安装 Nginx 详细步骤

5.3 cd openssl-1.0.1j 目录

5.4 执行./config 编译

Linux 安装 Nginx 详细步骤

5.5 make 编译

Linux 安装 Nginx 详细步骤

5.6 make install 安装

Linux 安装 Nginx 详细步骤

5.7 openssl 库安装完毕

6、安装 openssl 库

6.1 cd 到 /usr/local 目录

Linux 安装 Nginx 详细步骤

6.2 tar -zxvf nginx-1.5.9.tar.gz 解压

Linux 安装 Nginx 详细步骤

Linux 安装 Nginx 详细步骤

6.3 cd nginx-1.5.9 目录

6.4 执行 ./configure –prefix=/usr/local/nginx   注意编译之后的文件都放在 /usr/local/nginx

Linux 安装 Nginx 详细步骤

6.5 make 编译

Linux 安装 Nginx 详细步骤

6.6 make install 安装

Linux 安装 Nginx 详细步骤

6.7 openssl 库安装完毕

7、启动测试

7.1 启动命令:/usr/local/nginx/sbin/nginx

Linux 安装 Nginx 详细步骤

7.2 本机浏览器测试:虚拟机 IP 地址即可 

Linux 安装 Nginx 详细步骤

7.3 如果访问不了关闭防火墙 CentOS7

关闭防火墙命令:systemctl stop firewalld.service

禁用防火墙命令:systemctl disable firewalld.service

Linux 安装 Nginx 详细步骤

7.4 访问效果  访问虚拟机 IP 地址

Linux 安装 Nginx 详细步骤

8、Nginx 备机安装步骤同上 2、3、4、5、6、7 步

9、虚拟机备机访问效果

Linux 安装 Nginx 详细步骤

10、注意区分主机 nginx 和备机 nginx

11、Nginx 常用命令

重启:
$ /usr/local/nginx/sbin/nginx 启动命令
重启:
$ /usr/local/nginx/sbin/nginx –s reload
停止:
$ /usr/local/nginx/sbin/nginx –s stop
测试配置文件是否正常:
$ /usr/local/nginx/sbin/nginx –t
强制关闭:
$ pkill nginx
正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-21发表,共计1518字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中