1:首先安裝apache:打開終端(ctrl+Alt+t),
輸入命令:sudo apt-get install apache2即可安裝,
root@IGW:~# apt-get install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libaprutil1-dbd-sqlite3 libaprutil1-ldap
Suggested packages:
www-browser apache2-doc apache2-suexec apache2-suexec-custom
The following NEW packages will be installed:
apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libaprutil1-dbd-sqlite3 libaprutil1-ldap
0 upgraded, 7 newly installed, 0 to remove and 150 not upgraded.
Need to get 1,679 kB of archives.
After this operation, 5,067 kB of additional disk space will be used.
Do you want to continue [Y/n]?
安裝完后,打開瀏覽器,在地址欄輸入:localhost或者h(yuǎn)ttp://127.0.0.1
看到It works,表示安裝成功!
2:安裝mysql:
sudo apt-get install mysql-server-5.5(網(wǎng)上參考是5.0)下載有97MB
安裝完后,會要你新設(shè)置mysql root密碼,輸入你自己的密碼后enter鍵,再確認(rèn)密碼。
3:安裝PHP 5 and Apache PHP 5 module:
sudo apt-get install php5 libapache2-mod-php5
sudo /etc/init.d/apache2 restart(重啟apache)
試試成功否:
命令:gksudo gedit /var/www/text.php 【在apache默認(rèn)根目錄/var/www/下創(chuàng)建一text.php文件】
在text.php文件中輸入以下代碼檢驗是否安裝成功:
- <?php
- echo “helloworld”;
- ?>
在瀏覽器地址欄輸入:http://localhost/text.php 如果頁面顯示helloworld則表示成功
溫馨提示:如果返回終端時無法再次輸入命令時,按ctrl+z組合鍵
4:讓apache和php支持php :
sudo apt-get install libapache2-mod-auth-mysql
sudo apt-get install php5-mysql
至此環(huán)境已搭建完!
/var/www/(apache2網(wǎng)頁文件放在這里)
/var/lib/mysql(mysql文件放在這里)
如果你要遠(yuǎn)程連接的話,還要安裝SSH,命令:sudo apt-get install ssh
可能我們還是習(xí)慣用phpmyadmin
5:安裝phpmyadmin
此時在瀏覽器上輸入:http://localhost/phpmyadmin 可以打開(網(wǎng)上參考發(fā)現(xiàn)not found)
所以我們還必須把安裝好到phpmyadmin文件夾轉(zhuǎn)移到/var/www/下面
sudo ln -s /usr/share/phpmyadmin/ /var/www/
執(zhí)行上面到命令,我們已經(jīng)把phpmyadmin文件夾轉(zhuǎn)移到目的地了,也或者你把phpmyadmin直接復(fù)制到/var/www/的文件夾下面也可以。
原文:http://blog.csdn.net/guaikai/article/details/6905781
【編輯推薦】
聯(lián)系客服