簡體   English   中英

XAMPP conf-默認情況下運行php5_module並根據.htaccess切換到其他php cgi版本

[英]XAMPP conf - Run php5_module per default & switch to other php cgi versions per .htaccess

對於較舊的項目,我需要在.htacces上切換php版本。 如果我僅使用php-cgi版本,它將很好地工作。 php的性能更好。 現在我想配置我的xampp默認運行php5_module並在htaccss中使用AddHandler ...切換到其他cgi-versions php。 這個怎么做? 感謝幫助。

xampp conf:

#
# XAMPP settings
#

<IfModule env_module>
    SetEnv MIBDIRS "/xampplite/php/extras/mibs"
    SetEnv MYSQL_HOME "\\xampplite\\mysql\\bin"
    SetEnv OPENSSL_CONF "/xampplite/apache/bin/openssl.cnf"
    SetEnv PHP_PEAR_SYSCONF_DIR "\\xampplite\\php"
    SetEnv PHPRC "\\xampplite\\php"
    SetEnv TMP "\\xampplite\\tmp"
    UnsetEnv PERL5LIB
</IfModule>

#
# PHP-Module setup
#
#LoadFile "/xampplite/php/php5ts.dll"
#LoadModule php5_module modules/php5apache2_2.dll

<IfModule php5_module>

    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>

    PHPINIDir "/xampplite/php"
</IfModule>


#
# multible PHP Version Setup
#


#SetHandler application/x-httpd-php4
<IfModule !php5_module>

  Action application/x-httpd-php4_3 "/php4_3/php.exe"
  AddType application/x-httpd-php4_3 .php4 .php

  Action application/x-httpd-php4_4 "/php4_4/php.exe"
  AddType application/x-httpd-php4_4 .php4 .php

  Action application/x-httpd-php5_4 "/php5_4/php.exe"
  AddType application/x-httpd-php5_4 .php5 .php  

  Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
  AddType application/x-httpd-php-cgi .php  

  <FilesMatch "\.php$">
      AddHandler application/x-httpd-php-cgi .php
#        SetHandler application/x-httpd-php-cgi
  </FilesMatch>

</IfModule>

ScriptAlias /php4_3/ "/xampplite/php4_3/"
<Directory "/xampplite/php4_3">
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
</Directory>

ScriptAlias /php4_4/ "/xampplite/php4_4/"
<Directory "/xampplite/php4_4">
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
</Directory>

ScriptAlias /php5_4/ "/xampplite/php5_4/"
<Directory "/xampplite/php5_4">
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
</Directory>



#
# PHP-CGI setup
#

#<IfModule !php5_module>
#    <FilesMatch "\.php$">
#        AddHandler application/x-httpd-php-cgi .php
#        SetHandler application/x-httpd-php-cgi
#    </FilesMatch>
#    <IfModule actions_module>
#        Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
#    </IfModule>
#</IfModule>

<IfModule mime_module>
    AddType text/html .php .phps
</IfModule>

ScriptAlias /php-cgi/ "/xampplite/php/"
<Directory "/xampplite/php">
    AllowOverride None
    Options None
    Order deny,allow
    Deny from all
    <Files "php-cgi.exe">
        Allow from all
    </Files>
</Directory>

<Directory "/xampplite/cgi-bin">
    <FilesMatch "\.php$">
        SetHandler cgi-script
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler None
    </FilesMatch>
</Directory>

<Directory "/_projects/xampp">
    <IfModule php5_module>
        <Files "status.php">
            php_admin_flag safe_mode off
        </Files>
    </IfModule>
    AllowOverride AuthConfig
</Directory>


<IfModule alias_module>
    Alias /security "/xampplite/security/htdocs/"
    <Directory "/xampplite/security/htdocs">
        <IfModule php5_module>
            <Files "xamppsecurity.php">
                php_admin_flag safe_mode off
            </Files>
        </IfModule>
        AllowOverride AuthConfig
   </Directory>

    Alias /licenses "/xampplite/licenses/"
    <Directory "/xampplite/licenses">
        Options +Indexes
        <IfModule autoindex_color_module>
            DirectoryIndexTextColor  "#000000"
            DirectoryIndexBGColor "#f8e8a0"
            DirectoryIndexLinkColor "#bb3902"
            DirectoryIndexVLinkColor "#bb3902"
            DirectoryIndexALinkColor "#bb3902"
        </IfModule>
   </Directory>

    Alias /phpmyadmin "/xampplite/phpMyAdmin/"
    <Directory "/xampplite/phpMyAdmin">
        AllowOverride AuthConfig
    </Directory>

    Alias /webalizer "/xampplite/webalizer/"
    <Directory "/xampplite/webalizer">
        <IfModule php5_module>
            <Files "webalizer.php">
                php_admin_flag safe_mode off
            </Files>
        </IfModule>
        AllowOverride AuthConfig
    </Directory>
</IfModule>


#
# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
    Order deny,allow
    Deny from all
    Allow from ::1 127.0.0.0/8 \
               fc00::/7 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 \
               fe80::/10 169.254.0.0/16

    ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var
