博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nginx安装
阅读量:7025 次
发布时间:2019-06-28

本文共 2303 字,大约阅读时间需要 7 分钟。

hot3.png

系统:Centos6.6  64位

Nginx:   目前最新版本1.9.4 我下载1.8.0

下载模块依赖性Nginx需要依赖下面3个包

1.gzip 模块需要 zlib 库 ( 下载: http://www.zlib/ )
2.rewrite 模块需要 pcre 库 ( 下载: http://www.pcre.org/ )
3.ssl 功能需要 openssl 库 ( 下载: http://www.openssl.org/ )
依赖包安装顺序依次为:openssl、zlib、pcre, 然后安装Nginx包

 

如果没有安装c++编译环境,还得安装,通过yum install gcc-c++完成安装

下载完成后:

112347_mbqx_1421266.png

 

下一步,编译安装

openssl :

 

[root] tar zxvf openssl-fips-2.0.9.tar.gz

[root] cd openssl-fips-2.0.9

[root] ./config && make && make install

 

pcre:

 

[root] tar zxvf pcre-8.36.tar.gz

[root] cd pcre-8.36

[root@localhost]  ./configure && make && make install

 

zlib:

[root@localhost]tar zxvf zlib-1.2.8.tar.gz

[root@localhost] cd zlib-1.2.8

[root@localhost]  ./configure && make && make install

 

最后安装nginx

[root@localhost]tar zxvf nginx-1.8.0.tar.gz

[root@localhost] cd nginx-1.8.0

[root@localhost]  ./configure && make && make install

 

安装完成后,可启动nginx:

启动命令:/usr/local/nginx/sbin/nginx

发现报错了:
error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
经网上查询,这是的通病
[root@localhost nginx]# sbin/nginx
sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
[root@localhost nginx]# error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
[root@localhost nginx]# whereis libpcre.so.1
libpcre.so: /lib64/libpcre.so.0 /usr/local/lib/libpcre.so /usr/local/lib/libpcre.so.1
[root@localhost nginx]# ln -s /usr/local/lib/libpcre.so.1 /lib64
[root@localhost nginx]# sbin/nginx   
                           
先找到libpcre.so.1所在位置,然后做个软链接就可以了。
查看是否已启动:

最后在浏览器输入ip:80即可 访问,正常如下:

112116_sOpw_1421266.png

注意:

1.启动Ngnix的时候提示错误,异常信息如下。

* Starting nginx nginx                                                         nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)

nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

问题描述:端口已被使用。可能nginx服务卡死了,导致端口占用,出现此错误。

解决方案:

原因: 端口 80 端口被占用,用 “lsof -i:80" 命令查看一下是什么程序占用了80端口,然后kill之后再启动即可。

2.在虚拟机上安装的nginx由于防火墙原因有可能在本机上访问不了,所以可以关闭防火墙或者在配置 /etc/sysconfig/iptables 中添加 -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT

转载于:https://my.oschina.net/u/1421266/blog/906493

你可能感兴趣的文章
JavaScript 面向对象的编程(三) 类的继承
查看>>
redis 指定端口 启动
查看>>
21. Merge Two Sorted Lists
查看>>
SQL Server中date和datetime的区别
查看>>
HDu Battle
查看>>
python学习笔记Day4
查看>>
网站域名重定向
查看>>
Python全栈开发-有趣的小程序
查看>>
sdfsdsf
查看>>
最简单的实体手机测试移动端前端Vue Cli3搭建网站的方法
查看>>
AbsoluteDefense 项目Beta版本Postmortem结果
查看>>
数据结构和算法——将序列分解为单独的变量
查看>>
Kali Linux 安装教程-转
查看>>
【转360】KB4041678 Windows 仅安全更新(2017.10) 补丁更新后执行SQL出错! http://bbs.360.cn/thread-15201531-1-1.html...
查看>>
phantomjs + python 打造一个微信机器人
查看>>
[shell命令]文件查看/拼接:wc,sed,awk,cut,grep,paste,sz,cz
查看>>
【搜索】P1468 派对灯 Party Lamps
查看>>
C语言实现链表的原地置逆
查看>>
JavaScript关于闭包的理解和实例
查看>>
jquery-ui-widget
查看>>