Apache:将XAMPP / PHP句柄从application / x-httpd-php更改为application / x-httpd-php5 [英] Apache: Change XAMPP/PHP handle from application/x-httpd-php to application/x-httpd-php5

查看:1642
本文介绍了Apache:将XAMPP / PHP句柄从application / x-httpd-php更改为application / x-httpd-php5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是停止拥有我的.htaccess文件的本地副本和活副本,而且能够为BOTH本地/ live配置使用同一个.htaccess文件。



我的本​​地服务器是我计算机上的XAMPP,而我的live服务器是一个共享的web主机,我显然不能改变设置。我不是在那里,我可以配置一切从头,所以我会坚持使用XAMPP一段时间。此外,任何熟悉XAMPP的人都应该知道我试图使用他们的论坛(登录/密码重置失败),并且管理员没有回复我的电子邮件几天,所以我没有成功尝试更多的目标路由。



更具体的问题是我想使用我的本地服务器的现场共享服务器的PHP处理程序。



要执行PHP非共享网络主机上的非本机文件我使用以下...



public_html / .htaccess

  AddType application / x-httpd-php5 .css .html .js .txt .xml 

...我想配置我的电脑/本地设置来模拟这个,所以我不需要保留.htaccess文件的本地/活的独立副本我来学习如何配置服务器)。目前我必须使用以下本地...



public_html / .htaccess

  AddType application / x-httpd-php .css .html .js .txt .xml 

我可以跟踪XAMPP 1.7.7(当前最新版本)中的配置。



xampp \apache\conf\extra\httpd-xampp.conf



现在我不想改变PHP版本使用(不是我的目标)...我只是想确保我可以使用本地相同的句柄,我住的地方。我试图简单地添加字符串'5'到下面的行17(?),虽然那不工作(保存,停止服务器,当然重新启动服务器)。

 < IfModule env_module> 
SetEnv MIBDIRSC:/ MEDIA / INTERNET / xampp / php / extras / mibs
SetEnv MYSQL_HOME\\xampp\\mysql\\bin
SetEnv OPENSSL_CONFC:/MEDIA/INTERNET/xampp/apache/bin/openssl.cnf
SetEnv PHP_PEAR_SYSCONF_DIR\\xampp\\p
SetEnv PHPRC\\xampp\\ \\\php
SetEnv TMP\\xampp\\tmp
< / IfModule>


#PHP模块设置

LoadFileC:/MEDIA/INTERNET/xampp/php/php5ts.dll
LoadModule php5_module C:/MEDIA/INTERNET/xampp/php/php5apache2_2.dll

< FilesMatch\.php $>在此处输入代码
SetHandler应用程序/ x-httpd- php
< / FilesMatch>
< FilesMatch\.phps $>
SetHandler application / x-httpd-php-source
< / FilesMatch>


#PHP-CGI设置

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


< IfModule php5_module>
PHPINIDirC:/ MEDIA / INTERNET / xampp / php
< / IfModule>

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

ScriptAlias / php-cgi /C:/ MEDIA / INTERNET / xampp / php /
< DirectoryC:/ MEDIA / INTERNET / xampp / php>
AllowOverride无
选项无
命令拒绝,允许
拒绝所有
<文件php-cgi.exe>
允许所有
< / Files>
< / Directory>

< DirectoryC:/ MEDIA / INTERNET / xampp / cgi-bin>
< FilesMatch\.php $>
SetHandler cgi-script
< / FilesMatch>
< FilesMatch\.phps $>
SetHandler None
< / FilesMatch>
< / Directory>

< DirectoryC:/ MEDIA / INTERNET / xampp / htdocs / xampp>
< IfModule php5_module>
< Filesstatus.php>
php_admin_flag safe_mode off
< / Files>
< / IfModule>
AllowOverride AuthConfig
< / Directory>

< IfModule alias_module>
别名/安全C:/ MEDIA / INTERNET / xampp / security / htdocs /
< DirectoryC:/ MEDIA / INTERNET / xampp / security / htdocs
< IfModule php5_module>
< Filesxamppsecurity.php>
php_admin_flag safe_mode off
< / Files>
< / ifModule>
AllowOverride AuthConfig
< / Directory>

Alias / phpmyadminC:/ MEDIA / INTERNET / xampp / phpMyAdmin /
< DirectoryC:/ MEDIA / INTERNET / xampp / phpMyAdmin>
AllowOverride AuthConfig
< / Directory>

Alias / webalizerC:/ MEDIA / INTERNET / xampp / webalizer /
< DirectoryC:/ MEDIA / INTERNET / xampp / webalizer>
< IfModule php5_module>
< Fileswebalizer.php>
php_admin_flag safe_mode off
< / Files>
< / IfModule>
AllowOverride AuthConfig
< / Directory>
< / IfModule>

所以我不知道如何分配 application / x-httpd-php5 来处理任何应用程序/ x-httpd-php ,并记得我不想更改我使用的PHP版本(工作正常)。

我还应该注意,在使用程序高级查找&替换,我发现在XAMPP目录中的8个文件总共有字符串application / x-httpd-php,但上面的文件是唯一一个似乎与Apache的配置相关。



如果有人可以帮助我得到这个工作,我会很乐意接受答案和投票;

解决方案

不是你的问题的答案,但我不会'这样做对自己。 Apache的配置文件格式不是真的为这样的东西。



