欢迎光临
我们一直在努力

Apache2.0也能跑PHP3和PHP4-PHP教程,PHP应用

建站超值云服务器,限时71元/月

    apache作为应用最广泛的web服务器工具,其升级很迅速。一些能在apache 1.0中运行的模块,在apache 2.0中往往需要换一种方式才能运行,比如php3和php4。原来在apache 1.0中运行php3和php4,只需要在/etc/httpd/conf/httpd.conf文件里做个简单的修改就可以运行。可是apache 2.0把这些外挂的模块都移到/etc/httpd/conf.d文件里面了。下面就介绍如何通过修改conf.d文件让apache 2.0也能跑php3和php4。

    实现步骤

    1.用户需要下载httpd-2.0.tar.gz和php-4.0.tar.gz两个软件包,然后按下面的命令安装apache2.0的web服务器:

# tar zxvf apache2.0.tar.gz  
# cd httpd-2.0 
# ./configure 
# make 
# make install

    2.安装php4的代码。注意,下面的命令中不可缺少 “–with-apxs2=/usr/local/apache2/bin/apxs”。它的作用是利用让php以动态模块的方式安装到apache服务器下。

# tar zxvf php-4.x.tar.gz 
#cd php-4.x 
#./configure --with-apxs2=/usr/local/apache2/bin/apxs 
--enable-versioning --disable-debug --enable-track-vars 
# make 
# make install

    3.设置apache服务器的配置文件httpd.conf。用户把文件中“#listen ………:80”中的“……”改为用户的ip地址,同时把前面的“#”去掉。

    4.编辑/etc/httpd/conf.d/php.conf文件。注意下面代码中以加底线显示的这两行。它的作用是让apache“知道”哪些是php3和php4文件,并对此文件进行解释。编辑后,保存退出就可以了。

# cd /etc/httpd/conf.d/
# vi php.conf
# php is an html-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
loadmodule php4_module modules/libphp4.so
addtype application/x-httpd-php .php .php4 .php3 .phtml
addtype application/x-httpd-php-source .phps
#
# cause the php interpreter handle files with a .php extension.
#
<files *.php>
    setoutputfilter php
    setinputfilter php
    limitrequestbody 524288
</files>
#
# add index.php to the list of files that will be served as directory
# indexes.
#
directoryindex index.php

    5.完成后利用下面的代码让apache重启,就大功告成了。
    # service httpd restart

    检测实现效果

    用户可以编写一个简单的php文件,进行测试apache 2.0上能否跑php3和php4。首先在/usr/local/apache/htdocs目录下创造一个test.php的文件,内容是“”,保存后退出。然后在浏览器中输入http://用户的ip地址/test.php,如果用户能看到php的表和相关信息,那么再运行php3和php4的文件就没有问题了。

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » Apache2.0也能跑PHP3和PHP4-PHP教程,PHP应用
分享到: 更多 (0)