安装前先验证下版本
安装gcc
rpm -Uvh *.rpm --nodeps --force
安装g++
rpm -Uvh *.rpm --nodeps --force
验证gcc、g++是否安装成功,执行命令:
gcc -v
g++ -v
一.安装PCRE
先把pcre解压出来
tar xvf pcre-8.35.tar.gz
切换PCRE目录
cd pcre
执行以下命令
./configure
make
make install
二.安装libtool
解压libtool
tar xvf libtool-2.4.2.tar.gz
切换libtool目录
cd libtool
执行以下命令
./configure
make
make install
三.安装nginx
解压nginx
tar xvf nginx-1.13.9.tar.gz
切换nginx目录
cd nginx
执行以下命令
./configure
make
make install
安装nginx时可能会抛出异常
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using –without-http_gzip_module
option, or install the zlib library into the system, or build the zlib
library
statically from the source with nginx by using –with-zlib= option.
yum install -y zlib-devel 执行对应的安装命令即可
或者上传zlib包安装命令同上边
四.常用命令
启动-c参数指定了要加载的nginx配置文件路径。
需要配置nginx.conf需要在use/local/nginx下的conf中进行配置
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
启动
/usr/local/nginx/sbin/nginx
停止
/usr/local/nginx/sbin/nginx -s stop
重启
/usr/local/nginx/sbin/nginx -s reload
查询端口
ps -ef | grep nginx
杀掉进程
kill 进程id
查看进程
netstat -nltp