自用一键LAMP源码环境(CentOS6.8) 本文共有13829个字,关键词: ``` echo "LAMP starting...." #先检查光盘是否挂载 VALUE1=$(df -h |grep "/dev/sr0" >/dev/null) VALUE2=$(df -h |grep "/dev/sr1" >/dev/null) if [ -z "$VALUE1" ]; then if [ -b /dev/sr0 ]; then mkdir -p /ISO/cdrom1 mount -t iso9660 /dev/sr0 /ISO/cdrom1 else echo "/dev/sr0 is not exiest!" exit 1 fi fi if [ -z "$VALUE2" ]; then if [ -b /dev/sr1 ]; then mkdir -p /ISO/cdrom2 mount -t iso9660 /dev/sr1 /ISO/cdrom2 else echo "/dev/sr1 is not exiets!" exit 1 fi fi if [ -f /etc/yum.repos.d/CentOS-Base.repo ]; then mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak fi yum clean all yum list if [ "$?" == "0" ]; then echo "yum is ok" else #判断光盘大小,用于指定顺序 CD1=$(df -P |grep "/dev/sr0" |awk -F ' ' '{print $3}') CD2=$(df -P |grep "/dev/sr1" |awk -F ' ' '{print $3}') if [ $CD1 -gt $CD2 ]; then CDROM1="/ISO/cdrom1" CDROM2="/ISO/cdrom2" else CDROM1="/ISO/cdrom2" CDROM2="/ISO/cdrom1" fi echo ' [c6-media] name=CentOS-software-package baseurl=file://$CDROM1 file://$CDROM2 gpgchk=0 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6' >/etc/yum.repos.d/CentOS-Media.repo fi sed -i '7s/enforcing/disabled/g' /etc/selinux/config if [ "$?" == "0" ]; then echo "selinux is close,next reboot come into force!this is Temporary effective." setnforce 0 fi iptables -F #iptables -A INPUT -p tcp -dport 80 -j ACCEPT service iptables stop chkconfig iptables off if [ -d /lamp ]; then cd /lamp else echo "/lamp is not exist!" exit 1 fi for i in $(ls); do [[ "$i" =~ ".tar" ]] && tar -xvf $i [[ "$i" =~ ".zip" ]] && unzip $i done DF1=$(df -Ph |grep "/usr" |awk -F ' ' '{print $4}' |cut -d "G" -f 1) DF2=$(df -Ph |grep "\/$" |awk -F ' ' '{print $4}' |cut -d "G" -f 1) if [ -n "$DF1" ]; then DF3=$(echo "$DF1" |sed "s/[0-9]//g") if [ -z "$DF3" ]; then if [ $DF1 -ge 3 ]; then echo -e "\033[32mcheck disk is ok! \033[0m" else echo -e "\033[31mdisk is full\033[0m" fi fi else echo "Tips:/usr is not alone mount." fi if [ -n "$DF2" ]; then DF4=$(echo "$DF2" |sed 's/[0-9]//g') if [ -z "$DF4" ]; then if [ $DF2 -ge 3 ]; then echo -e "\033[32mcheck disk is ok! \033[0m" else echo -e "\033[31mdisk is full\033[0m"; exit 1 fi fi else echo 'Tips:/ is not alone mount.' fi yum -y install gcc gcc-c++ #[ "$?" == "0" ] && "\033[32;2mgcc is OK!\033[0m" || echo -e "\033[31:2mgcc install fail!" yum -y install libxml2-devel yum -y install python-devel cd /lamp/libxml2-2.9.1 ./configure --prefix=/usr/local/libxml2/ if [ "$?" == "0" ];then make else echo "libxml2 not make" exit 11 fi if [ "$?" == "0" ]; then make install else echo "libxml2 not make install" exit 11 fi [ "$?" != "0" ] && echo -e "\033[31;2mlibxml2-2.9.1 is not install!\033[0m" && exit 11 cd /lamp/libmcrypt-2.5.8 ./configure --prefix=/usr/local/libmcrypt/ if [ "$?" == "0" ]; then make else echo "libmcrypt is not make." exit 11 fi if [ "$?" == "0" ]; then make install else echo "libmcrypt is not make install." exit 11 fi [ "$?" != "0" ] && echo -e "\033[31;2mlibmcrypt-2.5.8 is not install!\033[0m" && exit 11 cd /lamp/libmcrypt-2.5.8/libltdl ./configure --enable-ltdl-install if [ "$?" == "0" ]; then make else echo "libltdl is not make." exit 11 fi if [ "$?" == "0" ]; then make install else echo "libltdl is not make install." exit 11 fi [ "$?" != "0" ] && echo -e "\033[31;2mlibmcrypt-2.5.8/libltdl is not install!\033[0m" && exit 11 cd /lamp/mhash-0.9.9.9 ./configure if [ "$?" == "0" ]; then make else echo "mhssh-0.9.9.9 not make" exit 11 fi if [ "$?" == "0" ]; then make install else echo "mhash-0.9.9.9 not make install" exit 11 fi [ "$?" != "0" ] && echo -e "\033[31;2mmhash-0.9.9.9 is not install!\033[0m" && exit 11 ############################################################################################################ cd /lamp/mcrypt-2.6.8 #此处变量报错,改为掉后恢复正常。 LD_LIBRARY_PATH=/usr/local/libmcrypt/lib:/usr/local/lib ./configure --with-libmcrypt-prefix=/usr/local/libmcrypt if [ "$?" == "0" ]; then make else echo "mcrypt not make" exit 11 fi if [ "$?" == "0" ]; then make install else echo "mcrypt not make install" exit 11 fi ################################################################################################################ [ "$?" != "0" ] && echo -e "\033[31;2mmcrypt-2.6.8 is not install!\033[0m" && exit 11 cd /lamp/zlib-1.2.3 ./configure if [ "$?" == "0" ]; then sed -i '21s/CFLAGS=-O3 -DUSE_MMAP/CFLAGS=-O3 -DUSE_MMAP -fPIC/g' ./Makefile; make else echo "zlib is not make" exit 11 fi if [ "$?" == "0" ]; then make install else echo "zlib is not make install" exit 11 fi [ "$?" != "0" ] && echo -e "\033[31;2m zlib-1.2.3 is not install!\033[0m" && exit 11 cd /lamp/libpng-1.2.31 ./configure --prefix=/usr/local/libpng if [ "$?" == "0" ]; then make else echo "libpng is not make." exit 11 fi if [ "$?" == "0" ]; then make install else echo "libpng is not make install." exit 11 fi [ "$?" != "0" ] && echo -e "\033[31;2m libpng-1.2.31 is not install!\033[0m" && exit 11 mkdir -p /usr/local/jpeg6/{bin,lib,include,/man/man1} yum -y install libtool* cd /lamp/jpeg-6b \cp -f /usr/share/libtool/config/config.sub ./ \cp -f /usr/share/libtool/config/config.guess ./ cd /lamp/jpeg-6b ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static if [ "$?" == "0" ]; then make else echo "jpeg is not make." exit 11 fi if [ "$?" == "0" ]; then make install else echo "jpeg is not make install." exit 11 fi [ "$?" != "0" ] && echo -e "\033[31;2m jpeg-6b is not install!\033[0m" && exit 11 cd /lamp/freetype-2.3.5 ./configure --prefix=/usr/local/freetype/ if [ "$?" == "0" ]; then make else echo "freetype is not make" exit 11 fi if [ "$?" == "0" ]; then make install else echo "freetype is make install." exit 11 fi [ "$?" != "0" ] && echo -e "\033[31;2m freetype-2.3.5 is not install!\033[0m" && exit 11 \cp -rf /lamp/apr-1.4.6 /lamp/httpd-2.4.7/srclib/apr \cp -rf /lamp/apr-util-1.4.1 /lamp/httpd-2.4.7/srclib/apr-util cd /lamp/pcre-8.34 ./configure if [ "$?" == "0" ]; then make else echo "pcre-8.34 is not make." exit 11 fi if [ "$?" == "0" ]; then make install else echo "pcre-8.34 is not make install." exit 11 fi [ "$?" != "0" ] && echo -e "\033[31;2m pcre-8.34 is not install!\033[0m" && exit 11 yum -y install openssl-devel cd /lamp/httpd-2.4.7 ./configure --prefix=/usr/local/apache2 --sysconfdir=/usr/local/apache2/etc --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared if [ "$?" == "0" ]; then make else echo "httpd-2.4.7 is not make." exit 11 fi if [ "$?" == "0" ]; then make install else echo "httpd-2.4.7 is not make install." exit 11 fi #/usr/local/apache2/bin/apachectl start #[ "$?" == "0" ] && echo "test apache start is ok!" || echo "apache start is fail.check selinux."; exit 1 #ps aux |greep --color "httpd" #sleep 1 #netstat -tlun |grep --color ":80" #sleep 1 echo ' #!/bin/bash #Version:0.0.0 #Author:stone #Discription:apache start scripts # chkconfig: 2345 66 33 # discription:apache start httpd="/usr/local/apache2/bin/apachectl" case $1 in start) $httpd start ;; stop) $httpd stop ;; status) $httpd status ;; restart) $httpd stop sleep 1 $httpd start ;; --help) echo "use start|stop|restart|status" ;; *) echo "use start|stop|restart|status" ;; esac' >/etc/init.d/httpd chmod +x /etc/init.d/httpd chkconfig --add httpd chkconfig httpd on service httpd start yum -y install ncurses-devel cd /lamp/ncurses-5.9 ./configure --with-shared --without-debug --without-ada --enable-overwrite if [ "$?" == "0" ]; then make else echo "ncurses-5.9 is not make." exit 11 fi if [ "$?" == "0" ]; then make install else echo "ncurses-5.9 is not make install." exit 11 fi [ "$?" != "0" ] && echo -e "\033[31;2m ncurses-5.9 is not install!\033[0m" && exit 11 yum -y install cmake yum -y install bison useradd -r -s /sbin/nologin mysql cd /lamp/mysql-5.5.48 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 if [ "$?" == "0" ]; then make else echo "mysql is not make." exit 11 fi if [ "$?" == "0" ]; then make install else echo "mysql is not make install;" exit 11 fi [ "$?" != "0" ] && echo -e "\033[31;2m mysql-5.5.48 is not install!\033[0m" && exit 11 cd /usr/local/mysql/ chown -R root . chown -R mysql data \cp -rf support-files/my-medium.cnf /etc/my.cnf cd /usr/local/mysql /usr/local/mysql/scripts/mysql_install_db --user=mysql & service mysqld start /usr/local/mysql/bin/mysqld_safe --user=mysql & \cp -a /lamp/mysql-5.5.48/support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld #给脚本执行权限 chkconfig --add mysqld chkconfig mysqld on service mysqld restart #数据库必须启动起来才可以设置密码 /usr/local/mysql/bin/mysqladmin -uroot password 123456 service mysqld stop #echo ' #show database; #use test; #show tables; #\s #exit #' | /usr/local/mysql/bin/mysql -u root -p123 yum -y install libtool* cd /lamp/php-7.0.7 ./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets --with-pdo-mysql=/usr/local/mysql --with-gd --without-pear if [ "$?" == "0" ]; then make else echo "php is not make" exit 11 fi if [ "$?" == "0" ]; then make install else echo "php is not make install." exit 11 fi [ "$?" != "0" ] && echo -e "\033[31;2m php-7.0.7 is not install!\033[0m" && exit 11 sed -i '/AddType.*tgz/i\AddType application/x-httpd-php .php .phtml' /usr/local/apache2/etc/httpd.conf sed -i '/AddType.*tgz/i\AddType application/x-httpd-php-source .phps' /usr/local/apache2/etc/httpd.conf yum -y install openssl-devel cd /lamp/php-7.0.7/ext/openssl mv config0.m4 config.m4 /usr/local/php/bin/phpize ./configure --with-openssl --with-php-config=/usr/local/php/bin/php-config if [ "$?" == "0" ]; then make else echo "php/ext/openssl is not make." exit 11 fi if [ "$?" == "0" ]; then make install else echo "php/ext/openssl is not make install." exit 11 fi [ "$?" != "0" ] && echo -e "\033[31;2m php-7.0.7/ext/openssl is not install!\033[0m" && exit 11 cd /lamp/pecl-memcache-php7 /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config if [ "$?" == "0" ]; then make else echo "pecl-memcache is not make." exit 11 fi if [ "$?" == "0" ]; then make install else echo "pecl-memcache is not make install." exit 11 fi [ "$?" != "0" ] && echo -e "\033[31;2m pecl-memcache-php7 is not install!\033[0m" && exit 11 sed -i 's@extension_dir.*@extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20151012@g"' /usr/local/php/etc/php.ini sed -i 's@; extension="openssl.so";@extension="openssl.so";@g' /usr/local/php/etc/php.ini sed -i 's@; extension="memcache.so";@extension="memcache.so";@g' /usr/local/php/etc/php.ini yum -y install libevent-devel cd /lamp/memcached-1.4.17 ./configure --prefix=/usr/local/memcache if [ "$?" == "0" ]; then make else echo "memcache is not make." exit 11 fi if [ "$?" == "0" ]; then make install else echo "memcache is not make install." exit 11 fi [ "$?" != "0" ] && echo -e "\033[31;2m memcached-1.4.17 is not install!\033[0m" && exit 11 useradd -r -s /sbin/nologin memcache /usr/local/memcache/bin/memcached -umemcache & ln -s /usr/local/memcache/bin/memcached /usr/local/memcached \cp /lamp/memcached-1.4.17/scripts/memcached.sysv /etc/init.d/memcached sed -i 's@daemon memcached@daemon /usr/local/memcache/bin/memcached@' /etc/init.d/memcached sed -i 's@killproc memcached@killproc /usr/local/memcache/bin/memcached@' /etc/init.d/memcached #phpmyadmin 的版本会影响登录时的显示,此版本会在登录时弹出对话框。 \cp -fr /lamp/phpMyAdmin-4.1.4-all-languages /usr/local/apache2/htdocs/phpmyadmin cd /usr/local/apache2/htdocs/phpmyadmin \cp -fr config.sample.inc.php config.inc.php sed -i '29s/cookie/http/' /usr/local/apache2/htdocs/phpmyadmin/config.inc.php #添加用户,并修改apache主配置文件内容 groupadd www useradd -r -g www -s /sbin/nologin www sed -i '160s@User.*@User www@g' /usr/local/apache2/etc/httpd.conf sed -i '161s@Group.*@Group www@g' /usr/local/apache2/etc/httpd.conf sed -i '249s@$@& index.php@' /usr/local/apache2/etc/httpd.conf service httpd restart #重启服务 echo -e "\033[32;2mLAMP is OK!\033[0m" ``` 「一键投喂 软糖/蛋糕/布丁/牛奶/冰阔乐!」 赞赏 × 几人行 (๑>ڡ<)☆谢谢老板~ 2元 5元 10元 50元 100元 任意金额 2元 使用微信扫描二维码完成支付 版权声明:本文为作者原创,如需转载须联系作者本人同意,未经作者本人同意不得擅自转载。 shell脚本 2017-03-21 评论 2528 次浏览