安装
安装依赖库和模块
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
安装 PCRE 模块
PCRE 作用是让 Ngnix 支持 Rewrite 功能。
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
tar zxvf pcre-8.35.tar.gz
cd pcre-8.36
./configure
make && make install
编译安装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/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/nginxModule/pcre-8.35
make
make install
usr/local/nginxModule/pcre-8.35
这个用自己的安装目录,如果安装新模块,就像上面安装pcre类似,然后在重写编译安装nginx即可。也可以把 /usr/local/nginx/sbin 加到环境变量中。
常用命令
nginx -v //查看版本信息
nginx -V //查看安装了那些模块
/usr/local/nginx/sbin/nginx –s reload //重启
/usr/local/nginx/sbin/nginx –s stop //停止
/usr/local/nginx/sbin/nginx –t //测试配置文件是否正常
pkill nginx //强制关闭
killall nginx