无法在Apache配置文件中找到PHP的Addhandler

发布于 2025-01-27 11:36:26 字数 691 浏览 4 评论 0原文

我已经安装了CentOS(最新8和流9),并且确实安装了PHP和Apache:

dnf install httpd php

一切正常,并且PHP文件正在正确解释。

我意识到有一个文件,位于/etc/httpd/conf.modules.d/20-php.conf使用以下行,将PHP加载到apache内部,例如:

LoadModule php_module modules/libphp.so

伟大!但是我在其他任何地方都找不到Addhandler XXXX PHP之类的代码。在所有之前,我安装了PHP+Apache,总会使用Addhandler加载PHP的行。

我之所以要求这个,是因为我想允许PHP在我的整个服务器中分发,但是如果用户访问任何具有名称dons_interpret_php的目录,我不希望对PHP进行解释。在这种情况下,如果此目录内有一个PHP文件,则应使用Apache 的服务器,而无需解释其内容。

我在Google上找到了一些方法来做到这一点,但是所有这些都需要修改行Addhandler,但我找不到任何地方(不是在httpd.conf中,而不是在VirtualHosts文件中...没有地点!)。

太感谢了!

I have a fresh install of CentOS (latest 8 and Stream 9) and I did this do install PHP and Apache:

dnf install httpd php

Everything works fine and PHP files are being interpreted correctly.

I realized there is a file at /etc/httpd/conf.modules.d/20-php.conf that loads PHP inside Apache using a line like:

LoadModule php_module modules/libphp.so

Great! But I cant find anywhere else a code like AddHandler xxxx php. On all the previous times I installed PHP+Apache there always would be a line to load php using AddHandler.

I am asking this because I want to allow PHP to be interepreted in my entire server HOWEVER I dont want PHP to be interpreted if the user access any directory with name dont_interpret_php. In this case, if there is a PHP file inside this directory, it should be server by Apache as is, without interpreting its content.

I found some ways on Google to do that but all of them require modifying the line AddHandler but I cant find it anywhere (not in httpd.conf, not in virtualhosts file... no where!).

Thank you so much!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枕梦 2025-02-03 11:36:27

这是我的一种配置中的片段(apache/2.4.25):

<FilesMatch ".+\.ph(ar|p|tml)$">
     SetHandler application/x-httpd-php 
</FilesMatch>

在您的/etc/etcache_config_dir中尝试grep -r php

Here's a fragment from one of my configurations (Apache/2.4.25):

<FilesMatch ".+\.ph(ar|p|tml)
quot;>
     SetHandler application/x-httpd-php 
</FilesMatch>

Try grep -R php in your /etc/APACHE_CONFIG_DIR

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文