nginx的安装

一. 准备环境
1.安装gcc
yum install gcc gcc-c++

2.安装pcre
为了确保能在 Nginx 中使用正则表达式进行更灵活的配置,安装之前需要确定系统是否安装有 PCRE(Perl Compatible Regular Expressions)包。
下载pcre-8.20.tar.gz,地址是:http://sourceforge.net/projects/pcre/files/pcre/ ,上传至/usr/local,安装目录:/usr/local/pcre
# mkdir -p pcre
# tar zxvf pcre-8.20.tar.gz
# cd pcre-8.20
# ./configure --prefix=/usr/local/pcre
# make
# make install

二. 安装Nginx
下载nginx-0.8.54.tar.gz,地址是:http://nginx.org/en/download.html ,上传至/usr/local,安装目录:/usr/local
2.1.安装
# tar zxvf nginx-0.8.54.tar.gz
#mv nginx-0.8.54 nginx
# cd nginx-0.8.54
# ./configure --sbin-path=/usr/local/nginx --conf-path=/usr/local/nginx --pid-path=/usr/local/nginx --with-http_ssl_module --with-pcre=/usr/local/pcre-8.20
# make
# make install

2.2.检查nginx是否安装成功  
#cd  /usr/local/nginx/sbin
#./nginx -t 
结果显示:
   nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
   nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

2.3.启动nginx 
#cd  /usr/local/nginx/sbin 
#./nginx 


2.4.检查是否启动成功
      客户端ie 浏览器中输入 http://ip(Linux)

其中参数:
--with-pcre=/usr/local/pcre-8.20 指的是pcre-8.20 的源码路径,并不是安装路径。

安装成功后 /usr/local/webserver/nginx 目录下有四个子目录分别是:conf、html、logs、sbin 。其中 Nginx 的配置文件存放于 conf/nginx.conf,Nginx 只有一个程序文件位于 sbin 目录下的 nginx 文件。确保系统的 80 端口没被其他程序占用,运行 sbin/nginx 命令来启动 Nginx,打开浏览器访问此机器的 IP(地址栏输入:127.0.0.1),如果浏览器出现 Welcome to nginx! 则表示 Nginx 已经安装并运行成功。

 
三. 安装过程中出现的问题
1.pcre :/configure: error: no acceptable C compiler found in $PATH  See `config.log' for more details
原因是没装gcc
解决办法:yum install gcc

2../configure :checking for C++ compiler default output file name... configure: error: C++ compiler cannot create executables
See `config.log' for more details.
原因是由于c++编译器的相关package没有安装
解决办法:yum install gcc-c++

3.pcre:make时报错:[pcrecpp.lo] Error 1
原因是由于c++编译器的相关package没有安装
解决办法:yum install gcc-c++,重新configure,make && make install通过。

4../configure: error: the HTTP rewrite module requires the PCRE library
原因是需要PCRE library
解决办法:yum -y install pcre-devel

5../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.
原因是需要OpenSSL library
解决办法:yum -y install openssl openssl-devel

原文地址:https://www.cnblogs.com/xiatian1071/p/3519646.html