对我来说,有两个单独的htaccess文件(如 .htaccess .htaccess。 local ,并通过 AccessFileName 指令:

  AccessFileName .htaccess.local 

是最好的方式。



您确实希望将所有内容都保存在一个文件中,也可以使用 < IfDefine> 块来分隔本地和实时指令。您必须在本地启动服务器时设置一个定义,然后可以测试是否存在 - 定义。


My goal is to stop having to have a local copy and a live copy of my .htaccess file and instead be able to use the same single .htaccess file for BOTH local/live configurations. This will force me to better understand configuring a server.

My local server is XAMPP on my computer while my live server is a shared web host where I obviously can't change settings. I'm not at the point where I can configure everything from scratch so I'll be sticking with XAMPP for a while longer. Additionally anyone familiar with XAMPP should know that I attempted to use their forums (broken signin/password reset) and the admin hasn't responded to my email for days so I did try the more on-target route without success.

The more specific issue is I want to use my live shared server's PHP handler for my local server.

To execute PHP in non-native files on my live shared web host I use the following...

public_html/.htaccess

AddType application/x-httpd-php5 .css .html .js .txt .xml

...I want to configure my computer/local setup to emulate this so I don't have to keep separate copies of .htaccess files for local/live (this forces me to learn how to configure the server). Currently I have to use the following locally...

public_html/.htaccess

AddType application/x-httpd-php .css .html .js .txt .xml

I was able to track down where the configuration seems to be in XAMPP 1.7.7 (current latest release)...

xampp\apache\conf\extra\httpd-xampp.conf

Now I'm not interested in changing the PHP version that's being used (not my goal)...I just want to make sure that I can use the same handle locally as I do live. I tried to simply add the string '5' to line 17(?) below though that didn't work (saved, stopped server, restarted server of course).

<IfModule env_module>
    SetEnv MIBDIRS "C:/MEDIA/INTERNET/xampp/php/extras/mibs"
    SetEnv MYSQL_HOME "\\xampp\\mysql\\bin"
    SetEnv OPENSSL_CONF "C:/MEDIA/INTERNET/xampp/apache/bin/openssl.cnf"
    SetEnv PHP_PEAR_SYSCONF_DIR "\\xampp\\php"
    SetEnv PHPRC "\\xampp\\php"
    SetEnv TMP "\\xampp\\tmp"
</IfModule>

#
# PHP-Module setup
#
LoadFile "C:/MEDIA/INTERNET/xampp/php/php5ts.dll"
LoadModule php5_module "C:/MEDIA/INTERNET/xampp/php/php5apache2_2.dll"

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

#
# PHP-CGI setup
#
#<FilesMatch "\.php$">
#    SetHandler application/x-httpd-php-cgi
#</FilesMatch>
#<IfModule actions_module>
#    Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
#</IfModule>


<IfModule php5_module>
    PHPINIDir "C:/MEDIA/INTERNET/xampp/php"
</IfModule>

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

ScriptAlias /php-cgi/ "C:/MEDIA/INTERNET/xampp/php/"
<Directory "C:/MEDIA/INTERNET/xampp/php">
    AllowOverride None
    Options None
    Order deny,allow
    Deny from all
    <Files "php-cgi.exe">
        Allow from all
    </Files>
</Directory>

<Directory "C:/MEDIA/INTERNET/xampp/cgi-bin">
    <FilesMatch "\.php$">
        SetHandler cgi-script
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler None
    </FilesMatch>
</Directory>

<Directory "C:/MEDIA/INTERNET/xampp/htdocs/xampp">
    <IfModule php5_module>
        <Files "status.php">
            php_admin_flag safe_mode off
        </Files>
    </IfModule>
    AllowOverride AuthConfig
</Directory>

<IfModule alias_module>
    Alias /security "C:/MEDIA/INTERNET/xampp/security/htdocs/"
    <Directory "C:/MEDIA/INTERNET/xampp/security/htdocs">
        <IfModule php5_module>
            <Files "xamppsecurity.php">
                php_admin_flag safe_mode off
            </Files>
        </IfModule>
        AllowOverride AuthConfig
   </Directory>

    Alias /phpmyadmin "C:/MEDIA/INTERNET/xampp/phpMyAdmin/"
    <Directory "C:/MEDIA/INTERNET/xampp/phpMyAdmin">
        AllowOverride AuthConfig
    </Directory>

    Alias /webalizer "C:/MEDIA/INTERNET/xampp/webalizer/"
    <Directory "C:/MEDIA/INTERNET/xampp/webalizer">
        <IfModule php5_module>
            <Files "webalizer.php">
                php_admin_flag safe_mode off
            </Files>
        </IfModule>
        AllowOverride AuthConfig
    </Directory>
</IfModule>

So I don't know how to assign "application/x-httpd-php5" to work with whatever "application/x-httpd-php" is assigned to and remember I do not want to change the version of PHP I'm using (works fine).

I should also note that after using the program Advanced Find & Replace that I've found eight total files in the XAMPP directory with the string "application/x-httpd-php" however the file above is the only one that seems relevant to Apache's configuration.

If someone can help me get this working I'll be happy to both accept the answer and up-vote; I'm also happy to make any clarifications if need be.

解决方案

Not really an answer to your question, but I wouldn't do this to myself. Apache's config file format isn't really built for stuff like this.

To me, having two separate htaccess files (like .htaccess and .htaccess.local, and controlling the local server through the AccessFileName directive:

AccessFileName .htaccess.local

is the best way to go.

If you really want to have everything in one file, it may be possible by using <IfDefine> blocks to separate local and live directives. You would have to set a define when starting your server locally, and could then test for the presence or non-presence of that define.

这篇关于Apache:将XAMPP / PHP句柄从application / x-httpd-php更改为application / x-httpd-php5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