搭建lamp的腳本

来源:http://www.cnblogs.com/zengqingfu1442/archive/2017/06/24/7072055.html
-Advertisement-
Play Games

環境:Centos6.6 事先將需要的源碼包打包放在lamp.tar.gz中,並解壓到/root下 [root@zengqingfu ~]# lsanaconda-ks.cfg lamp.sh phpMyAdmin-4.2.5-all-languages.tar.gz 模板avg_score.awk ...


環境:Centos6.6        事先將需要的源碼包打包放在lamp.tar.gz中,並解壓到/root下

[root@zengqingfu ~]# cat /etc/centos-release 
CentOS release 6.6 (Final)
[root@zengqingfu ~]# uname -a
Linux zengqingfu 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

[root@zengqingfu ~]# ls
anaconda-ks.cfg lamp.sh phpMyAdmin-4.2.5-all-languages.tar.gz 模板
avg_score.awk lamp.tar.gz pxe_kickstart.sh 視頻
cmake-2.8.6.tar.gz libmcrypt-2.5.8.tar.gz rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 圖片
history.txt lines sturecord.txt 文檔
httpd-2.2.17.tar.gz mcrypt-2.6.8.tar.gz test 下載
input.txt mhash-0.9.9.9.tar.gz var_of_shell.sh 音樂
install.log mysql-5.5.22.tar.gz ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz 桌面
install.log.syslog php-5.3.28.tar.gz 公共的

執行步驟:每一步執行之後的輸出過程省略了

[root@zengqingfu ~]# ./lamp.sh y   載入光碟搭建本地yum倉庫(可選的,已經搭建好yum倉庫的可以不執行,直接到下一步)

[root@zengqingfu ~]# ./lamp.sh a    安裝Apache web服務

[root@zengqingfu ~]# ./lamp.sh m     安裝mysql

[root@zengqingfu ~]# ./lamp.sh p     編譯安裝PHP


[root@zengqingfu ~]# ./lamp.sh P(大寫的)      再次安裝PHP,並修改httpd.conf以支持PHP解析
  

[root@zengqingfu ~]# ./lamp.sh o          測試PHP能否成功連接MySQL,http網頁能否解析PHP

