I configured a vps server with nginx, php-fpm and apache on it.
with .html extension as static web pages like , but when I try to use .php page which dynamically generate content I see only pure html code like Nginx is serving .txt file. 具有.html扩展名的 像一样作为静态网页进行服务器处理,但是当我尝试使用.php页面来动态生成内容时,我看到只有纯html代码(例如Nginx)正在提供.txt文件。
Nginx listens on 80, Apache on 8080.
Mods disabled: mod_proxy, mod_actions
Nginx server block configuration:
server {
server_name example.com www.example.com;
listen 80;
root /var/www/example.com;
index index.php;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://IP:8080;
}
}
Apache virtual host configuration:
<VirtualHost *:8080>
DocumentRoot /var/www/example.com
ServerName example.com
<Directory />
AllowOverride All
</Directory>
</VirtualHost>
Nginx & Apache both work under %username%, using %username% as group too.
Code seems to be correct, but the problem is when I load webpage example.com/index.php it is loaded like a .txt file with pure html code instead of normal .php page.
Same with info.php with usual "<?php phpinfo(); ?>"
info . 信息 。
You need to configure either nginx
or Apache to send the file to the php interpreter.
See this document to use nginx
and php-fpm
with the fastcgi_pass
directive.
See this document to use Apache and mod_php
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.