让php5.2和php5.3共存于一个Apache中(Windows)

来源:互联网 发布:北大荒网络广播电视台 编辑:程序博客网 时间:2024/04/30 05:06

1、从http://httpd.apache.org/download.cgi下载apache2.2.15(目前最新的稳定版本),如果你需要SSL,就下载带SSL的版本。

2、从http://www.php.net/(http://windows.php.net/download/)下载php5.2.13和php5.3.2(目前最新版本),使用apache做WEB服务的,用VC6 X86版本。至于是否用线程安全的版本。自己确定。

3、从http://www.apache.org/dist/httpd ... 2.3.5-win32-x86.zip下载fastcgi的apache2.2版本。

4、安装apache服务器!具体的过程就是下一步,WINDOWS下的标准安装。

5、解压php5.2和php5.3到D盘。将PHP5.2下的php.ini-dist和php5.3下的php.ini-production分别重命名为php.ini。

6、解压mod_fcgid-2.3.5-win32-x86.zip,将解压后的mod_fcgid.so文件拷贝到APACHE安装目录的modules目录下。

7、修改apache安装目录下conf目录下的httpd.conf文件,支持php5.2和php5.3,具体修改如下:

(1)、在LoadModule块添加LoadModule php5_module D:/Php52/php5apache2_2.dll,支持php5.2; 指定phpini的目录PHPIniDir "D:/PHP52" 添加对.php文件的解析:AddType application/x-httpd-php .php

(2)、使用fastcgi解析PHP5.3。 在LoadModule添加:LoadModule fcgid_module modules/mod_fcgid.so 让apache支持fastcgi模块 AddHandler fcgid-script .phtml FCGIWrapper "D:/php53/php-cgi.exe" .phtml

(3)为了区别php5.2和php5.3,两个解析的扩展名不一样;php为php5.2,而phtml为php5.3

 

 

 

 

 

