標籤:管理系統 軟體包 設定檔 資料加密 資料庫服務
具體操作:
1. 準備工作
為了避免發生程式衝突等現象,建議先將rpm方式安裝的php及相關依賴包(如果有的話)卸載。
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image002" border="0" alt="clip_image002" src="http://s3.51cto.com/wyfs02/M00/74/E5/wKiom1Ytu1TSwvaRAAAxscobriE467.jpg" height="34" />
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image004" border="0" alt="clip_image004" src="http://s3.51cto.com/wyfs02/M01/74/E5/wKiom1Ytu1TCB6U4AABUZ94ZmY0667.jpg" height="72" />
2. 安裝擴充工具庫
在實際公司專屬應用程式中,一部分基於PHP開發的Web應用系統需要額外的擴充工具,如資料加密工具libmcrypt、mhash、mcrypt等(可以從網站sf.net下載)。安裝php軟體包之前,應先安裝好這些擴充工具程式。
1) 安裝libmcrypt
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image006" border="0" alt="clip_image006" src="http://s3.51cto.com/wyfs02/M02/74/E5/wKiom1Ytu1WCcX-DAAENpXgP-VY456.jpg" height="142" />650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image008" border="0" alt="clip_image008" src="http://s3.51cto.com/wyfs02/M00/74/E5/wKiom1Ytu1WCJlfpAAAhk5OEnmo985.jpg" height="21" />650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image010" border="0" alt="clip_image010" src="http://s3.51cto.com/wyfs02/M01/74/E5/wKiom1Ytu1bzz0o9AAAtDLCpsOQ808.jpg" height="21" />
2) 安裝mhash
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image012" border="0" alt="clip_image012" src="http://s3.51cto.com/wyfs02/M02/74/E5/wKiom1Ytu1awG-i1AABJzDZ78_4825.jpg" height="44" />650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image014" border="0" alt="clip_image014" src="http://s3.51cto.com/wyfs02/M00/74/E5/wKiom1Ytu1ejegQsAAAhbcwx5mQ369.jpg" height="21" />650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image016" border="0" alt="clip_image016" src="http://s3.51cto.com/wyfs02/M00/74/E5/wKiom1Ytu1eDMbDUAAAq_-S1j8g688.jpg" height="21" />
3) 安裝mcrypt:
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image018" border="0" alt="clip_image018" src="http://s3.51cto.com/wyfs02/M01/74/E5/wKiom1Ytu1iyT9D6AABVBQ1w_Zw289.jpg" height="61" />
3. 編譯安裝PHP
1) 解包
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image020" border="0" alt="clip_image020" src="http://s3.51cto.com/wyfs02/M01/74/E5/wKiom1Ytu1mgdGYQAADJXDnTQo8865.jpg" height="107" />
2) 配置
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image022" border="0" alt="clip_image022" src="http://s3.51cto.com/wyfs02/M02/74/E5/wKiom1Ytu1myvEAwAABf2EgB-54615.jpg" height="45" />
? --prefix:指定將PHP程式安裝到哪個目錄。
? --with-mcrypt:載入資料加密等擴充工具支援。
? --with-apxs2:設定“Apache HTTP Server”提供的apxs模組支援程式的檔案設定。
? --with-mysql:設定MySQL資料庫服務程式的安裝位置。
? --with-config-file-path:設定PHP的設定檔php.ini將要存放的位置。
? --enable-mbstring:啟用多位元組字串功能,以便支援中文等代碼。
如果配置出現錯誤,可能是缺少一個網頁格式xml,安裝即可,然後重新再配置一次。:
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image024" border="0" alt="clip_image024" src="http://s3.51cto.com/wyfs02/M02/74/E2/wKioL1Ytu4uitl4HAAAdXehKMmQ033.jpg" height="22" />
3) 編譯及安裝
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image026" border="0" alt="clip_image026" src="http://s3.51cto.com/wyfs02/M01/74/E2/wKioL1Ytu4uz5WZsAAAe_RiyiLI544.jpg" height="21" />
n 設定LAMP組件環境
1. php.ini配置調整
安裝好php軟體包以後,伺服器並不會自動建立php.ini設定檔,但在源碼目錄下提供了兩份範例設定檔,分別對應於開發環境、生產環境。
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image028" border="0" alt="clip_image028" src="http://s3.51cto.com/wyfs02/M00/74/E5/wKiom1Ytu1vySZoiAABgVOCrZgg731.jpg" height="55" />
選擇其中一個範例檔案,並複製到PHP的設定檔目錄(應確保與configure步驟中指定的路徑一致),並改名為php.ini。在php.ini設定檔中,以分號開頭的內容表示注釋資訊。
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image030" border="0" alt="clip_image030" src="http://s3.51cto.com/wyfs02/M01/74/E5/wKiom1Ytu1vxp50bAADWVe_2_-M105.jpg" height="226" />
通過修改php.ini檔案中的配置內容,可以控制PHP網頁的執行特性。如是否允許使用者上傳檔案、設定上傳檔案的大小限制、設定預設使用的字元集、載入額外的擴充模組等。如果沒有特別要求,可以直接沿用預設配置,不做任何修改。
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image032" border="0" alt="clip_image032" src="http://s3.51cto.com/wyfs02/M02/74/E5/wKiom1Ytu1zxf1aTAAAdlbo1i4o930.jpg" height="23" />650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image034" border="0" alt="clip_image034" src="http://s3.51cto.com/wyfs02/M02/74/E2/wKioL1Ytu46TD355AAB86wOAPPE011.jpg" height="97" />
為了進一步提高PHP程式的執行效率,最佳化頁面載入速度,可以為PHP添加Zend公司開發的ZendGuardLoader最佳化模組。若需要加密PHP代碼以限制未經授權的分支,還可以購買該公司的ZendGuard軟體。
首先將下載的ZendGuardLoader包釋放,並將其中php-5.3.x目錄下的模組檔案複製到PHP程式的模組檔案夾。
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image036" border="0" alt="clip_image036" src="http://s3.51cto.com/wyfs02/M00/74/E2/wKioL1Ytu4-xxxsqAAEOorssnF0767.jpg" height="143" />
然後修改php.ini設定檔,添加載入及啟用ZendGuardLoader.so模組的配置語句。
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image038" border="0" alt="clip_image038" src="http://s3.51cto.com/wyfs02/M01/74/E2/wKioL1Ytu4_yPBrtAAAi6bbBprM634.jpg" height="21" />650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image040" border="0" alt="clip_image040" src="http://s3.51cto.com/wyfs02/M02/74/E5/wKiom1Ytu17DVVccAAAzgbohSWQ398.jpg" height="31" />
2. httpd.conf配置調整
要讓httpd伺服器支援PHP頁面解析功能,需通過LoadModule配置項載入PHP程式的模組檔案,並通過AddType配置項添加對“.php”類型網頁檔案的支援。除此以外,還應修改DirectoryIndex配置行,添加“index.php”項,以識別常見的PHP首頁檔案。
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image042" border="0" alt="clip_image042" src="http://s3.51cto.com/wyfs02/M00/74/E5/wKiom1Ytu16yf1bzAAAi2fnHmWw858.jpg" height="21" />
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image044" border="0" alt="clip_image044" src="http://s3.51cto.com/wyfs02/M02/74/E5/wKiom1Ytu1-SgteSAAA7RMZ8xLM805.jpg" height="46" />650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image046" border="0" alt="clip_image046" src="http://s3.51cto.com/wyfs02/M01/74/E2/wKioL1Ytu5HBEQ0-AAAkWmfLuNU672.jpg" height="21" />
在上述配置內容中,LoadModule行應該會在安裝php的過程中自動添加,其中的“php5_module”表示模組名稱;“module/libphp5.so”是模組檔案位置。而AddType行需要手動添加,DirectoryIndex行在原有基礎上對其進行修改即可。
n 測試LAMP協同工作
1. 測試PHP網頁能否正確顯示
編寫一個“.php” 格式的測試網頁檔案,使用PHP內建的“phpinfo()”函數顯示伺服器的PHP環境資訊,PHP代碼應包括在“<?php…?>”標記之間。將測試檔案放置到網站根目錄下。
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image048" border="0" alt="clip_image048" src="http://s3.51cto.com/wyfs02/M02/74/E2/wKioL1Ytu5Hi_Q7TAAAi7wr9Fp4758.jpg" height="23" />650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image050" border="0" alt="clip_image050" src="http://s3.51cto.com/wyfs02/M00/74/E5/wKiom1Ytu2CRfVj7AAAUkF_kT3Q805.jpg" height="44" />
然後通過瀏覽器訪問,,若能看到PHP程式的版本號碼、配置命令、運行變數等相關資訊,表示此Web伺服器已經能正常顯示PHP網頁。若還能看到Zend引擎相關資訊,則表示ZendGuardLoader模組也已啟用成功。
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image052" border="0" alt="clip_image052" src="http://s3.51cto.com/wyfs02/M01/74/E5/wKiom1Ytu2HgQfRgAAHiM1_4ljI297.jpg" height="390" />
2. 測試PHP網頁能否訪問MySQL資料庫
再編寫一個測試網頁檔案,添加簡單的資料庫操作命令,用於驗證與MySQL伺服器的串連、查詢等操作。其中,“mysql_connect()”函數用於串連MySQL資料庫,需要指定目標主機地址,以及授權訪問的使用者名稱、密碼。
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image054" border="0" alt="clip_image054" src="http://s3.51cto.com/wyfs02/M02/74/E5/wKiom1Ytu2GTtVTFAAAiw-TlKTE569.jpg" height="22" />650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image056" border="0" alt="clip_image056" src="http://s3.51cto.com/wyfs02/M02/74/E2/wKioL1Ytu5PwtexvAABH-0ngemw479.jpg" height="70" />
然後通過瀏覽器訪問測試網頁,若能看到成功串連的提示資訊,,則表示能夠通過PHP網頁訪問MySQL資料庫。當使用了錯誤的使用者名稱、密碼,或者因mysqld未運行而導致串連失敗時,執行時將會報錯。650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image058" border="0" alt="clip_image058" src="http://s3.51cto.com/wyfs02/M00/74/E2/wKioL1Ytu5PgGn2MAADSNIPS2ls284.jpg" height="177" />
n 部署phpMyAdmin系統
phpMyAdmin是一個使用php語言編寫,用來管理MySQL資料庫的Web應用系統。通過該套件提供的網頁介面,即便是對SQL語句不太熟悉的人,也能夠非常容易的對MySQL資料庫進行管理和維護。
1. 解包並複製到網站目錄
對於大部分PHP應用系統來說,只需要解包後複製到網站目錄下即可完成部署,之後再根據需要調整配置,或者訪問安裝頁面以完成進一步的安裝。
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image060" border="0" alt="clip_image060" src="http://s3.51cto.com/wyfs02/M02/74/E5/wKiom1Ytu2PgEbIjAAFAynAEBoM418.jpg" height="202" />
2. 建立設定檔config.inc.php
將phpMyAdmin套件複製到網站目錄以後,還需要建立設定檔方可正常使用。預設提供的範例設定檔為config.sample.inc,需要參照該檔案內容建立config.inc.php設定檔。尋找並修改設定檔中的“blowfish_secret”行,並設定一個短語密鑰(此密鑰用於網頁cookie認證,不需要使用者記憶)。
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image062" border="0" alt="clip_image062" src="http://s3.51cto.com/wyfs02/M00/74/E2/wKioL1Ytu5Wy-JHDAABOyC6ZNS4959.jpg" height="47" />650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image064" border="0" alt="clip_image064" src="http://s3.51cto.com/wyfs02/M01/74/E2/wKioL1Ytu5WTkthkAAAfGClc8AA791.jpg" height="40" />
3. 訪問phpMyAdmin的Web管理介面
在瀏覽器中訪問http://192.168.10.10/phpMyAdmin/,如果能夠看到phpMyAdmin系統的登入介面,,則表示部署成功。使用MySQL資料庫的使用者(不能是密碼為空白的使用者)登入後,即可在授權範圍內對資料庫進行管理。
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image066" border="0" alt="clip_image066" src="http://s3.51cto.com/wyfs02/M02/74/E2/wKioL1Ytu5aQlXjsAAFGhJ8ZbJ0220.jpg" height="390" />
phpMyAdmin系統預設使用cookie認證方式,在首次訪問時頁面下方可能會提示“必須啟用Cookies才能登入”,要求客戶機的瀏覽器啟用cookies機制。實際上大多數瀏覽器預設都是支援cookies的,因此按F5鍵重新整理頁面後該提示資訊即會消失。
4. 使用phpMyAdmin系統
需要使用phpMyAdmin系統時,應先通過MySQL伺服器中授權的資料庫使用者(如root)進行登入,認證成功後可以看到管理介面,。通過phpMyAdmin套件,使用者可以在授權的範圍內執行各種資料庫管理操作,使介面更加直觀、友好、大大降低了遠程維護MySQL資料庫伺服器的難度。
650) this.width=650;" style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image068" border="0" alt="clip_image068" src="http://s3.51cto.com/wyfs02/M00/74/E5/wKiom1Ytu2Wy9L3mAAJGuJoPBoM697.jpg" height="391" />
本文出自 “王高利” 部落格,請務必保留此出處http://wanggaoli.blog.51cto.com/10422005/1706322
搭建PHP(LAMP),安裝zend最佳化解析速度,並在其平台上搭建phpmyadmin管理系統,以頁面方式管理mysql