繁体   English   中英

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

[英]How to run php on non-standard port in nginx?

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM