LAMP動態網站搭建指令碼

來源:互聯網
上載者:User

標籤:lamp動態   網站   

#!/bin/bash#auto make install LAMP#by authors zhang 2016#httpd define path variableH_FILES=httpd-2.2.17.tar.gzH_FILES_DIR=httpd-2.2.17H_PREFIX=/usr/local/httpd/#mysql define path variableM_FILES=mysql-5.5.22.tar.gzM_FILES_DIR=mysql-5.5.22M_PREFIX=/usr/local/mysql/#php define path variableP_FILES1=libmcrypt-2.5.8.tar.gzP_FILES_DIR1=libmcrypt-2.5.8P_PREFIX1=/usr/local/lib/P_FILES2=mhash-0.9.9.9.tar.gzP_FILES_DIR2=mhash-0.9.9.9P_PREFIX2=/usr/local/lib/P_FILES3=mcrypt-2.6.8.tar.gzP_FILES_DIR3=mcrypt-2.6.8P_PREFIX3=/usr/local/lib/P_FILES4=php-5.3.28.tar.gzP_FILES_DIR4=php-5.3.28P_PREFIX4=/usr/local/php/if [ -z "$1" ];then        echo -e "\033[36m請選擇下面選項:\033[0m"        echo -e "\033[32m1)編譯安裝Apache伺服器\033[1m"        echo "2)編譯安裝MySQL伺服器"        echo "3)編譯安裝PHP伺服器"        echo "4)配置index.php並啟動LAMP服務"echo "5)部署phpMyAdmin系統"        echo -e "\033[31m使用: { /bin/sh $0 1|2|3|4|help}\033[0m"        exitfi#auto install Apacheif [ $1 -eq 1 ];then        rpm -e httpd --nodeps        tar -zxvf $H_FILES &&cd $H_FILES_DIR ;./configure --prefix=$H_PREFIX --enable-so --enable-rewrite --enable-charset-lite --enable-cgi        if [ $? -eq 0 ];then                make &&make install                echo -e "\033[32mThe $H_FILES_DIR Server Install successfully!(Apache服務安裝已完成!)\033[0m"        else                echo -e "\033[32mThe $H_FILES_DIR Server Install failed,please check...\033[0m"                exit        fifi#auto install Mysqlif [ $1 -eq 2 ];then        rpm -e mysql-server mysql --nodeps        tar -zxvf cmake-2.8.6.tar.gz -C /usr/src/ && cd /usr/src/cmake-2.8.6/;./configure        if [ $? -eq 0 ];then                gmake &&gmake install                echo -e "\033[32mThe cmake Server Install successfully!(cmake編譯安裝完成!)\033[0m"        else                echo -e "\033[32mThe cmake Server Install failed,please check...\033[0m"                exit        fi        useradd -M -u 27 -s /sbin/nologin mysql        cd /root        tar -zxvf $M_FILES -C /usr/src/;cd /usr/src/$M_FILES_DIR && cmake -DCMAKE_INSTALL_PREFIX=$M_PREFIX -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all        if [ $? -eq 0 ];then                make &&make install                echo -e "\033[32mThe mysql $M_FILES_DIR Install successfully!(MySQL服務安裝已完成!)\033[0m"        else                echo -e "\033[32mThe mysql $M_FILES_DIR Install failed,please check...\033[0m"                exit        fi        chown -R mysql:mysql /usr/local/mysql/        cd /usr/src/$M_FILES_DIR        cp support-files/my-medium.cnf /etc/my.cnf        $M_PREFIX/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/        cd /usr/src/$M_FILES_DIR        ln -s /usr/local/mysql/bin/* /usr/local/bin/        cp support-files/mysql.server /etc/init.d/mysqld        chmod +x /etc/rc.d/init.d/mysqld        chkconfig --add mysqld        chkconfig mysqld on        service mysqld stop        service mysqld start        netstat -anpt | grep 3306fi#PHP define path variableif [ $1 -eq 3 ];then        tar -zxvf $P_FILES1 -C /usr/src/;cd /usr/src/$P_FILES_DIR1/ && ./configure && make && make install && ln -s /$P_PREFIX1/libmcrypt.* /usr/lib/        cd /root/        tar -zxvf $P_FILES2 -C /usr/src/;cd /usr/src/$P_FILES_DIR2/ && ./configure && make && make install && ln -s /$P_PREFIX2/libmhash* /usr/lib/        cd /root/        tar -zxvf $P_FILES3 -C /usr/src/;cd /usr/src/$P_FILES_DIR3/ && export LD_LIBRARY_PATH=/$P_PREFIX3:$LD_LIBRARY_PATH && ./configure && make && make install        cd /root/        tar -zxvf $P_FILES4 -C /usr/src/;cd /usr/src/$P_FILES_DIR4/ && ./configure --prefix=$P_PREFIX4 --with-mcrypt --with-apxs2=$H_PREFIX/bin/apxs --with-mysql=$M_PREFIX --with-config-file-path=$P_PREFIX4 --enable-mbstring --enable-sockets        if [ $? -eq 0 ];then                make &&make install                echo -e "\033[32mThe $P_FILES_DIR4 Server Install successfully!(PHP安裝已完成!)\033[0m"        else                echo -e "\033[32mThe $P_FILES_DIR4 Server Install failed,please check...\033[0m"                exit        fifiif [ $1 -eq 4 ];then        sed -i ‘/DirectoryIndex/s/index.html/index.php index.html/g‘ $H_PREFIX/conf/httpd.conf        echo "AddType   application/x-httpd-php .php" >>$H_PREFIX/conf/httpd.conf        IP=`ifconfig eth0|grep "Bcast"|awk ‘{print $2}‘|cut -d: -f2`        echo "You can access http://$IP/"cat >$H_PREFIX/htdocs/index.php <<EOF<?phpphpinfo();?>EOFfiif [ $1 -eq 5 ];then        tar -zxvf phpMyAdmin-4.2.5-all-languages.tar.gz        mv phpMyAdmin-4.2.5-all-languages/ /usr/local/httpd/htdocs/phpMyAdmin        cd /usr/local/httpd/htdocs/phpMyAdmin        cp config.sample.inc.php config.inc.php        if [ $? -eq 0 ];then                echo -e "\033[32mphpMyAdmin系統安裝完成!\033[0m"        else                echo -e "\033[31mphpMyAdmin系統安裝失敗!\033[0m"        fifi      #  netstat -tnl       # /usr/local/httpd/bin/apachectl -t        #/usr/local/httpd/bin/apachectl start        #ps -ef | grep http         #       echo -e "\033[32m配置完成,開啟瀏覽器測試結果\033[0m"#phpMyAdmin測試:fireorx http://192.168.1.1/phpMyAdmin &

本文出自 “光速蝸牛” 部落格,轉載請與作者聯絡!

LAMP動態網站搭建指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.