下麵看完整代碼:

  1 [root@zengqingfu ~]# cat lamp.sh 
  2 #!/bin/bash
  3 #Filename: lamp.sh
  4 #Author: Zeng Qingfu
  5 #####
  6 if [ $# -ne 1 ];then
  7     echo '''
  8         Usage:input one option at a time;order to install lamp:first y,second a,third m,fourth p,fifth P,sixth o;
  9         Options:y[install yum and stop iptables,selinux];a[install httpd];m[install mysql];p[install php];o[djust httpd.conf,test,install phpMyAdmin];
 10     '''
 11         exit 1
 12 elif [ $# -eq 1 ];then
 13     if [ $1 != "a" -a $1 != "m" -a $1 != "p" -a $1 != "o" -a $1 != "y" -a $1 != "P" -o $1 == "h" ];then
 14          echo '''
 15              Usage:input one option at a time;order to install lamp:first y,second a,third m,fourth p,fifth o;
 16              Options:y[install yum and stop iptables,selinux];a[install httpd];m[install mysql];p[install php];o[djust httpd.conf,test,install phpMyAdmin];
 17          '''
 18         exit 1
 19     fi
 20 fi
 21 
 22 case $1 in
 23 
 24 y)
 25 ######stop  iptables and off selinux  and set yum repository################
 26 service iptables stop
 27 chkconfig iptables off
 28 setenforce 0
 29 sed -i '7 s/enforcing/disabled/' /etc/selinux/config
 30 umount /dev/cdrom
 31 mkdir -p /media/cdrom
 32 mount /dev/cdrom /media/cdrom
 33 cd /etc/yum.r*
 34 mkdir a
 35 mv C* a/
 36 /bin/cp a/*M* ./
 37 sed -i '20 s/0/1/' C*
 38 rpm --import /media/cdrom/*K*
 39 yum -y clean all
 40 yum makecache
 41 ;;
 42 #############################################################################
 43 
 44 a)
 45 echo "installing httpd"
 46 ##---------------install httpd------------------
 47     IP=$(hostname -I | awk '{print $1}')
 48     echo "$IP www.zengqingfu.com" >> /etc/hosts
 49     tar xf httpd-2.2.17.tar.gz -C /usr/src/
 50     rpm -qa make gcc gcc-c++
 51     if  [ $? -eq 0 ];then 
 52         cd /usr/src/httpd-2.2.17/
 53         ./configure --prefix=/usr/local/httpd  --enable-so --enable-rewrite --enable-charset-lite --enable-cgi &&make&&make install  &> /dev/null
 54     else
 55         yum -y install make gcc gcc-c++   &> /dev/null
 56         ./configure --prefix=/usr/local/httpd  --enable-so --enable-rewrite --enable-charset-lite --enable-cgi &&make&&make install  &> /dev/null
 57     fi
 58     ln -s /usr/local/httpd/bin/*  /usr/local/bin/
 59     /bin/cp /usr/local/httpd/bin/apachectl  /etc/init.d/httpd
 60     chmod +x /etc/init.d/httpd
 61     sed -i '1a#chkconfig: 35 85 21\n#description: Startup script for the Apache HTTP Server' /etc/init.d/httpd
 62     sed -n '1,3p' /etc/init.d/httpd
 63     chkconfig --add httpd
 64     chkconfig --list httpd
 65     cd  /usr/local/httpd/conf/
 66     /bin/cp httpd.conf httpd.conf.origin
 67     ROW=$(awk '/#ServerName/{print NR,$0}' httpd.conf | awk '{print $1}')
 68     sed -i "$ROW s/#//;s/example/zengqingfu/" httpd.conf
 69     apachectl -t
 70     [ $? -eq 0 ] && /etc/init.d/httpd start
 71     cat /usr/local/httpd/htdocs/index.html
 72 ;;
 73 
 74 m)
 75 echo "installing mysql"
 76 #########-------------------install mysql-------------------
 77     cd /root
 78     rpm -q mysql-server mysql
 79     rpm -e mysql --nodeps
 80     rpm -e mysql-server --nodeps
 81     rpm -q ncurses-devel
 82     [ $? -ne 0 ] && yum -y install ncurses-devel
 83     cd /root
 84     tar -xf cmake-2.8.6.tar.gz -C /usr/src/  
 85     cd /usr/src/cmake-2.8.6/
 86     ./configure && gmake && gmake install    &> /dev/null
 87     groupadd mysql
 88     useradd -M -s /sbin/nologin -g mysql mysql
 89     cd /root
 90     tar xf mysql-5.5.22.tar.gz -C /usr/src/
 91     cd /usr/src/mysql-5.5.22/
 92     cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci  -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc  && make && make install    &> /dev/null
 93     chown -R mysql:mysql /usr/local/mysql/
 94     cat support-files/my-medium.cnf > /etc/my.cnf
 95     /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/  --datadir=/usr/local/mysql/data/  --user=mysql        &> /dev/null
 96     echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
 97     source /etc/profile
 98     /bin/cp support-files/mysql.server /etc/init.d/mysqld
 99     chmod +x /etc/init.d/mysqld
100     chkconfig --add mysqld
101     /etc/init.d/mysqld start
102     netstat -anpt | grep mysqld
103     mysqladmin -uroot password "123456"
104     mysqladmin -uroot -p123456 password "zengqingfu";history -c
105 ;;
106 
107 p)
108 echo "installing php"
109 #####---------------------install php----------------------
110     rpm -q php && rpm -e php --nodeps
111     rpm -q php-cli && rpm -e php-cli --nodeps
112     rpm -q php-ldap && rpm -e php-ldap --nodeps
113     rpm -q php-common && rpm -e php-common -nodeps
114     rpm -q php-mysql  && rpm -e php-mysql --nodeps
115     rpm -q zlib-devel libxml2-devel  
116     if [ $? -ne 0 ];then
117         yum -y install zlib-devel libxml2-devel    
118     fi
119     cd /root
120     rpm -q libmcrypt || tar xf libmcrypt-2.5.8.tar.gz -C /usr/src/
121     cd /usr/src/libmcrypt-2.5.8/
122     ./configure &&make &&make install &> /dev/null
123     ln -s /usr/local/lib/libmcrypt* /usr/lib
124     cd /root
125     rpm -q mhash ||  tar xf mhash-0.9.9.9.tar.gz -C /usr/src/
126     cd /usr/src/mhash-0.9.9.9/
127     ./configure &&make&&make install  &> /dev/null
128     ln -s /usr/local/lib/libmhash.* /usr/lib/
129     cd /root
130     rpm -q mcrypt || tar xf mcrypt-2.6.8.tar.gz -C /usr/src/
131     cd /usr/src/mcrypt-2.6.8/
132     export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
133     ./configure &&make &&make install    &> /dev/null
134     cd /root
135     tar xf php-5.3.28.tar.gz -C /usr/src/
136     cd /usr/src/php-5.3.28/
137     ./configure --prefix=/usr/local/php5  --with-mcrypt  --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql/ --with-config-file-path=/usr/local/php5 --enable-mbstring && make && make install    &> /dev/null
138     /bin/cp -f php.ini-development /usr/local/php5/php.ini
139     cd /root
140     ROW=$(awk '/^short_open_tag/{print NR,$0}' /usr/local/php5/php.ini | awk '{print $1}') 
141     sed -i "$ROW s/Off/On/" /usr/local/php5/php.ini
142     ROW=$(awk '/default_charset/{print NR,$0}' /usr/local/php5/php.ini | awk '{if(NR==1)print $1}')
143     sed -i "$ROW s/;//;s/iso-8859-1/utf-8/" /usr/local/php5/php.ini 
144     cd /root
145     tar xf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src/
146     cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/
147     cd php-5.3.x/
148     /bin/cp ZendGuardLoader.so /usr/local/php5/lib/php/
149     echo -e "zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so\nzend_loader.enable=1" >> /usr/local/php5/php.ini
150     tail -2 /usr/local/php5/php.ini
151 
152 echo "adjust httpd.conf,test,install phpMyAdmin"
153 #############--------------------adjust httpd.conf---------------
154 ROW=$(awk '/LoadModule php5_module/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{print $1}')
155 sed -i "$ROW a AddType application/x-httpd-php .php" /usr/local/httpd/conf/httpd.conf
156 sed -n "$(($ROW+1)) p" /usr/local/httpd/conf/httpd.conf
157 ROW=$(awk '/DirectoryIndex/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{if(NR==2)print $1}')
158 sed -i "$ROW s/$/ index.php/" /usr/local/httpd/conf/httpd.conf
159 sed -n "$ROW p" /usr/local/httpd/conf/httpd.conf
160 httpd -t
161 [ $? -eq 0 ] && /etc/init.d/httpd restart
162 
163 ;;
164 
165 P)
166   cd /usr/src/php-5.3.28/
167   make install
168   /bin/cp -f php.ini-development /usr/local/php5/php.ini
169   cd /root
170   ROW=$(awk '/^short_open_tag/{print NR,$0}' /usr/local/php5/php.ini | awk '{print $1}') 
171   sed -i "$ROW s/Off/On/" /usr/local/php5/php.ini
172   ROW=$(awk '/default_charset/{print NR,$0}' /usr/local/php5/php.ini | awk '{if(NR==1)print $1}')
173   sed -i "$ROW s/;//;s/iso-8859-1/utf-8/" /usr/local/php5/php.ini 
174   cd /root
175   tar xf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src/
176   cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/
177   cd php-5.3.x/
178   /bin/cp ZendGuardLoader.so /usr/local/php5/lib/php/
179   echo -e "zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so\nzend_loader.enable=1" >> /usr/local/php5/php.ini
180   tail -2 /usr/local/php5/php.ini
181 
182 ROW=$(awk '/LoadModule php5_module/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{print $1}')
183 sed -i "$ROW a AddType application/x-httpd-php .php" /usr/local/httpd/conf/httpd.conf
184 sed -n "$(($ROW+1)) p" /usr/local/httpd/conf/httpd.conf
185 ROW=$(awk '/DirectoryIndex/{print NR,$0}' /usr/local/httpd/conf/httpd.conf | awk '{if(NR==2)print $1}')
186 sed -i "$ROW s/$/ index.php/" /usr/local/httpd/conf/httpd.conf
187 sed -n "$ROW p" /usr/local/httpd/conf/httpd.conf
188 httpd -t
189 [ $? -eq 0 ] && /etc/init.d/httpd restart
190 service httpd restart
191 ;;
192 
193 o)
194 ###########----------------------test---------------
195 cd /usr/local/httpd/htdocs/
196 echo -e "<?php\nphpinfo();\n?>" > test.php
197 echo -e "<?php\n\$link=mysql_connect('localhost','root','zengqingfu');\nif(\$link) echo 'Successfully connected mysql';\nmysql_close();\n?>" > test1.php 
198 ##############------install phpMyAdmin----------------
199 cd /root
200 tar xf phpMyAdmin-4.2.5-all-languages.tar.gz
201 mv phpMyAdmin-4.2.5-all-languages /usr/local/httpd/htdocs/phpMyAdmin
202 cd /usr/local/httpd/htdocs/phpMyAdmin/
203 /bin/cp config.sample.inc.php config.inc.php
204 
205 service httpd start
206 ;;
207 esac

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 1.DECODE 只有Oracle 才有,其它資料庫不支持; 2.CASE WHEN的用法, Oracle、SQL Server、 MySQL 都支持; 3.DECODE 只能用做相等判斷,但是可以配合sign函數進行大於,小於,等於的判斷,CASE when可用於=,>=,<,<=,<>,is n ...
  • 將大量數據保存起來,通過電腦加工而成的可以進行高效訪問的數據集合稱為資料庫(Database,DB)。將姓名、住址、電話號碼、郵箱地址、愛好和家庭構成等數據保存到資料庫中,就可以隨時迅速獲取想要的信息了。用來管理資料庫的電腦系統稱為資料庫管理系統(Database Management Syst... ...
  • pt-heartbeat是用來監控主從延遲的一款percona工具,現在我們大部分的MySQL架構還是基於主從複製,例如MHA,MMM,keepalived等解決方案。而主從環境的話,我們很關心的就是主從延遲的問題,一般情況下我們在從庫執行以下語句: mysql> show slave status ...
  • 由於最近工作要做MySQL集群,所以需要安裝MySQL,本機可以聯網,如不能聯網可參看rpm安裝方法,廢話不多,具體安裝步驟如下: 1,下載MySQL wget https://repo.mysql.com//mysql57-community-release-el6-11.noarch.rpm 2 ...
  • --查找存在某表名的存儲過程 SELECT distinct b.name from syscomments a,sysobjects b WHERE a.id=b.id and a.TEXT LIKE '%你要查找的表名%' --查找存在某內容的存儲過程SELECT NAME FROM sysob ...
  • [20170623]利用傳輸表空間恢複數據庫2.txt--//繼續上午的測試,測試truncate,是否可行,理論講應該沒有問題.我主要的目的測試是否要切換日誌.--//參考鏈接 : http://blog.itpub.net/267265/viewspace-2141166/1.環境:SCOTT@ ...
  • 一工廠的中控伺服器遇到了下麵Alert提示,'XXX\SERVERNAME$' XXX表示對應的功能變數名稱, SERVERNAME$(脫敏處理,SERVERNAME為具體的伺服器名稱+$),而且如下所示,客戶端是本機,研究了一下,才搞清楚具體原因. 日期/時間: 2017/6/20 12:24:51 說明... ...
  • create table DEPT ( deptno NUMBER(2) not null, dname VARCHAR2(20), loc VARCHAR2(13) ); alter table DEPT add constraint PK_DEPT primary key (DEPTNO); c ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...