温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

安装nginx

发布时间:2020-06-30 00:47:00 阅读:588 作者:OOOPE 栏目:系统运维
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

查看环境

Nginx的安装

模块依赖性Nginx需要依赖下面3个包

1. gzip 模块需要 zlib  ( 下载http://www.zlib.net/ )

2. rewrite 模块需要 pcre  ( 下载http://www.pcre.org/ )

3. ssl 功能需要 openssl  ( 下载http://www.openssl.org/ )

判断是否安装  gcc  gcc-c++

存在

[root@bogon /]# rpm  -q  gcc    或者   rpm –ql  gcc   列出所有的文件路径

gcc-4.4.7-18.el6.x86_64

查看是否已经安装了REPC

rpm -qa | grep“REPC”

好的这里看到已经安装了。同理查看openssl  gzip  wget

安装nginx

安装make

yum -y install  gcc  automake autoconf libtool make

安装g++ c++

yum install gcc gcc-c++

第一种方法源码安装

依赖包安装顺序依次为:openssl、zlib、pcre, 然后安装Nginx包.

第二步:依次安装openssl-fips-2.0.2.tar.gz,zlib-1.2.7.tar.gz, pcre-8.21.tar.gz, nginx-1.2.6.tar.gz

1.安装openssl-fips-2.0.2.tar.gz

 [root@localhostmrms]# tar -zxvf openssl-fips-2.0.2.tar.gz

[root@localhost mrms]# cd openssl-fips-2.0.2

[root@localhost openssl-fips-2.0.2]# ./config

[root@localhost openssl-fips-2.0.2]# make

[root@localhost openssl-fips-2.0.2]# makeinstall

2.安装zlib-1.2.7.tar.gz

 [root@localhostmrms]# tar -zxvf zlib-1.2.7.tar.gz

[root@localhost mrms]# cd zlib-1.2.7

[root@localhost zlib-1.2.7]# ./configure

[root@localhost zlib-1.2.7]# make

[root@localhost zlib-1.2.7]# make install

3.安装pcre-8.21.tar.gz

 [root@localhostmrms]# tar -zxvf pcre-8.21.tar.gz

[root@localhost mrms]# cd pcre-8.21

[root@localhost pcre-8.21]# ./configure

[root@localhost pcre-8.21]# make

[root@localhost pcre-8.21]# make install

第二种方法 通过yum

yum  -y install  zlib  zlib-devel openssl  openssl—devel  pcre  pcre-devel

或者是

 yum install pcre*

 yum install openssl*

 yum install zlib 

 yum install zlib-devel

 yum install wget

遇到错误

错误为:./configure: error: the HTTP rewrite module requires the PCRElibrary.

第一种方法处理

安装pcre-devel解决问题

yum -y install pcre-devel

yum -y install openssl openssl-devel

第二种方法处理 源码包

3.安装pcre-8.21.tar.gz

 [root@localhostmrms]# tar -zxvf pcre-8.21.tar.gz

[root@localhost mrms]# cd pcre-8.21

[root@localhost pcre-8.21]# ./configure

[root@localhost pcre-8.21]# make

[root@localhost pcre-8.21]# make install

4.安装 nginx-1.2.6.tar.gz

 [root@localhostmrms]# tar -zxvf nginx-1.2.6.tar.gz

[root@localhost mrms]# cd nginx-1.2.6

[root@localhost nginx-1.2.6]# ./configure--with-pcre=../pcre-8.21 --with-zlib=../zlib-1.2.7 --with-openssl=../openssl-fips-2.0.2

或者:[root@localhost nginx-1.2.6]# ./configure

[root@localhost nginx-1.2.6]# make

[root@localhost nginx-1.2.6]# make install

遇到错误

错误为:./configure: error: the HTTP rewrite module requires the PCRElibrary.

如上处理

修改端口

vi  / usr / local / nginx  /  conf  /  nginx.conf

安装nginx

Esc :wq

在防火墙设置端口

# vi /etc / sysconfig / iptables

安装nginx

重启端口服务

Service iptables restart

查看端口服务

/  etc  /init.d/  iptables   status

安装nginx

启动nginx

/usr/local/nginx/nginx   或者    /usr/local/nginx/sbin/nginx

 

重启nginx

/usr/local/nginx/sbin/nginx-s reload

/usr/local/nginx/sbin/nginx-s reopen 

查看进程号    

ps -ef|grep "nginx"

安装nginx

杀死进程

[root@bogon ~]# kill -QUIT 16717

强制停止

[root@ root@bogon ~]# pkill -9 nginx

项目文件存放路径

放到这个文件下,创建文件夹放入就好。

 安装nginx

安装位置就是--prefix指定的/usr/local/nginx,配置文件位置:/usr/local/nginx/nginx.conf  或者 /usr/local/nginx/conf/nginx.conf

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI

开发者交流群×