[英]How to have html files scanned by php as CGI?
I never worked with php as CGI so I have encounter a problem. 我从未使用过php作为CGI,因此遇到了问题。 I need execute php on html files. 我需要在html文件上执行php。 I tried to add instructions into .htaccess: 我试图将指令添加到.htaccess中:
AddHandler cgi-script .htm .html
This didn't work: 这不起作用:
AddType application/x-httpd-php5 html
Nor did this: 这也没有:
AddType application/x-httpd-php .php .htm .html .phtml
I tried editing the httpd.conf by replacing 我尝试通过替换来编辑httpd.conf
AddHandler cgi-scripts .cgi .pl .plx .ppl .perl
with 与
AddHandler cgi-scripts .cgi .pl .plx .ppl .perl .html
I then restarted apache, but this didn't help either. 然后,我重新启动了Apache,但这也没有帮助。
Could you guide me to the right path? 您能引导我走正确的道路吗?
Here is what am I using at the moment for two different php versions: (in httpd.conf) 这是我目前使用的两个不同的php版本:(在httpd.conf中)
#PHP4 - for legacy projects
AddType application/x-httpd-php4 .php4 .php3 .phtml .inc
Action application/x-httpd-php4 "/usr/local/php-4.4.4/bin/php-cgi"
<Directory /usr/local/php-4.4.4/bin>
Order allow,deny
Allow from all
</Directory>
#PHP5 - default
AddType application/x-httpd-php5 .php .php5
Action application/x-httpd-php5 "/usr/local/php-5.3.8/bin/php-cgi"
<Directory /usr/local/php-5.3.8/bin>
Order allow,deny
Allow from all
</Directory>
As you can see there are 3 parts for each cgi handler: 如您所见,每个cgi处理程序分为3部分:
You can find the instructions on how to configure the Apache web server for CGI scripts in Apache's documentation . 您可以在Apache的文档中找到有关如何为CGI脚本配置Apache Web服务器的说明 。
On the page, they use Perl as the programming language for the CGI scripts, but the process is the same for every language. 在页面上,他们使用Perl作为CGI脚本的编程语言,但是每种语言的处理过程都是相同的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.