我尝试使用apache和fcgi在我的Windows服务器上使用不同的PHP版本,但它不起作用...
这是我httpd.conf的摘录:
<IfModule php5_module>
PHPIniDir C:/Wamp/bin/php/php5.5.12
</IfModule>
LoadModule fcgid_module modules/mod_fcgid.so
<IfModule fcgid_module>
FcgidInitialEnv PATH "C:/Wamp/bin/php/php5.5.31-nts;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;"
FcgidInitialEnv SystemRoot "C:/Windows"
FcgidInitialEnv SystemDrive "C:"
FcgidInitialEnv TEMP "C:/Wamp/tmp"
FcgidInitialEnv TMP "C:/Wamp/tmp"
FcgidInitialEnv windir "C:/WINDOWS"
FcgidIOTimeout 64
FcgidConnectTimeout 16
FcgidMaxRequestsPerProcess 1000
FcgidMaxProcesses 3
FcgidMaxRequestLen 8131072
#FcgidConfig -idle-timeout 110 -killInterval 120 -pass-header HTTP_AUTHORIZATION -autoUpdate
# Location php.ini:
FcgidInitialEnv PHPRC "C:/Wamp/bin/php/php5.5.31-nts"
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
<Files ~ "\.php$">
Options Indexes FollowSymLinks ExecCGI
AddHandler fcgid-script .php
FcgidWrapper "C:/Wamp/bin/php/php5.5.31-nts/php-cgi.exe" .php
</Files>
</IfModule>
Listen 54
<VirtualHost *:54>
DocumentRoot "C:/WWWROOT/"
#SetEnv PHPRC "C:/Wamp/bin/php/php5.4.45-nts"
#ScriptAlias /php5445/ "C:/Wamp/bin/php/php5.4.45-nts"
#Action php5445-script /php5445/php-cgi.exe
#AddHandler php5445-script .php
FcgidInitialEnv PHPRC "C:/Wamp/bin/php/php5.4.45-nts"
AddHandler fcgid-script .php
FcgidWrapper "C:/Wamp/bin/php/php5.4.45-nts" .php
#<Directory "C:/Wamp/bin/php/php5.4.45-nts">
# Options Indexes FollowSymLinks Includes ExecCGI
# AllowOverride All
# Require all granted
# Order Allow,Deny
# Allow from all
#</Directory>
<Directory "C:/WWWROOT/">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Listen 52
<VirtualHost *:52>
DocumentRoot "C:/WWWROOT/"
#SetEnv PHPRC "C:/Wamp/bin/php/php5.2.17-nts"
#ScriptAlias /php5217/ "C:/Wamp/bin/php/php5.2.17-nts"
#Action php5217-script /php5217/php-cgi.exe
#AddHandler php5217-script .php
FcgidInitialEnv PHPRC "C:/Wamp/bin/php/php5.4.45-nts"
AddHandler fcgid-script .php
FcgidWrapper "C:/Wamp/bin/php/php5.4.45-nts" .php
#<Directory "C:/Wamp/bin/php/php5.2.17-nts">
# Options Indexes FollowSymLinks Includes ExecCGI
# AllowOverride All
# Require all granted
# Order Allow,Deny
# Allow from all
#</Directory>
<Directory "C:/WWWROOT/">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Order Allow,Deny
Allow from all
</Directory>
你认为有什么问题吗?
如果我去localhost:52?phpInfo我可以看到 _SERVER [“PHPRC”] C:/Wamp/bin/php/php5.2.17-nts 但主要标题是“PHP版本5.5.31” 如果我尝试在端口52上使用mysql_connect(),这在PHP 5.2上没有被弃用,我收到了已弃用的错误消息......
我正在使用wampserver ...我花了一天时间寻找解决方案...所以如果你有任何想法......
答案 0 :(得分:1)
简单的配置:
在端口80上托管1个php 5.3:
cat.Cat
在端口83上托管2个php 5.5:
<VirtualHost 0.0.0.0:80>
ServerAdmin "brko28@hotmail.com"
DocumentRoot "/www/www"
ServerName "localhost"
ServerAlias "localhost"
ScriptAlias /cgi-bin/ "/www/www/cgi-bin/"
Options Indexes FollowSymLinks
DirectoryIndex index.php index.html index.htm index.cgi default.html default.htm index.pl index.shtml default.php default.pl default.cgi default.shtml home.php home.pl home.cgi home.shtml home.html home.htm
IndexOptions FancyIndexing IconHeight=22 IconWidth=18 NameWidth=50 IgnoreCase FoldersFirst
AddType text/html .php .php3 .php4 .php5 .phps .shtml
DefaultType text/plain
<IfModule fcgid_module>
Options +ExecCGI
FcgidInitialEnv PATH "\www\php\encoders_new;\www\imagemagick;\www\php\bash;\www\perl\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem"
FcgidInitialEnv MIBDIRS "\www\php\x64\nts\php5.3.29VC9\extras\mibs"
FcgidInitialEnv PHP_PEAR_SYSCONF_DIR "\www\php\x64\nts\php5.3.29VC9"
FcgidInitialEnv PHPRC "\www\php\x64\nts\php5.3.29VC9"
AddHandler fcgid-script .php .php3 .php4 .php5 .phps .cgi .pl .fcgi
#FcgidWrapper "/www/php/x64/nts/php5.3.29VC9/php-cgi.exe" .php
</IfModule>
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
Require all denied
Satisfy All
</FilesMatch>
<IfModule autoindex_module>
IndexIgnore .htaccess
</IfModule>
<Directory "/www/www/cgi-bin">
DefaultType text/html
Options -Indexes +ExecCGI
AllowOverride None
Require all granted
SetHandler cgi-script
</Directory>
<Location "/cgi-bin">
SetHandler cgi-script
Options +ExecCGI
</Location>
<Directory "/www/www">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
AddType text/html .php .php3 .php4 .php5 .phps .shtml
DirectoryIndex index.php index.html index.htm index.cgi default.html default.htm index.pl index.shtml default.php default.pl default.cgi default.shtml home.php home.pl home.cgi home.shtml home.html home.htm
<IfModule fcgid_module>
Options +ExecCGI
<Files ~ "\.(php|phtml)$">
AddHandler fcgid-script .php .php3 .php4 .php5 .phps .cgi .pl .fcgi
FcgidWrapper "/www/php/x64/nts/php5.3.29VC9/php-cgi.exe" .php
#
# Taken care of in mod_fcgid.conf with: FcgidPassHeader Authorization
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]
</Files>
</IfModule>
<IfModule php5_module>
AddType application/x-httpd-php .phtml .pwml .php5 .php4 .php3 .php2 .php .inc
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps
<IfModule php5_module>
php_admin_flag apc.enabled Off
</IfModule>
</IfModule>
</Directory>
Include "conf/extra/php53/*.conf"
</VirtualHost>
端口2上的主机2 php 5.4:
Listen 0.0.0.0:83
#
<VirtualHost 0.0.0.0:83>
ServerAdmin "brko28@hotmail.com"
DocumentRoot "/www/vhdoc"
ServerName "localhost:83"
ServerAlias "localhost:83"
ScriptAlias /cgi-bin/ "/www/vhdoc/cgi-bin/"
Options Indexes FollowSymLinks
DirectoryIndex index.php index.html index.htm index.cgi default.html default.htm index.pl index.shtml default.php default.pl default.cgi default.shtml home.php home.pl home.cgi home.shtml home.html home.htm
IndexOptions FancyIndexing IconHeight=22 IconWidth=18 NameWidth=50 IgnoreCase FoldersFirst
AddType text/html .php .php3 .php4 .php5 .phps .shtml
DefaultType text/plain
<IfModule fcgid_module>
Options +ExecCGI
FcgidInitialEnv PATH "\www\php\encoders_new;\www\imagemagick;\www\php\bash;\www\perl\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem"
FcgidInitialEnv MIBDIRS "\www\php\x64\nts\php5.5.38VC11\extras\mibs"
FcgidInitialEnv PHP_PEAR_SYSCONF_DIR "\www\php\x64\nts\php5.5.38VC11"
FcgidInitialEnv PHPRC "\www\php\x64\nts\php5.5.38VC11"
AddHandler fcgid-script .php .php3 .php4 .php5 .phps .cgi .pl .fcgi
#FcgidWrapper "/www/php/x64/nts/php5.5.38VC11/php-cgi.exe" .php
</IfModule>
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
Require all denied
Satisfy All
</FilesMatch>
<IfModule autoindex_module>
IndexIgnore .htaccess
</IfModule>
<Directory "/www/vhdoc/cgi-bin">
DefaultType text/html
Options -Indexes +ExecCGI
AllowOverride None
Require all granted
SetHandler cgi-script
</Directory>
<Location "/cgi-bin">
SetHandler cgi-script
Options +ExecCGI
</Location>
<Directory "/www/vhdoc">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
AddType text/html .php .php3 .php4 .php5 .phps .shtml
DirectoryIndex index.php index.html index.htm index.cgi default.html default.htm index.pl index.shtml default.php default.pl default.cgi default.shtml home.php home.pl home.cgi home.shtml home.html home.htm
<IfModule fcgid_module>
Options +ExecCGI
<Files ~ "\.(php|phtml)$">
AddHandler fcgid-script .php .php3 .php4 .php5 .phps .cgi .pl .fcgi
FcgidWrapper "/www/php/x64/nts/php5.5.38VC11/php-cgi.exe" .php
#
# Taken care of in mod_fcgid.conf with: FcgidPassHeader Authorization
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]
</Files>
</IfModule>
<IfModule php5_module>
AddType application/x-httpd-php .phtml .pwml .php5 .php4 .php3 .php2 .php .inc
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps
<IfModule php5_module>
php_admin_flag apc.enabled Off
</IfModule>
</IfModule>
</Directory>
Include "conf/extra/php55/*.conf"
</VirtualHost>
最后,最重要的是。为所有php设置mod_fcgid
Listen 0.0.0.0:82
#
<VirtualHost 0.0.0.0:82>
ServerAdmin "brko28@hotmail.com"
DocumentRoot "/www/vhdoc"
ServerName "localhost:82"
ServerAlias "localhost:82"
ScriptAlias /cgi-bin/ "/www/vhdoc/cgi-bin/"
Options Indexes FollowSymLinks
DirectoryIndex index.php index.html index.htm index.cgi default.html default.htm index.pl index.shtml default.php default.pl default.cgi default.shtml home.php home.pl home.cgi home.shtml home.html home.htm
IndexOptions FancyIndexing IconHeight=22 IconWidth=18 NameWidth=50 IgnoreCase FoldersFirst
AddType text/html .php .php3 .php4 .php5 .phps .shtml
DefaultType text/plain
<IfModule fcgid_module>
Options +ExecCGI
FcgidInitialEnv PATH "\www\php\encoders_new;\www\imagemagick;\www\php\bash;\www\perl\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem"
FcgidInitialEnv MIBDIRS "\www\php\x64\nts\php5.4.45VC9\extras\mibs"
FcgidInitialEnv PHP_PEAR_SYSCONF_DIR "\www\php\x64\nts\php5.4.45VC9"
FcgidInitialEnv PHPRC "\www\php\x64\nts\php5.4.45VC9"
AddHandler fcgid-script .php .php3 .php4 .php5 .phps .cgi .pl .fcgi
#FcgidWrapper "/www/php/x64/nts/php5.4.45VC9/php-cgi.exe" .php
</IfModule>
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
Require all denied
Satisfy All
</FilesMatch>
<IfModule autoindex_module>
IndexIgnore .htaccess
</IfModule>
<Directory "/www/vhdoc/cgi-bin">
DefaultType text/html
Options -Indexes +ExecCGI
AllowOverride None
Require all granted
SetHandler cgi-script
</Directory>
<Location "/cgi-bin">
SetHandler cgi-script
Options +ExecCGI
</Location>
<Directory "/www/vhdoc">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
AddType text/html .php .php3 .php4 .php5 .phps .shtml
DirectoryIndex index.php index.html index.htm index.cgi default.html default.htm index.pl index.shtml default.php default.pl default.cgi default.shtml home.php home.pl home.cgi home.shtml home.html home.htm
<IfModule fcgid_module>
Options +ExecCGI
<Files ~ "\.(php|phtml)$">
AddHandler fcgid-script .php .php3 .php4 .php5 .phps .cgi .pl .fcgi
FcgidWrapper "/www/php/x64/nts/php5.4.45VC9/php-cgi.exe" .php
#
# Taken care of in mod_fcgid.conf with: FcgidPassHeader Authorization
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]
</Files>
</IfModule>
<IfModule php5_module>
AddType application/x-httpd-php .phtml .pwml .php5 .php4 .php3 .php2 .php .inc
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps
<IfModule php5_module>
php_admin_flag apc.enabled Off
</IfModule>
</IfModule>
</Directory>
Include "conf/extra/php54/*.conf"
</VirtualHost>