分开部署nginx和php-fpm实例测试

生活总是有很多出人意料的事情,比如,你以为我要举个例子。

php-fpm

  • IP : 47.104.245.210
  • 部署了php-fpm,并成功开启9000端口的访问权限
  • 部署了相关业务代码(/app/www/pandora_php_v1)

nginx

  • IP : 47.104.89.216
  • 部署了nginx
  • 配置文件
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    server {
    listen 80;
    #listen 443 ssl http2;
    server_name api2019.dazhi.com;
    root "/app/www/pandora_php_v1/public"; # 这里的目录是php-fpm服务器的代码目录

    index index.html index.htm index.php;

    charset utf-8;

    location / {
    try_files $uri $uri/ /index.php?$query_string;
    }



    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt { access_log off; log_not_found off; }

    access_log off;
    error_log /var/log/nginx/api2019.dazhifund.com.log error;

    sendfile off;

    client_max_body_size 100m;

    location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass 47.104.245.210:9000; # php-fpm环境的地址
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


    fastcgi_intercept_errors off;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 4 16k;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    }

    location ~ /\.ht {
    deny all;
    }
    }

  • 检查端口是否可以访问: telnet 47.104.245.210 9000
  • 重启nginx, nginx -s reload