一、

wget http://nginx.org/download/nginx-1.5.9.tar.gz直接在Linux上用命令下载

二、

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

三、

设置一下配置信息 ./configure --prefix=/usr/local/nginx 

四、

make 编译

五、

make install 安装

在配置信息的时候,也就是在第三步,出现了一下错误:

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

安装pcre-devel解决问题
yum -y install pcre-devel
错误提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library.   You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.

解决办法:

yum -y install openssl openssl-devel


./nginx -v 先打开/usr/local/nginx/sbin 再执行命令

安装成功后,只能本地访问,还需要设置防火墙

vim /etc/sysconfig/iptables 编辑防火墙文件
新增
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT //--防火墙不拦截80端口 保存退出 :wq service iptables restart 重启防火墙

卸载方式:

直接删除安装目录

//启动
./nginx

//关闭
pkill  nginx

还有些其他方式关闭启动,网上搜就可以

 

posted on 2016-07-27 22:33  浅唱年华1920  阅读(206)  评论(0编辑  收藏  举报