本文介绍了HTML文件作为PHP中的Nginx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有关使用PHP作为Apache模块Web服务器:
For web servers using PHP as apache module:
AddType application/x-httpd-php .html .htm
有关运行PHP,CGI的Web服务器:
For web servers running PHP as CGI:
AddHandler application/x-httpd-php .html .htm
我有一个Nginx的服务器,我想运行的.js文件,和.htm文件作为PHP的,所以我会在他们里面完整的PHP code。任何人都知道如何配置Nginx的这样做呢?
I have an Nginx server and I want to run .js files and and .htm files as PHP, so I will have full PHP code inside them. Anyone know how to configure the Nginx to do this?
推荐答案
实例的.htm,.html文件
Example for .htm, .html files
location ~ \.htm$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.htm;
include fastcgi.conf;
}
实例的.js文件
Example for .js files
location ~ \.js$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
只是,如果需要更改扩展名和端口设置
just change the extension and port settings if needed
这篇关于HTML文件作为PHP中的Nginx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!