首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Linux+Nginx:NodeJS+WordPress+Symfony?

Linux+Nginx:NodeJS+WordPress+Symfony?
EN

Stack Overflow用户
提问于 2018-08-02 05:08:16
回答 1查看 0关注 0票数 0

我有一个具有Nginx运行节点和PHP的Ubuntu服务器。

  • www.example.com/->ReactiveApp(与PM2一起运行)
  • www.example.com/blog->运行WordPress博客
  • www.example.com/backend->运行一个Symfony应用程序,即API

已实现:

  • 应用程序与PM2反应
  • WordPress博客在/blog上运行,index.php重写。

问题:

本应在/后端运行的Symfony应用程序正在/后端/web/app上运行_php和app.php(生产模式)抛出一个500服务器错误。(截图附后)

Nginx配置如下:

代码语言:txt
复制
# Default Server Settings
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;
        index index.php app.php;

        server_name 100.100.100.100;

        location / {
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-NginX-Proxy true;
                proxy_pass http://localhost:3030/;
                proxy_ssl_session_reuse off;
                proxy_set_header Host $http_host;
                proxy_cache_bypass $http_upgrade;
                proxy_redirect off;
        }

        # WORDPRESS SETTINGS
        location @blog {
                rewrite ^/blog(.*) /blog/index.php?q=$1;
        }

        location /blog {
                index index.php
                alias /var/www/html/blog;
                try_files $uri $uri/ @blog;

                location ~ \.php$ {
                        include snippets/fastcgi-php.conf;
                        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
                }

                access_log /var/log/nginx/blog-access.log;
                error_log /var/log/nginx/blog-error.log;
        }

        # SYMFONY SETTINGS
        location @backend {
                rewrite ^/backend(.*)$ /web/app.php/$1 last;
        }

        location /backend {
                index app.php
                alias /var/www/html/backend/web;
                try_files $uri $uri/ @backend;

                location ~ \.php$ {
                         include snippets/fastcgi-php.conf;
                         fastcgi_pass unix:/run/php/php7.2-fpm.sock;
                }

                access_log /var/log/nginx/symposh-access.log;
                error_log /var/log/nginx/symposh-error.log;
        }

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

回答 1

Stack Overflow用户

发布于 2018-08-02 14:47:32

你可以使用下面的nginx配置-

代码语言:txt
复制
        # SYMFONY SETTINGS

        location /backend {
                index app.php;
                alias /var/www/html/backend/web;
                try_files $uri $uri/ /sf/app.php?$args;

                location ~ \.php$ {
                         include snippets/fastcgi-php.conf;
                         fastcgi_pass unix:/run/php/php7.2-fpm.sock;
                }

                access_log /var/log/nginx/symposh-access.log;
                error_log /var/log/nginx/symposh-error.log;
        }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100005896

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档