我用nginx + php-fpm和mysql获得服务器设置。 我有另一台服务器只有安装的PHP-FPM,所以想用作负载平衡。 但是,当我用php-fpm作为负载平衡器使用这个专用的服务器时,打开页面时出现错误:“拒绝访问”。
/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 0; 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 – 一切正常。
find你的php-fpmconfiguration(默认源安装位置是/usr/local/etc/php-fpm.conf),并确保listen.allowed_clients设置为允许你的Nginx框的IP。
如果这不能解决它,然后检查您的Nginx错误日志的进一步细节。
我重新编译了所有的PHP。 如果需要一些教程http://docs.moodle.org/en/Development:Install_Moodle_On_Ubuntu_with_Nginx/PHP-fpm