一. 下载软件nginx
nginx-1.12.0.tar.gz http://nginx.org/download/nginx-1.12.0.tar.gzc++
pcre-8.40.tar.gz ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gzcentos
zlib-1.2.11.tar.gz http://www.zlib.net/zlib-1.2.11.tar.gz浏览器
二. 安装pcre服务器
主页地址: http://www.pcre.org/curl
1. 解压缩ui
tar -xzvf pcre-8.40.tar.gz url
2. 配置.net
# cd pcre-8.40ip
# ./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。