设为首页 收藏本站
查看: 777|回复: 0

[经验分享] CentOS6.5下Nginx1.7.4安装记录

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-10-13 08:51:26 | 显示全部楼层 |阅读模式

1.环境准备

yum -y install gcc gcc-c++ autoconf automake make

Center.jpg

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

Center.jpg

不执行以上两项安装的话,就可能会遇到下面我的安装过程中遇到的情况:


到此页面下载自己想要的版本:

http://nginx.org/en/download.html

左侧为Linux版本,右侧为Windows版本

SouthEast.jpg

使用以下命令下载文件:wget http://nginx.org/download/nginx-1.7.4.tar.gz

SouthEast.jpg

解压文件:tar -zxvf nginx-1.7.4.tar.gz

SouthEast.jpg

切换目录:cd nginx-1.7.4

配置:./configure

SouthEast.jpg

提示以下信息:./configure: error: the HTTP rewrite module requires the PCRE library.

You can either disable the module by using --without-http_rewrite_module

option, or install the PCRE library into the system, or build the PCRE library

statically from the source with nginx by using --with-pcre=<path> option.

SouthEast.jpg

需要安装pcre ,他作用是让ngnix支持rewrite功能

使用命令安装:yum install pcre-devel.i686

SouthEast.jpg

输入y,回车

SouthEast.jpg

最后提示Complete,说明安装成功:

SouthEast.jpg

再执行./configure

还是提示同样的错误;

执行命令查找PCRE的安装位置:file -name pcre

得到的是:./auto/lib/pcre

SouthEast.jpg

根据提示在后面添加参数指定Path

执行命令:./configure --with-pcre=./auto/lib/pcre

提示如下信息:

./configure: error: the HTTP gzip module requires the zlib library.

You can either disable the module by using --without-http_gzip_module

option, or install the zlib library into the system, or build the zlib library

statically from the source with nginx by using --with-zlib=<path> option.


还缺少zlib library信息!

执行以下命令安装:yum -y install make zlib zlib-devel gcc-c++ libtool

安装成功之后,再执行命令:./configure --with-pcre=./auto/lib/pcre

最后的提示信息如下:

SouthEast.jpg

应该是配置成功了,执行以下命令安装:

make && make install

提示以下错误:

SouthEast.jpg

该装的都装了,还是无法安装,最后执行以下命令解决问题:

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

执行之后再执行:./configure

再执行:make && make install

安装完成!

SouthEast.jpg

记住上图中的一些目录位置!

修改配置文件:

切换目录:cd /usr/local/nginx/conf

修改文件:vi nginx.conf

主要是修改server配置节的内容,按字母i进入编辑模式

SouthEast.jpg

按ESC键,退出编辑模式,按冒号键“:”进入命令模式,输入“wq”然后回车,保存并退出;


切换到sbin目录:cd /usr/local/nginx/sbin

启动Nginx:./nginx

开放防火墙端口:

/sbin/iptables -I INPUT -p tcp --dport 88 -j ACCEPT

/etc/init.d/iptables save


打开浏览器,输入以下地址访问吧:

http://你的服务器IP:88/

看到以下信息了吗?

SouthEast.jpg

我是看到了,看不到的朋友继续努力吧!


注意:我在虚拟机中安装的时候遇到了类似以下错误:

./configure auto/unix: No such file or directory

当我使用“mkdir auto/unix”之后,还是提示类似的错误,但目录名又变了。

纠结了好久,后来发现是解压的时候就有好多文件没有解压出来,判断应该是安装包压缩文件坏了,

所以解压的时候就少了好多的文件或目录,重新下载一个解压安装问题就解决了。


配置Nginx开机启动,vi /etc/rc.d/rc.local

在文件末尾添加“/usr/local/nginx/sbin/nginx”


Nginx常用命令:

重新加载配置文件:/usr/local/nginx/sbin/nginx -s reload

停止Nginx服务:/usr/local/nginx/sbin/nginx -s stop

其它Nginx命令:



  • /usr/local/nginx/sbin/nginx -h
  • nginx version: nginx/1.7.5
  • Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
  • Options:
  •   -?,-h         : this help
  •   -v            : show version and exit
  •   -V            : show version and configure options then exit
  •   -t            : test configuration and exit
  •   -q            : suppress non-error messages during configuration testing
  •   -s signal     : send signal to a master process: stop, quit, reopen, reload
  •   -p prefix     : set prefix path (default: /usr/local/nginx/)
  •   -c filename   : set configuration file (default: conf/nginx.conf)
  •   -g directives : set global directives out of configuration file

文件权限问题:

有可能因为目录、文件权限过高,导致Nginx无权访问文件,可以通过以下命令修改权限:

chmod -R 777 ./uploadfile




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-126094-1-1.html 上篇帖子: nginx 扩 展 负 载 均 衡 集 群 下篇帖子: linux/centos安装nginx常见错误及解决办法 记录
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表