一键安装nginx脚本
#!/bin/bash . /etc/init.d/functions #安装依赖包 yum -y install pcre-devel openssl-devel #创建相关目录,并下载nginx软件包 [ ! -d /application ] && mkdir -p /application [ ! -d /server/tools ] && mkdir -p /server/tools cd /server/tools wget http://nginx.org/download/nginx-1.6.3.tar.gz tar xf nginx-1.6.3.tar.gz sleep 5 cd nginx-1.6.3 useradd -s /sbin/nologin -M nginx #编译安装nginx ./configure --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --prefix=/application/nginx-1.6.3 if [ $? -eq 0 ] then action "Configure Nginx Success!" /bin/true else action "Configure Nginx Failure" /bin/false fi make if [ $? -eq 0 ] then action "Make Nginx Success!" /bin/true else action "Make Nginx Failure" /bin/false fi make install if [ $? -eq 0 ] then action "Install Nginx Success!" /bin/true else action "Install Nginx Failure" /bin/false fi ln -s /application/nginx-1.6.3 /application/nginx #启动nginx /application/nginx/sbin/nginx #判断nginx是否启动成功 HTTP_CODE=`curl -I -s -w "%{http_code}\n" -o /dev/null 127.0.0.1` if [ $HTTP_CODE -eq 200 -o $HTTP_CODE -eq 301 ] then action "Nginx is running" /bin/true else action "Nginx already been down" /bin/false fi
===================end==========================
本文出自 “迷失在Linux” 博客,请务必保留此出处http://zihang.blog.51cto.com/158746/1913627
原文地址:http://zihang.blog.51cto.com/158746/1913627