我的httpd.conf文件的完整文件内容如下:

  1. #
  2. # This is the main Apache HTTP server configuration file.  It contains the
  3. # configuration directives that give the server its instructions.
  4. # See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
  5. # In particular, see
  6. # <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
  7. # for a discussion of each configuration directive.
  8. #
  9. # Do NOT simply read the instructions in here without understanding
  10. # what they do.  They're here only as hints or reminders.  If you are unsure
  11. # consult the online docs. You have been warned.  
  12. #
  13. # Configuration and logfile names: If the filenames you specify for many
  14. # of the server's control files begin with "/" (or "drive:/" for Win32), the
  15. # server will use that explicit path.  If the filenames do *not* begin
  16. # with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
  17. # with ServerRoot set to "D:/Program Files/Apache Software Foundation/Apache2.2" will be interpreted by the
  18. # server as "D:/Program Files/Apache Software Foundation/Apache2.2/logs/foo.log".
  19. #
  20. # NOTE: Where filenames are specified, you must use forward slashes
  21. # instead of backslashes (e.g., "c:/apache" instead of "c:/apache").
  22. # If a drive letter is omitted, the drive on which httpd.exe is located
  23. # will be used by default.  It is recommended that you always supply
  24. # an explicit drive letter in absolute paths to avoid confusion.
  25. #
  26. # ServerRoot: The top of the directory tree under which the server's
  27. # configuration, error, and log files are kept.
  28. #
  29. # Do not add a slash at the end of the directory path.  If you point
  30. # ServerRoot at a non-local disk, be sure to point the LockFile directive
  31. # at a local disk.  If you wish to share the same ServerRoot for multiple
  32. # httpd daemons, you will need to change at least LockFile and PidFile.
  33. #
  34. ServerRoot "D:/Program Files/Apache Software Foundation/Apache2.2"
  35. #
  36. # Listen: Allows you to bind Apache to specific IP addresses and/or
  37. # ports, instead of the default. See also the <VirtualHost>
  38. # directive.
  39. #
  40. # Change this to Listen on specific IP addresses as shown below to
  41. # prevent Apache from glomming onto all bound IP addresses.
  42. #
  43. #Listen 12.34.56.78:80
  44. Listen 80
  45. #
  46. # Dynamic Shared Object (DSO) Support
  47. #
  48. # To be able to use the functionality of a module which was built as a DSO you
  49. # have to place corresponding `LoadModule' lines at this location so the
  50. # directives contained in it are actually available _before_ they are used.
  51. # Statically compiled modules (those listed by `httpd -l') do not need
  52. # to be loaded here.
  53. #
  54. # Example:
  55. # LoadModule foo_module modules/mod_foo.so
  56. #
  57. LoadModule actions_module modules/mod_actions.so
  58. LoadModule alias_module modules/mod_alias.so
  59. LoadModule asis_module modules/mod_asis.so
  60. LoadModule auth_basic_module modules/mod_auth_basic.so
  61. #LoadModule auth_digest_module modules/mod_auth_digest.so
  62. #LoadModule authn_alias_module modules/mod_authn_alias.so
  63. #LoadModule authn_anon_module modules/mod_authn_anon.so
  64. #LoadModule authn_dbd_module modules/mod_authn_dbd.so
  65. #LoadModule authn_dbm_module modules/mod_authn_dbm.so
  66. LoadModule authn_default_module modules/mod_authn_default.so
  67. LoadModule authn_file_module modules/mod_authn_file.so
  68. #LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
  69. #LoadModule authz_dbm_module modules/mod_authz_dbm.so
  70. LoadModule authz_default_module modules/mod_authz_default.so
  71. LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
  72. LoadModule authz_host_module modules/mod_authz_host.so
  73. #LoadModule authz_owner_module modules/mod_authz_owner.so
  74. LoadModule authz_user_module modules/mod_authz_user.so
  75. LoadModule autoindex_module modules/mod_autoindex.so
  76. #LoadModule cache_module modules/mod_cache.so
  77. #LoadModule cern_meta_module modules/mod_cern_meta.so
  78. LoadModule cgi_module modules/mod_cgi.so
  79. #LoadModule charset_lite_module modules/mod_charset_lite.so
  80. #LoadModule dav_module modules/mod_dav.so
  81. #LoadModule dav_fs_module modules/mod_dav_fs.so
  82. #LoadModule dav_lock_module modules/mod_dav_lock.so
  83. #LoadModule dbd_module modules/mod_dbd.so
  84. #LoadModule deflate_module modules/mod_deflate.so
  85. LoadModule dir_module modules/mod_dir.so
  86. #LoadModule disk_cache_module modules/mod_disk_cache.so
  87. #LoadModule dumpio_module modules/mod_dumpio.so
  88. LoadModule env_module modules/mod_env.so
  89. #LoadModule expires_module modules/mod_expires.so
  90. #LoadModule ext_filter_module modules/mod_ext_filter.so
  91. #LoadModule file_cache_module modules/mod_file_cache.so
  92. #LoadModule filter_module modules/mod_filter.so
  93. #LoadModule headers_module modules/mod_headers.so
  94. #LoadModule ident_module modules/mod_ident.so
  95. #LoadModule imagemap_module modules/mod_imagemap.so
  96. LoadModule include_module modules/mod_include.so
  97. #LoadModule info_module modules/mod_info.so
  98. LoadModule isapi_module modules/mod_isapi.so
  99. #LoadModule ldap_module modules/mod_ldap.so
  100. #LoadModule logio_module modules/mod_logio.so
  101. LoadModule log_config_module modules/mod_log_config.so
  102. #LoadModule log_forensic_module modules/mod_log_forensic.so
  103. #LoadModule mem_cache_module modules/mod_mem_cache.so
  104. LoadModule mime_module modules/mod_mime.so
  105. #LoadModule mime_magic_module modules/mod_mime_magic.so
  106. LoadModule negotiation_module modules/mod_negotiation.so
  107. #LoadModule proxy_module modules/mod_proxy.so
  108. #LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
  109. #LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
  110. #LoadModule proxy_connect_module modules/mod_proxy_connect.so
  111. #LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
  112. #LoadModule proxy_http_module modules/mod_proxy_http.so
  113. #LoadModule reqtimeout_module modules/mod_reqtimeout.so
  114. LoadModule rewrite_module modules/mod_rewrite.so
  115. LoadModule setenvif_module modules/mod_setenvif.so
  116. #LoadModule speling_module modules/mod_speling.so
  117. LoadModule ssl_module modules/mod_ssl.so
  118. #LoadModule status_module modules/mod_status.so
  119. #LoadModule substitute_module modules/mod_substitute.so
  120. #LoadModule unique_id_module modules/mod_unique_id.so
  121. #LoadModule userdir_module modules/mod_userdir.so
  122. #LoadModule usertrack_module modules/mod_usertrack.so
  123. #LoadModule version_module modules/mod_version.so
  124. #LoadModule vhost_alias_module modules/mod_vhost_alias.so
  125. #LoadModule jk_module modules/mod_jk-1.2.30-httpd-2.2.3.so
  126. LoadModule php5_module D:/Php52/php5apache2_2.dll
  127. LoadModule fcgid_module modules/mod_fcgid.so
  128. PHPIniDir "D:/PHP52"  
  129. #JkWorkersFile "D:/apache-tomcat-6.0.26/conf/workers.properties"
  130. #JkLogFile "D:/apache-tomcat-6.0.26/logs/mod_jk2.log"
  131. #JkLogLevel info
  132. <IfModule !mpm_netware_module>
  133. <IfModule !mpm_winnt_module>
  134. #
  135. # If you wish httpd to run as a different user or group, you must run
  136. # httpd as root initially and it will switch.  
  137. #
  138. # User/Group: The name (or #number) of the user/group to run httpd as.
  139. # It is usually good practice to create a dedicated user and group for
  140. # running httpd, as with most system services.
  141. #
  142. User daemon
  143. Group daemon
  144. </IfModule>
  145. </IfModule>
  146. # 'Main' server configuration
  147. #
  148. # The directives in this section set up the values used by the 'main'
  149. # server, which responds to any requests that aren't handled by a
  150. # <VirtualHost> definition.  These values also provide defaults for
  151. # any <VirtualHost> containers you may define later in the file.
  152. #
  153. # All of these directives may appear inside <VirtualHost> containers,
  154. # in which case these default settings will be overridden for the
  155. # virtual host being defined.
  156. #
  157. #
  158. # ServerAdmin: Your address, where problems with the server should be
  159. # e-mailed.  This address appears on some server-generated pages, such
  160. # as error documents.  e.g. admin@your-domain.com
  161. #
  162. ServerAdmin admin@neusoft.com.cn
  163. #
  164. # ServerName gives the name and port that the server uses to identify itself.
  165. # This can often be determined automatically, but we recommend you specify
  166. # it explicitly to prevent problems during startup.
  167. #
  168. # If your host doesn't have a registered DNS name, enter its IP address here.
  169. #
  170. #ServerName server@neusoft.com.cn:80
  171. #
  172. # DocumentRoot: The directory out of which you will serve your
  173. # documents. By default, all requests are taken from this directory, but
  174. # symbolic links and aliases may be used to point to other locations.
  175. #
  176. DocumentRoot "D:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
  177. #
  178. # Each directory to which Apache has access can be configured with respect
  179. # to which services and features are allowed and/or disabled in that
  180. # directory (and its subdirectories).
  181. #
  182. # First, we configure the "default" to be a very restrictive set of
  183. # features.  
  184. #
  185. <Directory />
  186.     Options FollowSymLinks
  187.     AllowOverride All
  188.     Order deny,allow
  189.     Deny from all
  190. </Directory>
  191. #
  192. # Note that from this point forward you must specifically allow
  193. # particular features to be enabled - so if something's not working as
  194. # you might expect, make sure that you have specifically enabled it
  195. # below.
  196. #
  197. #
  198. # This should be changed to whatever you set DocumentRoot to.
  199. #
  200. <Directory "D:/Program Files/Apache Software Foundation/Apache2.2/htdocs">
  201.     #
  202.     # Possible values for the Options directive are "None", "All",
  203.     # or any combination of:
  204.     #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
  205.     #
  206.     # Note that "MultiViews" must be named *explicitly* --- "Options All"
  207.     # doesn't give it to you.
  208.     #
  209.     # The Options directive is both complicated and important.  Please see
  210.     # http://httpd.apache.org/docs/2.2/mod/core.html#options
  211.     # for more information.
  212.     #
  213.     Options Indexes FollowSymLinks
  214.     #
  215.     # AllowOverride controls what directives may be placed in .htaccess files.
  216.     # It can be "All", "None", or any combination of the keywords:
  217.     #   Options FileInfo AuthConfig Limit
  218.     #
  219.     #AllowOverride None
  220.     AllowOverride All
  221.     #
  222.     # Controls who can get stuff from this server.
  223.     #
  224.     Order allow,deny
  225.     Allow from all
  226.    
  227.     #Allow ExecCGI add by wangcc
  228.     Options ExecCGI
  229.     #RedirectMatch ^/(.*)$ http://www.sina.com
  230. </Directory>
  231. #
  232. # DirectoryIndex: sets the file that Apache will serve if a directory
  233. # is requested.
  234. #
  235. <IfModule dir_module>
  236.     DirectoryIndex index.html index.php
  237. </IfModule>
  238. #
  239. # The following lines prevent .htaccess and .htpasswd files from being
  240. # viewed by Web clients.
  241. #
  242. <FilesMatch "^/.ht">
  243.     Order allow,deny
  244.     Deny from all
  245.     Satisfy All
  246. </FilesMatch>
  247. #
  248. # ErrorLog: The location of the error log file.
  249. # If you do not specify an ErrorLog directive within a <VirtualHost>
  250. # container, error messages relating to that virtual host will be
  251. # logged here.  If you *do* define an error logfile for a <VirtualHost>
  252. # container, that host's errors will be logged there and not here.
  253. #
  254. ErrorLog "logs/error.log"
  255. #
  256. # LogLevel: Control the number of messages logged to the error_log.
  257. # Possible values include: debug, info, notice, warn, error, crit,
  258. # alert, emerg.
  259. #
  260. LogLevel warn
  261. <IfModule log_config_module>
  262.     #
  263.     # The following directives define some format nicknames for use with
  264.     # a CustomLog directive (see below).
  265.     #
  266.     LogFormat "%h %l %u %t /"%r/" %>s %b /"%{Referer}i/" /"%{User-Agent}i/"" combined
  267.     LogFormat "%h %l %u %t /"%r/" %>s %b" common
  268.     <IfModule logio_module>
  269.       # You need to enable mod_logio.c to use %I and %O
  270.       LogFormat "%h %l %u %t /"%r/" %>s %b /"%{Referer}i/" /"%{User-Agent}i/" %I %O" combinedio
  271.     </IfModule>
  272.     #
  273.     # The location and format of the access logfile (Common Logfile Format).
  274.     # If you do not define any access logfiles within a <VirtualHost>
  275.     # container, they will be logged here.  Contrariwise, if you *do*
  276.     # define per-<VirtualHost> access logfiles, transactions will be
  277.     # logged therein and *not* in this file.
  278.     #
  279.     CustomLog "logs/access.log" common
  280.     #
  281.     # If you prefer a logfile with access, agent, and referer information
  282.     # (Combined Logfile Format) you can use the following directive.
  283.     #
  284.     #CustomLog "logs/access.log" combined
  285. </IfModule>
  286. <IfModule alias_module>
  287.     #
  288.     # Redirect: Allows you to tell clients about documents that used to
  289.     # exist in your server's namespace, but do not anymore. The client
  290.     # will make a new request for the document at its new location.
  291.     # Example:
  292.     # Redirect permanent /foo http://server@neusoft.com.cn/bar
  293.     #
  294.     # Alias: Maps web paths into filesystem paths and is used to
  295.     # access content that does not live under the DocumentRoot.
  296.     # Example:
  297.     # Alias /webpath /full/filesystem/path
  298.     #
  299.     # If you include a trailing / on /webpath then the server will
  300.     # require it to be present in the URL.  You will also likely
  301.     # need to provide a <Directory> section to allow access to
  302.     # the filesystem path.
  303.     #
  304.     # ScriptAlias: This controls which directories contain server scripts.
  305.     # ScriptAliases are essentially the same as Aliases, except that
  306.     # documents in the target directory are treated as applications and
  307.     # run by the server when requested rather than as documents sent to the
  308.     # client.  The same rules about trailing "/" apply to ScriptAlias
  309.     # directives as to Alias.
  310.     #
  311.     ScriptAlias /cgi-bin/ "D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/"
  312. </IfModule>
  313. <IfModule cgid_module>
  314.     #
  315.     # ScriptSock: On threaded servers, designate the path to the UNIX
  316.     # socket used to communicate with the CGI daemon of mod_cgid.
  317.     #
  318.     #Scriptsock logs/cgisock
  319. </IfModule>
  320. #
  321. # "D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin" should be changed to whatever your ScriptAliased
  322. # CGI directory exists, if you have that configured.
  323. #
  324. <Directory "D:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin">
  325.     AllowOverride All
  326.     Options None
  327.     Order allow,deny
  328.     Allow from all
  329. </Directory>
  330. #
  331. # DefaultType: the default MIME type the server will use for a document
  332. # if it cannot otherwise determine one, such as from filename extensions.
  333. # If your server contains mostly text or HTML documents, "text/plain" is
  334. # a good value.  If most of your content is binary, such as applications
  335. # or images, you may want to use "application/octet-stream" instead to
  336. # keep browsers from trying to display binary files as though they are
  337. # text.
  338. #
  339. DefaultType text/plain
  340. <IfModule mime_module>
  341.     #
  342.     # TypesConfig points to the file containing the list of mappings from
  343.     # filename extension to MIME-type.
  344.     #
  345.     TypesConfig conf/mime.types
  346.     #
  347.     # AddType allows you to add to or override the MIME configuration
  348.     # file specified in TypesConfig for specific file types.
  349.     #
  350.     #AddType application/x-gzip .tgz
  351.     #
  352.     # AddEncoding allows you to have certain browsers uncompress
  353.     # information on the fly. Note: Not all browsers support this.
  354.     #
  355.     #AddEncoding x-compress .Z
  356.     #AddEncoding x-gzip .gz .tgz
  357.     #
  358.     # If the AddEncoding directives above are commented-out, then you
  359.     # probably should define those extensions to indicate media types:
  360.     #
  361.     AddType application/x-compress .Z
  362.     AddType application/x-gzip .gz .tgz
  363.     AddType application/x-httpd-php .php
  364.     #
  365.     # AddHandler allows you to map certain file extensions to "handlers":
  366.     # actions unrelated to filetype. These can be either built into the server
  367.     # or added with the Action directive (see below)
  368.     #
  369.     # To use CGI scripts outside of ScriptAliased directories:
  370.     # (You will also need to add "ExecCGI" to the "Options" directive.)
  371.     #
  372.     #AddHandler cgi-script .cgi
  373.     # For type maps (negotiated resources):
  374.     #AddHandler type-map var
  375.     #
  376.     # Filters allow you to process content before it is sent to the client.
  377.     #
  378.     # To parse .shtml files for server-side includes (SSI):
  379.     # (You will also need to add "Includes" to the "Options" directive.)
  380.     #
  381.     #AddType text/html .shtml
  382.     #AddOutputFilter INCLUDES .shtml
  383. </IfModule>
  384. #
  385. # The mod_mime_magic module allows the server to use various hints from the
  386. # contents of the file itself to determine its type.  The MIMEMagicFile
  387. # directive tells the module where the hint definitions are located.
  388. #
  389. #MIMEMagicFile conf/magic
  390. #
  391. # Customizable error responses come in three flavors:
  392. # 1) plain text 2) local redirects 3) external redirects
  393. #
  394. # Some examples:
  395. #ErrorDocument 500 "The server made a boo boo."
  396. #ErrorDocument 404 /missing.html
  397. #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
  398. #ErrorDocument 402 http://server@neusoft.com.cn/subscription_info.html
  399. #
  400. #
  401. # EnableMMAP and EnableSendfile: On systems that support it,
  402. # memory-mapping or the sendfile syscall is used to deliver
  403. # files.  This usually improves server performance, but must
  404. # be turned off when serving from networked-mounted
  405. # filesystems or if support for these functions is otherwise
  406. # broken on your system.
  407. #
  408. #EnableMMAP off
  409. #EnableSendfile off
  410. # Supplemental configuration
  411. #
  412. # The configuration files in the conf/extra/ directory can be
  413. # included to add extra features or to modify the default configuration of
  414. # the server, or you may simply copy their contents here and change as
  415. # necessary.
  416. # Server-pool management (MPM specific)
  417. #Include conf/extra/httpd-mpm.conf
  418. # Multi-language error messages
  419. #Include conf/extra/httpd-multilang-errordoc.conf
  420. # Fancy directory listings
  421. #Include conf/extra/httpd-autoindex.conf
  422. # Language settings
  423. #Include conf/extra/httpd-languages.conf
  424. # User home directories
  425. #Include conf/extra/httpd-userdir.conf
  426. # Real-time info on requests and configuration
  427. #Include conf/extra/httpd-info.conf
  428. # Virtual hosts
  429. #Include conf/extra/httpd-vhosts.conf
  430. # Local access to the Apache HTTP Server Manual
  431. #Include conf/extra/httpd-manual.conf
  432. # Distributed authoring and versioning (WebDAV)
  433. #Include conf/extra/httpd-dav.conf
  434. # Various default settings
  435. #Include conf/extra/httpd-default.conf
  436. # Secure (SSL/TLS) connections
  437. Include conf/extra/httpd-ssl.conf
  438. #
  439. # Note: The following must must be present to support
  440. #       starting without SSL on platforms with no /dev/random equivalent
  441. #       but a statically compiled-in mod_ssl.
  442. #
  443. <IfModule ssl_module>
  444. SSLRandomSeed startup builtin
  445. SSLRandomSeed connect builtin
  446. </IfModule>
  447. <VirtualHost changchun.wang>
  448. #ServerAdmin changchun.wang
  449. #DocumentRoot D:/apache-tomcat-6.0.26/webapps
  450. #您的站点项目所在路径,应与tomcat中的目录设置相同
  451. #ServerName localhost
  452. #<Directory "D:/apache-tomcat-6.0.26/webapps">
  453. #Options Indexes FollowSymLinks
  454. #DirectoryIndex index.html index.htm index.jsp
  455. #AllowOverride All
  456. #Order allow,deny
  457. #Allow from all
  458. #</Directory>
  459. #ErrorLog logs/shsc-error_log.txt
  460. #CustomLog logs/shsc-access_log.txt common
  461. #JkMount /servlet/* ajp13
  462. #让Apache支持对servlet传送,用以Tomcat解析
  463. #JkMount /*.jsp ajp13
  464. #让Apache支持对jsp传送,用以Tomcat解析
  465. #JkMount /*.do ajp13
  466. #让Apache支持对.do传送,用以Tomcat解析
  467. </VirtualHost>
  468. <IfModule mod_fcgid.c>
  469.     AddHandler fcgid-script .phtml
  470.     FCGIWrapper "D:/php53/php-cgi.exe" .phtml
  471. </IfModule>
  472. <IfModule mod_rewrite.c>
  473. RewriteEngine On
  474. #RewriteCond %{HTTP} off
  475. #RewriteCond %{HTTP_PORT} ^443$
  476. #RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI}
  477. #RewriteEngine on
  478. #RewriteRule ^/(.*):SSL$ https://%{SERVER_NAME}/$1 [R,L]
  479. #RewriteRule ^/(.*):NOSSL$ http://%{SERVER_NAME}/$1 [R,L]
  480. </IfModule>
复制代码
编写php文件:
  1. <?php
  2.    phpinfo();
  3. ?>
复制代码
分别命名为:index.php和index.phtml,运行结果如下:

php52.JPG (113.57 KB)

 

php52.JPG

php53.JPG (110.81 KB)

 

php53.JPG

原创粉丝点击