1、安装c语言环境:
[root@localhost opt]# rpm -qa|grep gcc
[root@localhost opt]# yum install gcc-c++
[root@localhost opt]# yum install -y pcre pcre-devel
yum -y install make zlib-devel gcc-c++ libtool openssl openssl-devel
2、下载nginx离线包:
下载地址:http://nginx.org/download/
下载版本:nginx-1.9.9.tar.gz
3、上传离线包 & 解压:
[root@localhost /]# cd /opt/nginx
[root@localhost nginx]# rz
[root@localhost nginx]# ls
nginx-1.9.11.tar.gz
[root@localhost nginx]# tar -zxvf nginx-1.9.11.tar.gz
4、编译安装nginx:
[root@localhost /]# cd /opt/nginx/nginx-1.9.11
[root@localhost nginx-1.9.11]# mkdir nginx
[root@localhost nginx-1.9.11]# ./configure --prefix=/opt/nginx/nginx-1.9.11
[root@localhost nginx-1.9.11]# make && make install
[root@localhost nginx-1.9.11]# make && make install
5、新建nginx日志目录 & 日志:
[root@localhost nginx-1.9.11]# mkdir -p /opt/nginx/nginx-1.9.11/logs
[root@localhost logs]# touch /opt/nginx/nginx-1.9.11/logs/error.log
6、新建启动脚本 & 修改nginx启动脚本:
[root@localhost nginx-1.9.11]# touch start.sh
[root@localhost nginx-1.9.11]# vi start.sh
7、脚本【start.sh】文件内容:
pkill -9 nginx
/opt/nginx/nginx-1.9.11/sbin/nginx
8、启动脚本:
[root@localhost nginx-1.9.11]# sh start.sh