linux安装nginx及注意事项
1、网络配置
1)查看linux是否可以连外网
#ping www.baidu.com
如果ping不通外网,需要配置网络
方法:给/etc/resolv.conf添加nameserver
nameserver 114.114.114.114
nameserver 8.8.8.8
内容如下:
配置好了之后,执行命令:
#ping www.baidu.com
结果为:
2、查看yum软件是否安装,安装的yum是否可用
如果系统是RedHat,需要重新安装yum命令,因为RedHat的yum是收费的
重新安装yum的方法:
1)卸载RedHat原有的yum命令
使用命令 rpm -qa|grep yum 能够查看已经安装的yum包
# rpm -qa|grep yum
然后使用命令 rpm -qa|grep yum|xargs rpm -e --nodeps 不检查依赖直接删除所有的rpm包
#rpm -qa|grep yum|xargs rpm -e --nodeps
最后用命令 rpm -qa|grep yum查看是否卸载成功
# rpm -qa|grep yum
2)下载新的centos的yum命令包,然后安装
下载地址:http://mirrors.kernel.org/centos/ 或者 http://mirrors.163.com/centos/ 找对应系统版本号和系统位数下载
查看linux系统的版本信息的命令:
#uname -a
linux环境:Linux SC_Nignx_new 3.10.0-123.el7.x86_64 #1 SMP Mon May 5 11:16:57 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
#python
python环境:Python 2.7.5 (default, Feb 11 2014, 07:46:25)
rpm安装包版本:RPM version 4.11.3
#rpm
以上是我的linux服务器环境,所以选择的yum安装包是7.0版本的
下载这几个安装包:
yum、
yum-plugin-fastestmirror、
yum-metadata-parser、
python-urlgrabber
最后使用命令安装
rpm -ivh yum-metadata-parser-1.1.2.16.el6.i686.rpm
rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm python-urlgrabber-3.9.1-11.el6.noarch.rpm (把相互依赖的包一起安装)
注意:在安装过程中因为环境不一样可能出现不同的问题。如果是因为缺少依赖包安装失败会出现 error:Failed dependencies:缺失包 is needed by 你安装的包,这种情况下,你需要下载缺失的包,然后一起安装即可。如果是因为你安装的包已经存在但是版本不一样会出现conflicts with的提示,你需要根据提示把原来的包卸载之后再次安装新的包。
3)更换yum源,使用163的源
打开http://mirrors.163.com/.help/centos.html,在里面下载对应版本的repo文件,比如我下载的是CentOS6-Base-163.repo文件,然后把它放到/etc/yum.repos.d/下。还需要打开CentOS6-Base-163.repo文件修改$releasever为版本号6
已经修改后的文件内容如下:
# CentOS-ase.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-6 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-6 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-6 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
4)清除原有缓存
使用命令 yum clean all 清除原来的缓存。
5)重新建立缓存
使用命令 yum makecache 重建缓存。
6)测试yum命令是否可用
#yum install wget
1)下载Nginx及相关组件
创建安装软件的目录:
#mkdir /data/soft
#cd /data/soft
[aaa@qq.com src]# wget http://nginx.org/download/nginx-1.10.2.tar.gz
省略安装内容...
[aaa@qq.com src]# wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
省略安装内容...
[aaa@qq.com src]# wget http://zlib.net/zlib-1.2.11.tar.gz
省略安装内容...
[aaa@qq.com src]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
省略安装内容...
2)安装c++编译环境,如已安装可略过
#yum install gcc-c++
如果报错./configure: error: the HTTP rewrite module requires the PCRE library,则根据报错信息执行如下命令:
#yum -y install gcc gcc-c++ kernel-devel --skip-broken
3)安装Nginx及相关组件
openssl安装
[aaa@qq.com src]# tar zxvf openssl-fips-2.0.10.tar.gz
省略安装内容...
[aaa@qq.com src]# cd openssl-fips-2.0.10
[aaa@qq.com openssl-fips-2.0.10]# ./config && make && make install
省略安装内容...
pcre安装
[aaa@qq.com src]# tar zxvf pcre-8.40.tar.gz
省略安装内容...
[aaa@qq.com src]# cd pcre-8.40
[aaa@qq.com pcre-8.40]# ./configure && make && make install
省略安装内容...
zlib安装
[aaa@qq.com src]# tar zxvf zlib-1.2.11.tar.gz
省略安装内容...
[aaa@qq.com src]# cd zlib-1.2.11
[aaa@qq.com zlib-1.2.11]# ./configure && make && make install
省略安装内容...
nginx安装
[aaa@qq.com src]# tar zxvf nginx-1.10.2.tar.gz
省略安装内容...
[aaa@qq.com src]# cd nginx-1.10.2
[aaa@qq.com nginx-1.10.2]# ./configure && make && make install
省略安装内容...
4)启动nginx
查看nginx安装目录:
#whereis nginx
#cd /usr/local/nginx/sbin
#./nginx
如果报错了,error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory,按照下面方式解决
1.用whereis libpcre.so.1命令找到libpcre.so.1在哪里
2.用ln -s /usr/local/lib/libpcre.so.1 /lib64命令做个软连接就可以了
3.用sbin/nginx启动Nginx
4.用ps -aux | grep nginx查看状态
[aaa@qq.com nginx]# whereis libpcre.so.1
[aaa@qq.com nginx]# ln -s /usr/local/lib/libpcre.so.1 /lib64
[aaa@qq.com nginx]# sbin/nginx
[aaa@qq.com nginx]# ps -aux | grep nginx
5)访问nginx服务器
6)Nginx range filter模块数字错误漏洞(CVE-2017-7529)
简单描述 |
Nginx 0.5.6版本至1.13.2版本中的range filter模块存在整数溢出漏洞 |
详细描述 |
Nginx是由俄罗斯的程序设计师Igor Sysoev所开发的一款轻量级Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器。range filter module是其中的一个范围过滤器模块。 Nginx 0.5.6版本至1.13.2版本中的range filter模块存在整数溢出漏洞。攻击者可利用该漏洞获取敏感信息。 |
修补建议 |
目前厂商已发布升级补丁以修复漏洞,补丁获取链接: http://mailman.nginx.org/pipermail/nginx-announce/2017/000200.html |
参考网址 |
MLIST:[nginx-announce] 20170711 nginx security advisory (CVE-2017-7529) URL:http://mailman.nginx.org/pipermail/nginx-announce/2017/000200.html BID:99534 URL:http://www.securityfocus.com/bid/99534 SECTRACK:1039238 URL:http://www.securitytracker.com/id/1039238 |
打开网址:
http://mailman.nginx.org/pipermail/nginx-announce/2017/000200.html
页面有补丁修改url:
http://nginx.org/download/patch.2017.ranges.txt
页面内容:
在linux系统的找到解压之后的nginx:
目录:/data/nginx/nginx/nginx-1.10.2/src/http/modules/ngx_http_range_filter_module.c
找到377行,在对应的位置添加红色字这段内容;
range->start = start;
range->end = end;
+ if (size > NGX_MAX_OFF_T_VALUE - (end - start)) {
+ return NGX_HTTP_RANGE_NOT_SATISFIABLE;
+ }
+
size += end - start;
if (ranges-- == 0) {
然后重新编译nginx,执行./configure 和make命令,不需要执行make install命令
上一篇: Pygame、Python五子棋游戏
推荐阅读
-
Linux libcurl安装及注意事项
-
linux安装nginx及注意事项
-
Linux下RPM软件包的安装及卸载 博客分类: linux rpmlinux
-
Nginx的安装部署及负载均衡设置 软负载Nginx配置
-
win10安装解压版mysql5.7.21过程及注意事项
-
linux下nginx安装,启动,停止,卸载,平滑升级,添加模块 博客分类: nginx nginx安装启动停止添加模块
-
Linux自动化脚本安装Nginx使用说明
-
[转] Linux下RPM软件包的安装及卸载 博客分类: linux linuxrpm
-
Linux下Mysql 5.7的安装及远程连接配置 博客分类: Linux linuxmysql
-
Linux 软件包的安装与管理 博客分类: Linux rpmyum源码安装nginx