码迷,mamicode.com
首页 > 系统相关 > 详细

linux下nginx安装脚本

时间:2018-08-26 13:46:37      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:pre   source   exist   tar   ...   pcre   c++   fail   with   

#!/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 "\033[41;36m pcre install failed \033[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 "\033[42;30m nginx install successed... \033[0m"
else
echo -e "\033[41;36m nginx install failed \033[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安装脚本

标签:pre   source   exist   tar   ...   pcre   c++   fail   with   

原文地址:https://www.cnblogs.com/perTest/p/9536959.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!