【发布时间】:2016-03-06 06:06:17
【问题描述】:
美好的一天,我想在同一台服务器上处理 php 文件和 html,我希望 html 文件处理端口 8080 上的节点,而 php 文件处理 php5 服务。我这样写了 nginx 配置:
server {
listen 80 default_server;
root /home/examle/public_html;
index index.php index.html index.htm;
server_name www.examle.com examle.com;
location ~ \.html$ {
proxy_pass http://localhost:8080;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
但是当打开 html 页面时,nodejs 没有处理包含在 html 页面中的节点 javascript。如何在同一台服务器上同时处理 php 和 html 两种类型的文件?
【问题讨论】:
-
当你打开 sample.html 会发生什么?第404章?
-
页面打开但节点根本不处理javascript,如果打开example.com:8080/sample.html页面显示完美!
标签: javascript php html node.js nginx