将Apache2设置为处理.html文件为PHP 8.0

发布于 2025-01-30 11:14:59 字数 833 浏览 2 评论 0原文

根据本Linode指南,我已经设置了PHP/Apache: https://www.linode.com/docs/guides/guides/install-php-8-for-apache-anpache-and-nginx-nginx-on-ubuntu/

我有一个可以使用文件的Apache服务器,并处理.php文件。

但是,我有最糟糕的时间来弄清楚如何告诉Apache使用.php来处理.html文件。我对.htaccess进行任何修改file.html“ rel =” nofollow noreferrer“> https://manage.accuwebhosting.com/knowledgebase/2492/parse-html-as-as-php-usish-htaccess-file.html 和类似。我还将所有设置为/var/www/目录/etc/apache2/apache2/apache2.conf中。此外,有关主题的大多数在线信息都指向.php的早期版本,而没有具体引用8.0

什么可以让Apache使用PHP 8.0来处理.html

I have setup php/apache according to this linode guide: https://www.linode.com/docs/guides/install-php-8-for-apache-and-nginx-on-ubuntu/

This seems to have worked, and I have an apache server that can serve files, and process .php files.

However, I am having the darndest time figuring out how to tell apache to process .html files with .php. Any modification I make to .htaccess (a-la- https://manage.accuwebhosting.com/knowledgebase/2492/Parse-HTML-As-PHP-Using-HTACCESS-File.html and similar) produce no change. I have also set AllowOverride All to the /var/www/ directory in /etc/apache2/apache2.conf. Additionally, most online information on the subject points to earlier versions of .php, with no specific reference to 8.0.

What can get apache to process .html with php 8.0?

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

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

发布评论

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

评论(1

淑女气质 2025-02-06 11:14:59

您需要为此提供模块,请确认您在httpd.conf中有此行,或在此处添加:

LoadModule mime_module modules/mod_mime.so

另外,请检查系统上存在Modules/mod_mime.so文件。

然后在httpd.conf中查找或添加模块部分:

<IfModule mime_module>
    # following line will change mime type of .html file to php
    # and they will be handled as such
    AddType application/x-httpd-php .html
</IfModule>

指令allowoverride all将启用.htaccess文件,但您也需要启用mime_module。

当然,在更改配置后,重新启动Apache服务器。

模块文档:在这里

You need to have module for this, confirm you have this line in httpd.conf, or add it there:

LoadModule mime_module modules/mod_mime.so

Also check if you have the modules/mod_mime.so file present on your system.

Then find or add module section in httpd.conf:

<IfModule mime_module>
    # following line will change mime type of .html file to php
    # and they will be handled as such
    AddType application/x-httpd-php .html
</IfModule>

Directive AllowOverride All will enable .htaccess files but you need the mime_module enabled too.

And of course restart the apache server after making configuration changes.

Module documentation: here

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