</LocationMatch>

.htacces:

AddHandler application/x-httpd-php4_3  .php
SetHandler application/x-httpd-php4_3

#AddHandler application/x-httpd-php4_4  .php
#SetHandler application/x-httpd-php4_4

#AddHandler application/x-httpd-php5_4  .php
#SetHandler application/x-httpd-php5_4

我找到了自己的解決方案:

xampp conf

#
# XAMPP settings
#

<IfModule env_module>
    SetEnv MIBDIRS "/xampplite/php/extras/mibs"
    SetEnv MYSQL_HOME "\\xampplite\\mysql\\bin"
    SetEnv OPENSSL_CONF "/xampplite/apache/bin/openssl.cnf"
    SetEnv PHP_PEAR_SYSCONF_DIR "\\xampplite\\php"
    SetEnv PHPRC "\\xampplite\\php"
    SetEnv TMP "\\xampplite\\tmp"
    UnsetEnv PERL5LIB
</IfModule>

#
# PHP-Module setup (module as default version 5.3 in my case)
#

LoadFile "/xampplite/php/php5ts.dll"
LoadModule php5_module modules/php5apache2_2.dll

<IfModule php5_module>
    <FilesMatch "\.php$">
        AddHandler application/x-httpd-php .php
        #SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
    PHPINIDir "/xampplite/php"
</IfModule>


#
# PHP-CGI multiple Version Setup
#

Action application/x-httpd-php4_3 "/php4_3/php.exe"
AddType application/x-httpd-php4_3 .php4 .php

Action application/x-httpd-php4_4 "/php4_4/php.exe"
AddType application/x-httpd-php4_4 .php4 .php

Action application/x-httpd-php5_4 "/php5_4/php-cgi.exe"
AddType application/x-httpd-php5_4 .php5 .php  

Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
AddType application/x-httpd-php-cgi .php  

<IfModule mime_module>
    AddType text/html .php .phps
</IfModule>

ScriptAlias /php4_3/ "/xampplite/php4_3/"
<Directory "/xampplite/php4_3">
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
</Directory>

ScriptAlias /php4_4/ "/xampplite/php4_4/"
<Directory "/xampplite/php4_4">
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
  SetEnv PHPRC "\\xampplite\\php4_4"
</Directory>

ScriptAlias /php5_4/ "/xampplite/php5_4/"
<Directory "/xampplite/php5_4">
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
  SetEnv PHP_PEAR_SYSCONF_DIR "\\xampplite\\php5_4"
  SetEnv PHPRC "\\xampplite\\php5_4"
</Directory>

ScriptAlias /php-cgi/ "/xampplite/php/"
<Directory "/xampplite/php">
    AllowOverride None
    Options None
    Order deny,allow
    Deny from all
    <Files "php-cgi.exe">
        Allow from all
    </Files>
</Directory>

<Directory "/xampplite/cgi-bin">
    <FilesMatch "\.php$">
        SetHandler cgi-script
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler None
    </FilesMatch>
</Directory>

<Directory "/_projects/xampp">
    <IfModule php5_module>
        <Files "status.php">
            php_admin_flag safe_mode off
        </Files>
    </IfModule>
    AllowOverride AuthConfig
</Directory>


<IfModule alias_module>
    Alias /security "/xampplite/security/htdocs/"
    <Directory "/xampplite/security/htdocs">
        <IfModule php5_module>
            <Files "xamppsecurity.php">
                php_admin_flag safe_mode off
            </Files>
        </IfModule>
        AllowOverride AuthConfig
   </Directory>

    Alias /licenses "/xampplite/licenses/"
    <Directory "/xampplite/licenses">
        Options +Indexes
        <IfModule autoindex_color_module>
            DirectoryIndexTextColor  "#000000"
            DirectoryIndexBGColor "#f8e8a0"
            DirectoryIndexLinkColor "#bb3902"
            DirectoryIndexVLinkColor "#bb3902"
            DirectoryIndexALinkColor "#bb3902"
        </IfModule>
   </Directory>

    Alias /phpmyadmin "/xampplite/phpMyAdmin/"
    <Directory "/xampplite/phpMyAdmin">
        AllowOverride AuthConfig
    </Directory>

    Alias /webalizer "/xampplite/webalizer/"
    <Directory "/xampplite/webalizer">
        <IfModule php5_module>
            <Files "webalizer.php">
                php_admin_flag safe_mode off
            </Files>
        </IfModule>
        AllowOverride AuthConfig
    </Directory>
</IfModule>


#
# New XAMPP security concept
#

<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
    Order deny,allow
    Deny from all
    Allow from ::1 127.0.0.0/8 \
               fc00::/7 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 \
               fe80::/10 169.254.0.0/16

    ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var
</LocationMatch>

如何在.htaccess中使用

#SetHandler application/x-httpd-php4_3
#SetHandler application/x-httpd-php4_4
SetHandler application/x-httpd-php5_4

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM