linux上安装nginx简单几步

nginx下载地址:http://nginx.org/download/,我选择一个1.6.0版本nginx-1.6.0.tar.gz

建议所有操作要在管理员权限下操作,安装目录在/usr/local下,安装在其他目录可能找不到sbin文件夹。

步骤:

 # wget http://nginx.org/download/nginx-1.6.0.tar.gz 下载
# tar -zxv -f nginx-1.6.0.tar.gz 解压
# cd nginx-1.6.0 到文件目录
# ./configure --prefix=/usr/local/nginx  指定安装路径
(如果需要升级nginx,例如nginx1.9开始支持socket转发,编译时需要添加--with-stream
./configure --prefix=/usr/local/nginx --with-stream)
# make  编译
# make install  安装
安装完成后,启动/nginx/sbin下执行./nginx,在浏览器中输入http://IP查看是否安装成功


指定安装目录时可能会报错1:

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

解决方法:

yum -y install pcre-devel  默认/盘,要保证磁盘有足够空间

可能报错2:

./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

可能报错3:

解决办法:安装gcc

yum install gcc

再次执行

./configure --prefix=/usr/local/nginx

# make  编译
# make install  安装




网络借鉴:

nginx编译几个基本的的参数详细列表解释:

--prefix=<path>  指定nginx的安装路径,如果没有指定,默认安装在/usr/local/nginx下。

--sbin-path=<path> nginx的可执行文件的安装路径,这个路径只能够在安装的时候指定,默认为nginx安装路径下的sbin目录下。

--conf-path=<path> 指定nginx的配置文件nginx.conf的路径,默认为<nginx>/conf/nginx.conf。

--pid-path=<path> 指定nginx.pid文件的路径,默认为<nginx>/logs/nginx.conf

--lock-path=<path> 指定nginx.lock路径

--error-log-path=<path> 指定错误日志的路径

--http-log-path=<path> 指定访问日志的路径。

--user=<user> 指定nginx的运行用户,默认为nobody

--group=<group> 指定nginx的运行组,默认为nobody

--with-http_stub_status_module 启用 "server status" 页

--with-openssl=<dir> 指定openssl库源路径

参考备忘:

http://blog.csdn.net/apache0554/article/details/7766567 
http://www.cnblogs.com/kunhu/p/3633002.html 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值