如何在nginx的非标准端口上运行php?

如何在nginx的非标准端口上运行php?,php,nginx,Php,Nginx,我在ubuntu服务器上的节点应用程序的标准端口80上使用nginx/etc/nginx/可用站点/默认为: server { listen 80; server_name example.com; location / { proxy_pass http://localhost:3333; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade;

我在ubuntu服务器上的节点应用程序的标准端口80上使用nginx/etc/nginx/可用站点/默认为:

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;
     }
}
我已经安装了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;
    }
}

您可以编写一个附加服务器块

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;
    }
}