PHP安装运行

【php靠什么运行】

tomcat是servlet容器,tomcat只能支持servlet/jsp标准,并不支持php。apache httpd是个web server和http反向代理,可以支持第三方的插件modules,因此要在apache下运行php,必须加载php5_module这么个插件。

 

在httpd.conf中配置php5_module以支持php

(1)让apache加载php5_module插件;//必选

#
# PHP enable for apache 2.2 version
#
LoadModule php5_module mod_php/php5apache2_2.dll     (php安装在相对目录mod_php下)
#specify the config file php.ini for PHP
PHPIniDir "mod_php/"           (指定php.ini配置文件所在的目录,也就是mod_php)

 

(2)增加可处理的类型,这样在*.php的文件里则可以执行php的代码;//必选

#
#make *.php executed by mod_php
#added by [email protected] on 2009-07-02
#
AddType application/x-httpd-php .php

 

(3)默认文件增加一种index.php  //可选

# index.php added by [email protected] on 2009-07-02
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

 

(4)在htdocs目录下,创建一个index.php的文档,内容为:

<html>
   <head><title>php测试</title></head>
     <?php
       phpinfo();
     ?>
</html>

 

(5)在urlworkermap.properties配置文件中写上

/*=lbcontroller    (表示一般的请求,比如*.jsp,*.do 都交给负载均衡器来处理,通过httpd分发到后面的tomcat)
/jkstatus=jkmonitor   (jk状态监控交给jkmonitor这个worker来处理,不需要分发给后面的tomcat)

 

#httpd can process *.php and *.html requests
!/*.php=lbcontroller       (*.php也不需要负载均衡器来处理,直接由httpd处理即可。)
!/*.html=lbcontroller

 

(6)访问http://localhost/index.php,显示:

PHP Version 5.2.10

 

System Windows NT LIWEI2 5.1 build 2600
Build Date Jun 17 2009 16:16:01
Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--with-snapshot-template=d:\php-sdk\snap_5_2\vc6\x86\template" "--with-php-build=d:\php-sdk\snap_5_2\vc6\x86\php_build" "--with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared"
Server API Apache 2.0 Handler
Virtual Directory Support enabled

 

类似页面

 

 

====================================================================

【参考资料】

1、http://hi.baidu.com/nainiu/blog/item/bc372c736419871b8601b0d4.html   Windows下Apache+Tomcat+MySQL+jsp+php的服务器整合配置经验总结

2、http://yl8822.blog.163.com/blog/static/8742382200775358340/   Apache+php+mysql在windows下的安装与配置

 

====================================================================

【附录  httpd.conf配置内容常识】

httpd.conf文件
     apache的配置文件是httpd.conf,位于apache根目录的下的conf文件夹下
    (1).修改默认网站根目录
       在d:\server下建立文件夹www,以此作为网站的根目录
       DocumentRoot "D:/server/Apache Group/Apache2/htdocs"      (因为在htdocs目录下有个index.html中写着“it works”,这就是为什么我们初次访问httpd时显示"it works"的原因。)
       改为DocumentRoot "D:/server/www
    (2).修改字符设置
      apache解析中文网页时会产生乱码,
      修改AddDefaultCharset ISO-8859-1为AddDefaultCharset GB2312
    (3).修改默认主页
       当访问目录时,apache会自动导入的主页,优先级以先后顺序为准
       把DirectoryIndex index.html index.html.va r改为
       DirectoryIndex index.html index.jsp index.php default.jsp default.php index.html.var
    (4).设置错误页面
      这样对于你的网站会更安全些,如果没设置,别人在你的网址后随便输入一个路径,会显示404错
    误,并且会显示你的服务器版本号,服务器配置一目了然,为了避免这种情况,可以设置错误页面。
      当出现404错误,即找不到网页时,把访问者导入到一个错误页面

 

你可能感兴趣的:(apache,oracle,tomcat,PHP,jsp)