在CentOS 7上搭建lamp環境

來源:互聯網
上載者:User

標籤:lamp centos7

在CentOS 7上安裝httpd、php、MariaDB,ServerIP 192.168.199.157

  1. 首先安裝相關程式包

650) this.width=650;" width="554" height="22" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

2.啟動httpd和mariadb

650) this.width=650;" width="554" height="21" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

3.查看各服務啟動情況

650) this.width=650;" width="554" height="83" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

80連接埠和3306連接埠都處於監聽狀態了

4.測試php

(1)編輯/etc/httpd/conf/httpd.conf檔案,在DirectoryIndex後面填寫index.php,定義預設首頁為index.php。

650) this.width=650;" width="554" height="114" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

(2)檢查設定檔是否有語法錯誤。

650) this.width=650;" width="554" height="36" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

(3)製作預設首頁index.php。

650) this.width=650;" width="516" height="31" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

650) this.width=650;" width="484" height="149" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

(4)重載httpd設定檔

650) this.width=650;" width="544" height="22" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

(5)開啟瀏覽器測試

650) this.width=650;" width="553" height="288" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

5.測試php與MariaDB的串連

(1)在MariaDB裡面建立資料庫testdb,建立使用者testuser,並給該使用者授權

650) this.width=650;" width="553" height="159" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

650) this.width=650;" width="554" height="32" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

650) this.width=650;" width="554" height="37" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

650) this.width=650;" width="374" height="49" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

(2)編輯預設首頁檔案index.php,寫一個指令碼進行測試

650) this.width=650;" width="554" height="136" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

(3)在瀏覽器上測試,如果出現OK則表示成功串連資料庫

650) this.width=650;" width="460" height="210" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

6.建立兩個基於FQDN的虛擬機器主機www1.magedu.com和www1.magedu.com。

650) this.width=650;" width="550" height="25" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

650) this.width=650;" width="514" height="120" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

650) this.width=650;" width="554" height="25" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

650) this.width=650;" width="521" height="108" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

650) this.width=650;" width="494" height="86" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

7.設定虛擬機器主機www1.magedu.com提供wordpress。

(1)下載wordpress並解壓,將解壓後的目錄內的所有檔案複製到/data/www1目錄下。

650) this.width=650;" width="554" height="29" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

650) this.width=650;" width="487" height="27" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

(2)將/data/www1/目錄下的wp-config-sample.php改名為wp-config.php。

650) this.width=650;" width="553" height="18" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

(3)編輯wp-config.php,修改資料庫名,資料庫使用者名稱,資料庫密碼,主機IP等資訊。

650) this.width=650;" width="367" height="207" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

(4)測試wordpress,佈建網站名及登入帳號、密碼、郵箱等資訊即可使用了。

650) this.width=650;" width="511" height="385" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

8.設定虛擬機器主機www2.magedu.com提供phpMyAdmin。

(1)下載並解壓phpMyAdmin,將phpMyAdmin目錄中的檔案複製到/data/www2目錄中。

650) this.width=650;" width="553" height="17" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

(2)將config.sample.inc.php改名為config.inc.php

650) this.width=650;" width="554" height="23" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

(3)編輯config.inc.php檔案,用openssl產生的隨機碼填充blowfish_secret欄位。

650) this.width=650;" width="442" height="31" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

(4)編輯config.inc.php檔案,修改[‘Servers‘][$i][‘host‘]欄位的IP地址為127.0.0.1。

650) this.width=650;" width="431" height="25" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/themes/default/images/word.gif") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

(5)在瀏覽器裡測試www2.magedu.com能否開啟。

650) this.width=650;" width="554" height="408" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />


在CentOS 7上搭建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.