用于Angular前端和Laravel API的Nginx设置

问题描述

我已经在www目录中设置了前端Angular应用程序,并按照以下目录结构设置了Laravel后端应用程序。

/application
    /app
    /bootstrap
    /vendor   
    /public
        /api 
            index.PHP <-- Laravel "public" index

我当前使用以下设置。它不起作用。

server {
    listen 80;
    server_name my_domain.com www.my_domain.com;
    root /var/www/my_domain.com;

    index index.html index.htm index.PHP;

    location / {
        try_files $uri $uri/ /index.html;
    }

    location /api {
        root /var/www/my_domain.com/api/public;
        try_files $uri $uri/ /index.PHP?$args;
    }

    location ~ \.PHP$ {
        include snippets/fastcgi-PHP.conf;
        fastcgi_pass unix:/var/run/PHP/PHP7.4-fpm.sock;
     }

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

你能指出我的错误吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)