Bitnami LAMP 堆栈 .htmaccess 不工作

Posted

技术标签:

【中文标题】Bitnami LAMP 堆栈 .htmaccess 不工作【英文标题】:Bitnami LAMP stack .htmaccess not working 【发布时间】:2021-05-16 09:07:26 【问题描述】:

我正在尝试将我的网站迁移到 Google Cloud Platform 中的 Bitnami LAMP 标准堆栈。 在我的旧 Apache 服务器中,我使用 .htaccess 和命令:

AddHandler application/x-httpd-php .html

如果我没有该文件 .htaccess,则网站无法正常运行。 当我将 .htaccess 文件复制到 /htdocs 时,网站停止工作 关于 Bitnami 如何与 .htaccess 一起工作的任何线索? (我有几天的时间试图找到解决方案)

【问题讨论】:

【参考方案1】:

这里是 Bitnami 工程师,

我不知道您使用的 Bitnami LAMP 版本,以及您是否将自定义应用程序部署在 /opt/bitnami/apache2/htdocs 文件夹或任何其他文件夹中,但我们建议您检查 Apache 的配置文件(取决于LAMP 版本以及您如何部署应用程序:/opt/bitnami/apache2/conf/bitnami/、/opt/bitnami/apache2/conf/vhosts/ 或 /opt/bitnami/apps/yourcustomapp/conf /*) 并查看“AllowOverride”参数是否设置为“All”。

https://httpd.apache.org/docs/2.4/mod/core.html#allowoverride

确认后,请确保您在浏览您的网站时正在访问这些文件。最后,请查看我们文档中的本指南,其中我们解释了如何将 .htaccess 信息移动到 Apache 的 conf 文件以提高网站的安全性和性能。

https://docs.bitnami.com/google/infrastructure/lamp/administration/use-htaccess/

该指南基本上解释了如何将 .htaccess 信息移动到一个 htaccess.conf 文件中,您可以在其中设置相同的规则

<Directory "your/htdocs/folder">
   AddHandler application/x-httpd-php .html
</Directory>

将它包含在 Apache 的 conf 文件夹中

Include "path/to/the/htaccess.conf"

然后重启 Apache

sudo /opt/bitnami/ctlscript.sh restart apache

【讨论】:

以上是关于Bitnami LAMP 堆栈 .htmaccess 不工作的主要内容,如果未能解决你的问题,请参考以下文章

修复:AWS Bitnami LAMP 堆栈错误中的 Laravel Git 克隆

在 Google Cloud VM 上重置丢失的 Bitnami LAMP 堆栈密码

在 Bitnami LAMP 堆栈中设置和访问 PHP-FPM 状态页面

无法在 Bitnami LAMP 堆栈上使用 Cron 运行 PHP Artisan 命令

使用 Bitnami 与使用本机服务器堆栈有啥缺点吗?

AWS Lightsail Bitnami LAMP - 安装第二个 Wordpress 模块不起作用