我在 ubuntu 服务器上的节点应用程序的标准端口 80 上运行 nginx。/etc/nginx/sites-available/default 是:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://localhost:3333;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Run Code Online (Sandbox Code Playgroud)
我已经安装了php7. 我想使用 nginx 在端口 8585 上提供 php 文件。因此 example.com:8585/info.php 指向文件系统上的 /var/www/html/info.php 。
如何解决这个问题呢?
您可以编写一个额外的服务器块
server {
listen 8585;
listen somename:8585;
server_name somename alias another.alias;
root html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Run Code Online (Sandbox Code Playgroud)