先安装libxml
# tar -zxf libxml2-2.6.16.tar.gz
# cd libxml2-2.6.16
# ./configure (xml默认安装就可以,不要指定路径了,因为安装时php可能找不到它,PHP5只支持libxml2-2.5.10以上版本)
# make
# make install
PHP v5.0.3 For Linux
PHP是一种新型的CGI程序编写语言,易学易用,运行速度快,可以方便快捷地编写出功能强大,运行速度快,并可同时运行于Windows、Unix、 Linux 平台的Web后台程序。
下载地址:
http://down.chinaz.com/S/7001.asp
http://www.php.net/downloads.php
1、解压缩文件至/usr/local/src/
2、进入目录
#cd /usr/local/src/php-5.0.3
3、配置
#./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql --with-mail --with-apxs2=/usr/local/apache/bin/apxs
4、编译
#make
5、安装
#make install
6、复制php.ini文件
#cp php.ini-dist /usr/local/lib/php.ini
7、编辑/usr/local/apache/conf/httpd.conf
(1)397附近DirectoryIndex行中加入index.php,变成:
代码: |
DirectoryIndex index.php index.html index.html.var index.htm |
(2)827附近的#AddType application/x-tar .tgz下方加入两行:
代码: |
AddType application/x-httpd-php .php .phtml AddType application/x-httpd-php-source .phps |
8、测试
(1)删除/var/www/html/下index.*文件,编辑index.php保存到这里,内容为:
代码: |
<? phpinfo(); ?> |
(2)重启web服务器
#httpd -k stop
#httpd -k start
(3)Firefox地址栏输入http://localhost/,回车。
关于php乱码问题:在/etc/ 下 编辑php.ini <命令:vi php .ini> 找到 ;default_charset = "iso-8859-1"
下面添加或者改为:default_charset = "gb2312"