Как мне развернуть Laravel 5.7 и Angular 7 на Nginx на сервере? - PullRequest
0 голосов
/ 19 февраля 2019
server {
    listen 80;
    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;
    server_name example;

     location / {

    index index.html;
    try_files $uri $uri/ /index.html =404;

      }

      location /api {

    root /var/www/html/example/public;
    try_files /index.php =404;

    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $request_filename;
    fastcgi_param APP_ENV dev;
    fastcgi_pass 127.0.0.1:9000;

     }

выше - это конфигурация моего сервера, но работает только угловой, но laravel недоступен, он продолжает показывать не найденным

1 Ответ

0 голосов
/ 20 февраля 2019

После прочтения документации Nginx о обработке запроса и использовании псевдоним .Я придумал следующее:

server {
    listen 80;
    server_name example.com;

    # This is the "last resort" nginx will direct to when no other matches with location have been found.
    # It will only look for a file named index.html
    location / {
        root /location/of/angular;
        index index.html;

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

    # All requests that start with /api are directed to the laravel location.
    # It will only look for a file named index.php
    location /api {
        alias /location/of/laravel;
        index index.php;

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

    # All files that end with .php are through fastcgi
    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_param APP_ENV dev;
        fastcgi_pass 127.0.0.1:9000;
    }
}

Sidenote: это не было проверено в рабочей среде, но может помочь вам в правильном направлении.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...