码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS6.5下Nginx1.7.4安装记录

时间:2015-10-13 01:54:10      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:nginx centos6.5

1.环境准备

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

技术分享

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

技术分享

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


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

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

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

技术分享

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

技术分享

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

技术分享

切换目录:cd nginx-1.7.4

配置:./configure

技术分享

提示以下信息:./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.

技术分享

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

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

技术分享

输入y,回车

技术分享

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

技术分享

再执行./configure

还是提示同样的错误;

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

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

技术分享

根据提示在后面添加参数指定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

最后的提示信息如下:

技术分享

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

make && make install

提示以下错误:

技术分享

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

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

执行之后再执行:./configure

再执行:make && make install

安装完成!

技术分享

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

修改配置文件:

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

修改文件:vi nginx.conf

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

技术分享

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/

看到以下信息了吗?

技术分享

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


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

./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命令:


[plain] view plaincopy技术分享技术分享

  1. /usr/local/nginx/sbin/nginx -h  

  2. nginx version: nginx/1.7.5  

  3. Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]  

  4.   

  5. Options:  

  6.   -?,-h         : this help  

  7.   -v            : show version and exit  

  8.   -V            : show version and configure options then exit  

  9.   -t            : test configuration and exit  

  10.   -q            : suppress non-error messages during configuration testing  

  11.   -s signal     : send signal to a master process: stop, quit, reopen, reload  

  12.   -p prefix     : set prefix path (default: /usr/local/nginx/)  

  13.   -c filename   : set configuration file (default: conf/nginx.conf)  

  14.   -g directives : set global directives out of configuration file  


文件权限问题:

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

chmod -R 777 ./uploadfile


本文出自 “IT系统架构” 博客,请务必保留此出处http://ghostxyj.blog.51cto.com/692495/1702209

CentOS6.5下Nginx1.7.4安装记录

标签:nginx centos6.5

原文地址:http://ghostxyj.blog.51cto.com/692495/1702209

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!