安裝Ubuntu 11.10 Desktop 32bit
安裝 apache2、php5、openssl、libssl-dev、gcc編譯器與開發庫、gd開發庫、php、php-apache、php相關的插件
可以用apt-get命令來安裝這些軟件包,鍵入命令:
sudo apt-get install apache2
sudo apt-get install build-essential
sudo apt-get install libgd2-xpm-dev
sudo apt-get install openssl
sudo apt-get install libssl-dev
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5 (這個可能在安裝php5的時候就已經安裝,如果安裝就 不需要安裝啦)
sudo apt-get install libjpeg8
sudo apt-get install libjpeg8-dev
sudo apt-get install curl
sudo apt-get install libcurl3
sudo apt-get install libpng12-0
sudo apt-get install libpng12-dev
sudo apt-get install freetype2-demos
sudo apt-get install libfreetype6
sudo apt-get install libxml2
sudo apt-get install libxml2-dev
配置apache
如果默認沒有安裝vim編輯器,先安裝vim,因為默認的vi編輯器在ubuntu裡相當的惡心
sudo apt-get install vim
sudo vim /etc/apache2/apache2.conf
按shift-g,也就是G,到篇尾,添加如下配置
AddType application/x-httpd-php .php .htm .html
AddDefaultCharset UTF-8
DirectoryIndexindex.php index.html index.html
啟動apache服務
sudo /etc/init.d/apache2 start
使用chkconfig工具設為隨機自啟動,如果沒有安裝chkconfig則先安裝chkconfig
sudo apt-get install chkconfig
sudo update-rc.d apache2 defaults
sudochkconfig apache2 on
測試php是否解析正常
在shell裡切換到/var/www目錄下
cd /var/www
清空裡面的文件
rm -rf *
新建測試頁面
vimindex.php
<?php
phpinfo();
?>
退出並保存
打開浏覽器測試:
http://localhost
是否正常顯示php的信息