5分钟编译安装nginx1.10.1支持清除缓存

实现功能:

  1. nginx稳定版本

  2. 支持模块purge、rewrite、ssl等等

  3. 软件包下载

  4. 等等等等....


本文送给需要安装nginx的小伙伴,由于本人编代码能力非常有限,故下面的脚本写的很烂,勿喷。

相信下面的脚本是个人都能看懂!!!

cat nginx.sh

yum -y install wget git vim make gcc gcc-c++ openssl-devel


#安装依赖库


mkdir /root/app
cd /root/app
mkdir -p /usr/local/nginx/module

#创建软件存放目录

wget http://nchc.dl.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.gz
wget https://www.openssl.org/source/openssl-1.0.2h.tar.gz
wget http://zlib.net/zlib-1.2.8.tar.gz
wget https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz
wget http://nginx.org/download/nginx-1.10.1.tar.gz

#下载所需软件包

tar -xf pcre-8.39.tar.gz -C /usr/local/nginx/module/
tar -xf openssl-1.0.2h.tar.gz -C /usr/local/nginx/module/
tar -xf zlib-1.2.8.tar.gz -C /usr/local/nginx/module/
tar -xf 2.3.tar.gz -C /usr/local/nginx/module/
tar -xf nginx-1.10.1.tar.gz -C /usr/local/nginx/module/

#解压软件包

useradd -M -s /sbin/nologin nginx

#创建用户

cd /usr/local/nginx/module/nginx-1.10.1


#进入nginx配置目录

/usr/local/nginx/module/nginx-1.10.1/configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre=/usr/local/nginx/module/pcre-8.39 --with-zlib=/usr/local/nginx/module/zlib-1.2.8 --with-openssl=/usr/local/nginx/module/openssl-1.0.2h --add-module=/usr/local/nginx/module/ngx_cache_purge-2.3
make && make install

#配置和编译(如需其他模块请自行添加)

cd /usr/local/nginx/conf
mkdir /usr/local/nginx/conf/servers
cp nginx.conf nginx.conf.bak
chown -R nginx:nginx /usr/local/nginx

#备份默认配置文件并赋予权限


/usr/local/nginx/sbin/nginx -t

#检测nginx是否正常

/usr/local/nginx/sbin/nginx

#启动nginx

netstat -nltp|grep nginx

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      13709/nginx


-------------------end--------------