沃梦达 / 编程问答 / php问题 / 正文

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(Apache:将 XAMPP/PHP 句柄从 application/x-httpd-php 更改为 application/x-httpd-php5)

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

问题描述

我的目标是不再需要我的 .htaccess 文件的本地副本和实时副本,而是能够对本地/实时配置使用相同的单个 .htaccess 文件.这将迫使我更好地理解配置服务器.

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.

我的本​​地服务器是我计算机上的 XAMPP,而我的实时服务器是一个共享的网络主机,我显然无法更改设置.我还不能从头开始配置所有东西,所以我会坚持使用 XAMPP 一段时间.此外,任何熟悉 XAMPP 的人都应该知道,我曾尝试使用他们的论坛(登录/密码重置失败),而管理员已经好几天没有回复我的电子邮件,所以我确实尝试了更针对目标的路线,但没有成功.

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.

更具体的问题是我想为我的本地服务器使用我的实时共享服务器的 PHP 处理程序.

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

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

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

...我想配置我的计算机/本地设置来模拟这一点,因此我不必为本地/实时保留单独的 .htaccess 文件副本(这迫使我学习如何配置服务器).目前我必须在本地使用以下...

...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

我能够追踪配置在 XAMPP 1.7.7(当前最新版本)中的位置...

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

xamppapacheconfextrahttpd-xampp.conf

现在我对更改正在使用的 PHP 版本不感兴趣(不是我的目标)...我只是想确保我可以在本地使用与我实际使用的相同的句柄.我试图简单地将字符串 '5' 添加到下面的第 17 行(?),尽管这不起作用(当然是保存、停止服务器、重新启动服务器).

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>

所以我不知道如何分配application/x-httpd-php5"来处理分配的任何application/x-httpd-php"记住我不想更改我正在使用的 PHP 版本(工作正常).

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).

我还应该注意,在使用程序 Advanced Find &将我在 XAMPP 目录中找到的总共八个文件替换为字符串application/x-httpd-php",但是上面的文件是唯一一个似乎与 Apache 的配置相关的文件.

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.

推荐答案

不是你的问题的真正答案,但我不会对自己这样做.Apache 的配置文件格式并不是真正为这样的东西而构建的.

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.

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

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

AccessFileName .htaccess.local

是最好的选择.

如果您真的想将所有内容都放在一个文件中,可以使用 <IfDefine> 块来分隔本地和实时指令.您必须在本地启动服务器时设置一个定义,然后可以测试该定义的存在或不存在.

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Apache:将 XAMPP/PHP 句柄从 application/x-httpd-php 更改为 application/x-httpd-php5

基础教程推荐