設定 Apache2 以 php 8.0 的方式處理 .html 文件
P粉670838735
P粉670838735 2024-01-16 11:25:21
0
1
403

我已經根據此 linode 指南設定了 php/apache:https://www.linode.com/docs/guides/install-php-8-for-apache-and-nginx-on-ubuntu/

這似乎有效,我有一個 apache 伺服器,可以提供檔案服務,並處理 .php 檔案。

但是,我正在花時間弄清楚如何告訴 apache 使用 .php 處理 .html 檔案。我對.htaccess (a-la- https://manage.accuwebhosting.com/knowledgebase/2492/Parse-HTML-As-PHP-Using-HTACCESS-File.html 等)所做的任何修改都不會產生任何變化。我還將 AllowOverride All 設定為 /etc/apache2/apache2.conf 中的 /var/www/ 目錄。此外,大多數有關該主題的線上資訊都指向 .php 的早期版本,沒有具體提及 8.0

什麼可以讓apache用 8.0處理.html

P粉670838735
P粉670838735

全部回覆(1)
P粉373990857

您需要為此模組,確認您在 httpd.conf 中有此行​​,或將其新增至其中:

LoadModule mime_module modules/mod_mime.so

另請檢查您的系統上是否存在 modules/mod_mime.so 檔案。

然後在httpd.conf中找到或新增模組部分:


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

指令 AllowOverride All 將啟用 .htaccess 文件,但您還需要啟用 mime_module。

當然,在更改配置後重新啟動 apache 伺服器。

模組文件:此處

#
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!