【问题标题】:Execute php in html file "Apache 2.4", "php-fpm" on Centos 6.9在 Centos 6.9 上执行 html 文件“Apache 2.4”、“php-fpm”中的 php
【发布时间】:2018-12-20 16:56:17
【问题描述】:

您能帮我们在 html 文件中执行 php。由于我们在 centos 6.9(64 位)上使用 Apache 2.4,php-fpm。我们使用下面的代码将 php 作为 html 执行,但我认为它不正确。

我在/opt/rh/httpd24/root/etc/httpd/conf/httpd.conf 文件中添加了以下代码:

# 2.4.10+ can proxy to unix socket # SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"

# Else we can just use a tcp socket:
SetHandler "proxy:fcgi://127.0.0.1:9000"

# 2.4.10+ can proxy to unix socket # SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"

# Else we can just use a tcp socket:
SetHandler "proxy:fcgi://127.0.0.1:9000"

现在我可以在 htm 文件中执行 php,但每个 htm 文件都呈现为 php。所以任何机构都可以帮助解决这个问题。

我们想通过handler执行html文件中的php。

【问题讨论】:

  • 旁注:尝试清理您的代码,但您似乎粘贴了两次相同的代码?

标签: php centos6 apache2.4


【解决方案1】:

看这里:https://www.server-world.info/en/note?os=CentOS_6&p=httpd&f=25

用这个替换“AddHandler”:

AddHandler php-fastcgi .php .htm .html

这应该可以解决您的问题。

【讨论】:

    猜你喜欢
    • 2018-12-24
    • 2020-12-09
    • 2014-12-09
    • 2021-10-10
    • 1970-01-01
    • 2013-06-05
    • 2014-11-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多