微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Nginx负载均衡与专用的php-fpm服务器

我用Nginx PHP-fpm和mysql安装了服务器.
我有另一台服务器只安装了PHP-fpm,所以想用作负载平衡.
但是当我使用这个带有PHP-fpm的dedacted服务器作为负载均衡器时,我在打开页面时遇到错误:“拒绝访问”.

/etc/Nginx/Nginx.conf

user www-data;
worker_processes  3;

error_log  /var/log/Nginx/error.log;
pid        /var/run/Nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    server_names_hash_bucket_size 64;
    access_log  /var/log/Nginx/access.log;

    sendfile        on;
    #tcp_nopush      on;

    keepalive_timeout   65;
    tcp_nodelay         on;

    #gzip                on;

    upstream PHP {
        server dedicatedserverip:9000;
    }

    include /etc/Nginx/sites-enabled/*;
}

/etc/Nginx/sites-enabled/site.org.conf

server {
    listen   81;
    server_name site.org www.site.org;
    access_log  /var/log/Nginx/site.org.log;
    error_log   /var/log/Nginx/site.org.log;
    root        /home/www/site.org;
    index       index.PHP; 

    location ~ .PHP${
        fastcgi_pass  PHP;
        fastcgi_index index.PHP;
        fastcgi_param SCRIPT_FILENAME /home/www/$fastcgi_script_name;
    }
} 

为什么我收到此错误?当我只将fastcgi_pass更改为127.0.0.1:9000时 – 一切正常.

解决方法:

如果它是一个带有“拒绝访问”的空白页面,则由security.limit_extensions directive引起的已添加PHP-fpm.

如果你没有在你的PHP-fpm配置中使用它,它认为.PHP并防止所有其他文件类型被PHP解释器解析,在尝试这样做时产生“拒绝访问”.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