linux下安裝apache php的方法:首先下載「httpd-2.2.11」並解壓安裝包 ;然後通過「make install」進行編譯安裝;接著下載php並進行編譯安裝;最後修改組態檔即可。
linux下安裝apache+PHP過程
安裝apache過程總結
安裝httpd-2.2.11
下載地址:http://archive.apache.org/dist/httpd/
安裝過程
[[email protected] /]# rpm -qa |grep httpd httpd-manual-2.0.52-32.ent httpd-suexec-2.0.52-32.ent system-config-httpd-1.3.1-1 httpd-2.0.52-32.ent //檢視本機是否已經安裝httpd [[email protected] /]# rpm -e httpd --nodeps //刪除本機存在的httpd [[email protected] tmp]# tar zxvf httpd-2.2.11.tar.gz //解壓安裝包 [[email protected] tmp]# cd httpd-2.2.11 //進入httpd-2.2.11 [[email protected] httpd-2.2.11]# ./configure --prefix=/usr/local/apache --enable-s0 //檢測程式, --prefix 軟體要安裝的路徑–enable-so表示讓apache核心裝載DSO,但是不實際編譯任何動態模組 [[email protected] httpd-2.2.11]# make //編譯 [[email protected] httpd-2.2.11]# make install //編譯後安裝
安裝 php-5.2.9
下載地址:http://cn.php.net/downloads.php
注意:安裝php-5.2.9之前,png,gd,freetype,zlib,mysql,openssl都存在,若不存在,手動安裝一下
安裝過程
[[email protected] tmp]# tar zxvf php-5.2.9.tar.gz [[email protected] tmp]#cd php-5.2.9.tar.gz [[email protected] php-5.2.9]#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-png-dir --with-gd --with-freetype-dir --with-zlib --with-mysql=/usr/local/mysql --with-openssl --with-gettext -enable-sockets //檢測程式,並同時載入相關引數 [[email protected] php-5.2.9]#make && make install //編譯安裝 [[email protected] php-5.2.9]#cp php.ini-recommended /usr/local/php/lib/php.ini //拷貝php.ini檔案啟動時會讀取到的組態檔 [[email protected] php-5.2.9]#ln -s /usr/local/php/bin/* /usr/local/bin/ //連線 [email protected] php-5.2.9]#lvi /usr/local/apache/conf/httpd.conf //修改組態檔
新增
AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php AddType p_w_picpath/x-icon .ico
新增
index.php index.html index.html.var <IfModule dir_module> DirectoryIndex index.html index.php index.html index.html.var </IfModule>
測試:
[[email protected] ]#vi /usr/local/apache/htdocs/test.php //新建test.php
在新檔案中新增
<?php phpinfo(); ?>
wq儲存退出
Phpinfo是特殊的php函數,可以顯示目前伺服器內php模組的相關核心資料
[[email protected] ]## /usr/local/apache/bin/apachectl –k stop [[email protected] ]##/usr/local/apache/bin/apachectl –k start //重新啟動apache
在瀏覽器中輸入主機地址例如http://主機IP/test.php如有出現下面圖片就說明apace安裝成功
以上就是linux下如何安裝apache php的詳細內容,更多請關注TW511.COM其它相關文章!