标签:nginx编译安装脚本
#!/bin/bash DIR=$( cd "$( dirname "$0" )" && pwd ) SRCDIR=/usr/local/src nginxVersion="1.10.1" nginxUser=nginx nginxGroup=nginx if [ $(id -u) -ne 0 ]; then echo "Please run as root" exit 1 fi DISTRO="" Distributions="CentOS Ubuntu Amazon" for i in $Distributions do cat /etc/*release |grep "$i" >/dev/null if [ $? -eq 0 ]; then DISTRO=$i fi done echo $DISTRO egrep "^$nginxGroup" /etc/group >/dev/null if [ $? -ne 0 ]; then groupadd -r $nginxGroup fi egrep "^$nginxUser" /etc/passwd >/dev/null if [ $? -ne 0 ]; then [ $DISTRO = "Amazon" -o $DISTRO = "CentOS" ] && useradd -g $nginxGroup $nginxUser -s /sbin/nologin -M -r fi cd $SRCDIR [ ! -f nginx-$nginxVersion.tar.gz ] && wget http://nginx.org/download/nginx-$nginxVersion.tar.gz tar -xzf nginx-$nginxVersion.tar.gz cd nginx-$nginxVersion ## 添加第三方EPEL更新源 [ $DISTRO = "CentOS" ] && yum install -y epel-release ## 依赖安装 if [ $DISTRO = "Amazon" -o $DISTRO = "CentOS" ]; then yum groupinstall -y "Development Tools" yum groupinstall -y "Development Libraries" yum install -y wget gcc gcc-c++ make zlib-devel pcre-devel openssl-devel libxslt-devel gd-devel perl-devel perl-ExtUtils-Embed GeoIP-devel gperftools-devel fi ./configure --prefix=/usr/local/nginx-$nginxVersion --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --user=$nginxUser --group=$nginxGroup --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_dav_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-google_perftools_module --with-file-aio --with-pcre --with-ipv6 --with-debug --with-ld-opt="-Wl,-E" if [ $? -eq 0 ]; then make && make install else echo -e "\033[41;30m configured failed!!! \033[0m" exit 5 fi cd /usr/local ln -sv nginx-$nginxVersion nginx ln -sv /usr/local/nginx/conf /etc/nginx ln -sv /usr/local/nginx/sbin/nginx /usr/sbin/nginx mkdir -p /var/lib/nginx/tmp/client_body
本文出自 “11414123” 博客,转载请与作者联系!
标签:nginx编译安装脚本
原文地址:http://11424123.blog.51cto.com/11414123/1841281