linux下nginx安装脚本
Posted ivon168
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux下nginx安装脚本相关的知识,希望对你有一定的参考价值。
#!/bin/bash
#安装编译工具及库文件
#软件包准备PCRE和nginx
package_dir="/data/app/Softpackage"
install_dir="/usr/local"
pcre_version="8.35"
nginx_version="1.12.2"
#下载安装包
package_download(){
wget et http://downloads.sourceforge.net/project/pcre/pcre/$pcre_version/pcre-$pcre_version.tar.gz
wget et http://nginx.org/download/nginx-$nginx_version.tar.gz
}
#
}
#安装pcre
pcre_install(){
tar -xvzf pcre-$pcre_re_version.tar.gz
cd pcre-$pcre_version;./configure; make && make install
pcre_version_check=`pcre-config --version`
if [ "$pcre_version_check" != "$pcre_version" ];then
echo -e " 33[41;36m pcre install failed 33[0m"
exit 1
fi
}
#安装nginx
nginx_install(){
cd $package_dir
tar -xvzf nginx-$nginx_nx_version.tar.gz
cd nginx-$nginx_version
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=$package_dir/pcre-8.35
make;make install
nginx_check=`$install_dir/nginx/sbin/nginx -v`
if [ $? -eq 0 ];then
echo -e " 33[42;30m nginx install successed... 33[0m"
else
echo -e " 33[41;36m nginx install failed 33[0m"
fi
}
#配置nginx
nginx_configure(){
cd $install_dir/nginx
mkdir -p /var/cache/nginx
mv *temp /var/cache/nginx
mkdir conf.d;cd conf;cp cp nginx.conf ../ ../conf.d
ip_loc=`ifconfig eth0 | grep "inet addr" | awk ‘{ print $2}‘ | awk -F: ‘{print $2}‘`
cd $install_dir/nginx/conf.d
mv mv nginx.conf $i $ip_ip_loc.conf
}
file_exist(){
if [ ! -d "$package_dir" ];then
mkdir -p $package_dir
else
echo "文件夹已存在"
fi
if [ ! -d "$install_dir" ];then
mkdir -p $install_dir
else
echo "文件夹已存在"
fi
}
#函数调用
file_exist
cd $package_dir
#安装编译工具及库文件
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
package_download
pcre_install
nginx_install
nginx_configure
以上是关于linux下nginx安装脚本的主要内容,如果未能解决你的问题,请参考以下文章