您的位置:首页 > 运维架构 > Nginx

nginx安装(centos6.9)

2017-04-19 00:00 459 查看
一. 下载软件

nginx-1.12.0.tar.gz http://nginx.org/download/nginx-1.12.0.tar.gz

pcre-8.40.tar.gz ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz

zlib-1.2.11.tar.gz http://www.zlib.net/zlib-1.2.11.tar.gz

二. 安装pcre

主页地址: http://www.pcre.org/

1. 解压缩

tar -xzvf pcre-8.40.tar.gz

2. 配置

# cd pcre-8.40

# ./configure

configure有许多参数可配,具体参见./configure --help及手册

若出现以下错误

configure: error: You need a C++ compiler for C++ support.

则说明需要C++编译环境支持

使用yum安装gcc-c++

# yum install -y gcc gcc-c++

安装成功后,重新执行

# ./configure

3. 编译

# make

4. 安装

# make install

安装过程出现警告:

libtool: warning: relinking 'libpcreposix.la'

libtool: warning: relinking 'libpcrecpp.la'

但安装nginx能成功。

如果安装pcre2,则安装nginx会失败,nginx不支持pcre2?

三. 安装zlib

1. 解压缩

tar -xzvf zlib-1.2.11.tar.gz

2. 配置

# cd zlib-1.2.11

# ./configure

3. 编译

# make

4. 安装

# make install

四. 安装nginx

1. 解压缩

tar -xzvf nginx-1.12.0.tar.gz

2. 配置

# cd nginx

# ./configure

3. 编译

# make

4. 安装

# make install

5. 启动

# cd /usr/local/nginx/sbin

# ./nginx

启动报错:

/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
解决方方法,执行:

# ln -s /usr/local/lib/libpcre.so.1 /lib64

再次启动执行

# ./nginx

6.验证nginx是否启动成功

# curl http://localhost
出现下面信息表示启动成功



或者直接在浏览器访问服务器的ip会出现下面画面,也表示启动成功.



备注:

在安装prce执行make命令时

WARNING: 'aclocal-1.15' is missing on your system.
You should only need it if you modified 'acinclude.m4' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'aclocal' program is part of the GNU Automake package:
<http://www.gnu.org/software/automake>
It also requires GNU Autoconf, GNU m4 and Perl in order to run:
<http://www.gnu.org/software/autoconf>
<http://www.gnu.org/software/m4/>
<http://www.perl.org/>
make: *** [aclocal.m4] Error 127

无法进行下一步,所以必须解决。根据warning给的提示以及网上搜的信息判断,这是一个时间戳变化导致的系统以为文件被修改,所以需要重新编译几个脚本文件。实际上我从官网下载来的源文件压缩包我根本没有改动过,这错误比较少见,相关资料实在太少。最后反复确认是在本地解压tar.gz后(文件最后修改时间变为当前时间),才上传到centos系统中造成的。因此将tar.gz上传到centos系统中,再执行 tar -xzvf pcre-8.40.tar.gz ,一切OK。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx