1.库的安装
安装必要的库(nginx 中gzip模块需要 zlib 库,rewrite模块需要 pcre 库,ssl 功能需要openssl库)
1.安装gcc gcc-c++(如新环境,未安装请先安装)
yum install -y gcc gcc-c++
2.安装PCRE库
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
解压
tar -zxvf pcre-8.36.tar.gz
进入PCRE
cd pcre-8.36
找到根目录
./configure
安装
make && make install
如报错:configure: error: You need a C++ compiler for C++ support
解决:
yum install -y gcc gcc-c++
3.安装SSL库
wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz
解压
tar -zxvf openssl-1.0.1j.tar.gz
进入
cd openssl-1.0.1j
根目录
./config
安装
make && make install
4.安装zlib库存
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
./configure
cd zlib-1.2.11
./configure
make && make install
4.安装nginx
wget http://nginx.org/download/nginx-1.8.0.tar.gz
解压
tar -zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0
./configure \
--prefix=/usr/local/nginx \
--pid-path=/usr/local/nginx/run \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre \
--with-http_image_filter_module \
--with-debug \
make && make install
5.启动
/usr/local/nginx/sbin/nginx
查看nginx是否启动成功
网页输入该服务器网址
安装成功
其他命令:
重启:/usr/local/nginx/sbin/nginx –s reload
停止:/usr/local/nginx/sbin/nginx –s stop