微信小程序PHP服务端Nginx配置

下面的/var/www/dbmz/server为小程序的PHP服务端目录
需要添加一个/weapp/的路由映射到小程序的server根目录

server {
  listen       80;
  server_name  a.com;
  root         /var/www/dbmz/server;
  index        index.php index.html;
  location / {
    try_files $uri $uri/ =404;
  }
  
  location ~* \.php$ {
    fastcgi_pass 127.0.0.1:9000;
    include         fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
  }

  location /weapp/ {
    root   /var/www/dbmz/server;
    index  index.html index.htm index.php;
    try_files $uri $uri/ /index.php;
  }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/a.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/a.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

你可能感兴趣的:(微信小程序PHP服务端Nginx配置)