标签:mirror png 依赖 dev 扩展模块 zabbix安装 .gz include icon
#!/bin/bash #coding:utf-8 #author:fjiangjun #date:2018/1/30 check_dir(){ if [ ! -d $1 ] then mkdir -p $1 else echo -e "\033[33m检测到$1这个目录已经存在\033[0m" fi } check_dir /opt/lnmp BASE_DIR=/opt/lnmp check_env(){ echo } echo "--------------this is script to download lnmp in /opt/lnmp---------------- " first(){ echo -e "\033[32m安装编译工具\033[0m" yum install gcc gcc-c++ make epel-release -y echo -e ".\n.\n" echo -e "\033[32m安装nginx的依赖包\033[0m" yum install pcre-devel zlib-devel openssl-devel -y echo -e ".\n.\n" echo -e "\033[32m安装php的依赖包\033[0m" yum install -y libxml2-devel.x86_64 libxml2.x86_64 bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel } nginx_install(){ cd $BASE_DIR check_dir $BASE_DIR/nginx echo -e "\033[32m进入$BASE_DIR/nginx目录,准备下载\033[0m" echo -e "\033[32m开始下载安装nginx.1.8.0\033[0m" wget -c http://nginx.org/download/nginx-1.8.0.tar.gz -O nginx-1.8.0.tar.gz tar -xf nginx-1.8.0.tar.gz cd nginx-1.8.0 echo -e "\033[32m开始编译nginx-1.8.0\033[0m" ./configure --prefix=$BASE_DIR/nginx --with-http_stub_status_module --with-http_realip_module --with-http_ssl_module echo -e ".\n.\n" make make install echo -e ".\n.\n" echo "\033[32mNGINX安装成功\033[0m" echo -e ".\n.\n" } php_install(){ cd $BASE_DIR check_dir $BASE_DIR/php echo -e "\033[32m进入$BASE_DIR/php目录,准备下载\033[0m" echo -e "\033[32m开始下载安装php-5.6.30.tar.gz\033[0m" #wget -c http://cn2.php.net/get/php-5.6.33.tar.gz/from/this/mirror -O php-5.6.33.tar.gz wget -c http://cn2.php.net/distributions/php-5.6.30.tar.gz -O php-5.6.30.tar.gz tar -xf php-5.6.30.tar.gz cd php-5.6.30 ./configure --prefix=$BASE_DIR/php --enable-fpm --enable-mysqlnd --enable-ftp --with-mysql=mysqlnd --with-mysqli --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-gd --with-freetype-dir --with-jpeg-dir --with-png-dir make make install echo -e ".\n.\n" echo -e "\033[32m开始编译PHP-5.6.30\033[0m" echo "\033[32mPHP-5.6.30安装成功\033[0m" echo -e ".\n.\n" } mysql(){ echo -e "\033[32m开始下载mysql-server\033[0m" rpm -qa | grep mysql &>/dev/null && echo -e "\033[33m检测到MYSQL已经用YUM安装,跳过安装!\033[0m" || yum install -y mysql-server } check_nginx(){ ls $BASE_DIR/nginx | xargs echo | grep conf |grep html | grep sbin | grep logs &>/dev/null if [ $? -eq 0 ] then echo -e "\033[31mNGINX 或许已经下载了,请检查一下$BASE_DIR/nginx\033[0m" read -t 5 -p "你要下载吗?(y/n) 默认为不下载,将等待5秒 : " choose choose=${choose:-n} if [ $choose == "y" -o $choose == "Y" ] then #rm -fr $BASE_DIR/nginx $BASE_DIR/nginx-1.8.0 $BASE_DIR/nginx-1.8.0.tar.gz mv -f $BASE_DIR/nginx $BASE_DIR/nginx-1.8.0 $BASE_DIR/nginx-1.8.0.tar.gz -t /tmp echo "原NGINX安装目录备份在/tmp目录下" nginx_install else echo -e "\033[33m你选择跳过重新安装NGINX\033[33m" fi else nginx_install fi } check_php(){ ls $BASE_DIR/php | xargs echo | xargs echo | grep bin | grep etc | grep include | grep lib | grep php | grep sbin | grep var &>/dev/null if [ $? -eq 0 ] then echo -e "\033[31mPHP 或许已经安装了,请检查$BASE_DIR/php\033[0m" read -t 5 -p "你要重新下载PHP吗?(y/n) 默认为不下载,将等待5秒 : " choose choose=${choose:-n} echo $choose if [ $choose == "y" -o $choose == "Y" ] then #rm -fr $BASE_DIR/php $BASE_DIR/php-5.6.30 $BASE_DIR/php-5.6.30.tar.gz mv -f $BASE_DIR/php $BASE_DIR/php-5.6.30 $BASE_DIR/php-5.6.30.tar.gz -t /tmp echo "原PHP安装目录备份在/tmp目录下" php_install else echo -e "\033[33m你选择跳过重新安装PHP\033[0m" fi else php_install fi } check_zabbix(){ echo "开始安装ZABBIX的EPEL源" rpm -i http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm rpm -qa | grep zabbix-server | grep zabbix-web-mysql | grep zabbix-agent if [ $? -ne 0 ] then echo "开始安装ZABBIX-SERVER-MYSQL ZABBIX-WEB-MYSQL ZABBIX-AGETN" yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent echo "ZABBIX安装完成" else echo -e "\033[33mZABBIX已经安装了\033[0m" fi } main(){ echo -e "\033[32m--------------这个脚本用于在/opt/lnmp/下载安装LNMP----------\033[0m" #"\033[32m 绿色字 \033[0m" echo -e "\033[32mNGINX 下载网站 http://nginx.org/download/nginx-1.8.0.tar.gz\033[0m" echo -e "\033[32mPHP 下载网站 http://cn2.php.net/distributions/php-5.6.30.tar.gz\033[0m" echo -e "\033[32mMYSQL 下载网址 http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35.tar.gz\033[0m" echo -e "\033[32mZABBIX 下载网址 https://www.zabbix.com/download?zabbix=3.2&os_distribution=centos&os_version=6&db=MySQL \033[0m" echo -e ".\n.\n.\n" first echo -e ".\n.\n" check_nginx || exit 1 echo -e ".\n.\n" check_php || exit 2 echo -e ".\n.\n" mysql || exit 3 echo -e ".\n.\n" #check_zabbix || exit 4 echo -e ".\n.\n" } mainnginx,php,有些扩展模块不足,只做练习。
可以去掉check_zabbix注释,来安装zabbix。
标签:mirror png 依赖 dev 扩展模块 zabbix安装 .gz include icon
原文地址:http://blog.51cto.com/19941018/2067320