安装 Nginx 服务器


Nginx 安装

1 ,安装前准备

安装nginx之前我们通过 yum 安装两个软件

1 pcre - 为了有rewrite功能,

1
# yum install pcre

2 openssl - 为了支持ssl

1
# yum install openssl

2 ,安装Nginx

2.1 下载 Nginx

我们用wget下载1.6.2 稳定版

1
wget http://nginx.org/download/nginx-1.6.2.tar.gz

2.2 解压并且安装

下载完成之后 解压文件

1
tar xvf nginx-1.6.2.tar.gz

解压完成之后 , 开始编译安装

1
2
3
4
5
6
7
# cd nginx-1.6.2
# ./configure --prefix=/usr/local/nginx-1.6.2 \
--with-http_ssl_module --with-http_spdy_module \
--with-http_stub_status_module --with-pcre

1
make
1
make install

2.2.1 安装过程中常见错误1

1
./configure: error: the HTTP rewrite module requires the PCRE library.

那么我们要安装pcre-devel来解决问题

1
# yum -y install pcre-deve

2.2.2 安装过程中常见错误 2

1
2
3
4
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.

解决办法

1
yum -y install openssl openssl-devel

2.3 启动Nginx

1
2
3
/usr/local/nginx-1.6.2/sbin/nginx
curl http://localhost

发现Nginx 服务已经正常启动 : )

License

注 :转载 请注明出处 http://blog.netpi.me/nginx/nginx-Installation/