请确认gcc g++开发类库是否装好,默认已经安装。
yum -y install gcc automake autoconf libtool make
yum install gcc gcc-c++
一、选定安装文件目录
cd /usr/local/src
二、安装PCRE库
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 下载最新的 PCRE 源码包,使用下面命令下载编译和安装 PCRE 包:(本文参照下载文件版本:pcre-8.37.tar.gz 经过验证未发现这个版本,若想下载最新版本请打开上面网址。本文选择pcre-8.39.tar.gz)
cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz tar -zxvf pcre-8.37.tar.gz cd pcre-8.34 ./configure make make install
注意如果pcre版本可以根据自己的情况调整,没有版本强制要求,如果出现报错请使用:yum -y install pcre-devel 。自动安装
三、安装zlib库
http://zlib.net/zlib-1.2.11.tar.gz 下载最新的 zlib 源码包,使用下面命令下载编译和安装 zlib包:(本文参照下载文件版本:zlib-1.2.8.tar.gz 经过验证未发现这
cd /usr/local/src wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz tar -zxvf openssl-1.0.1t.tar.gz个版本,若想下载最新版本请打开上面网址。本文选择zlib-1.2.11.tar.gz ) 这一步骤不会出现任何问题,已测试cd /usr/local/src wget http://zlib.net/zlib-1.2.11.tar.gz tar -zxvf zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure make make install四、安装openssl(某些vps默认没装ssl)
yum -y install openssl openssl-devel五、安装nginx
Nginx 一般有两个版本,分别是稳定版和开发版,您可以根据您的目的来选择这两个版本的其中一个,下面是把 Nginx 安装到 /usr/local/nginx 目录下的详细步骤:
cd /usr/local/src wget http://nginx.org/download/nginx-1.1.10.tar.gz tar -zxvf nginx-1.1.10.tar.gz cd nginx-1.1.10 ./configure make make install
注意这个时候编译的时候 会出现个make[1]: Leaving directory `/usr/local/nginx’ 的错误是可以忽略的参考
因为我所有的操作步骤都是按照上面来的,我的解决办法也非常的简单:
如果你走到make这一步的时候只出现了一行“make[1]: Leaving directory `/usr/local/nginx-1.12.1;”提示,不用管它,继续走make install ;
然后:
1、我只需要去看/usr/local下面是否有nginx文件夹?
2、如果已经有nginx文件夹?
3、我们再去看nginx是否可以正常启动?
4、如果nginx启动也可以成功,我们再去看下网站是否可以访问,是否会出现“Welcome to nginx!”?
5、如果上面都成功了,说明你的nginx已经ok!
此解决方法只针对报错一行,如果你安装nginx走到make这一步的时候,报错了很多行的make解决办法就不一样了,比如说:有时候安装nginx需要指定 pcre 的源码目录;
安装Nginx时报错 PCRE library OpenSSL library
安装Nginx时报错
./configure: error: the HTTP rewrite module requires the PCRE library.
安装pcre-devel解决问题
yum -y install pcre-devel
错误提示:./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
注意诸如 make[1]: Leaving directory `/usr/local/***的错误 这两项可以使用 自动安装
[root@LinuxServer sbin]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
综合参考文章 http://www.cnblogs.com/wyd168/p/6636529.html
http://blog.csdn.net/feng27156/article/details/38874921
http://blog.csdn.net/cuipengchong/article/details/44102525
https://www.fujieace.com/nginx/make1-leaving-directory-usrlocalnginx.html