Nginx 的安装

参考
http://www.cnblogs.com/mfc-itblog/p/5718655.html

1、线上下载 nginx

wget http://nginx.org/download/nginx-1.11.9.tar.gz  

2、解压

tar zxvf nginx-1.2.6.tar.gz

3、进入文件目录

cd nginx-1.2.6/ 

4、编译 文件

安装目录:/usr/local/nginx/(自选)

./configure --user=www --group=www --prefix=/usr/local/nginx  \--with-http_stub_status_module --with-http_ssl_module 
在nginx发布的版本中,除了http和mail模块之外,还有一些其他模块在默认安装时并没有被安装可通过以下配置来启用相应的选项(http://www.cnblogs.com/HKUI/p/5225895.html )

--prefix   : Nginx安装的根路径,所有其它路径都要依赖该选项

--with-http_stub_status_module  : 
这个模块可以取得一些nginx的运行状态,如果是工业状况,可以直接取消,
输出的状态信息科使用RRDtool或类似的工具绘制成图

--with-http_ssl_module   : 
如果需要对流量加密.可使用此选项,在urls中开始部分将会是https(需要openssl库)

① 直接执行,出现错误 1

这里写图片描述

错误代码

checking for PCRE library … not found checking for PCRE library in /usr/local/ … not found checking for PCRE library in /usr/include/pcre/ … not found checking for PCRE library in /usr/pkg/ … not found checking for PCRE library in /opt/local/ … not found ./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by usingwithout-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by usingwith-pcre=<path> option.

提示安装 PCRE(让 Ngnix 支持 Rewrite 功能。)

下载安装 prec 以及依赖包

yum install pcre-devel

② 再次执行 Nginx 编译的代码出现错误 2

这里写图片描述

提示安装 openssl 组件

直接下载安装 openssl

yum install openssl openssl-devel
./configure --with-http_ssl_module --with-ipv6
Make
Make install

之后再次编译Nginx 的编译

5、安装

make 
make install

6、Nginx安装完毕,然后使用命令:

/usr/local/nginx/sbin/nginx -t 

测试OK,代表nginx安装成功

7、启动 Nginx 服务

/usr/local/nginx/sbin/nginx

可以通过访问http://ip/看到nginx默认页面。

这里写图片描述

8、端口占用时修改 nginx.conf 配置文件

这里写图片描述

当然以上只是一种安装方式,可以以其他方式安装

参考:
http://www.runoob.com/linux/nginx-install-setup.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值