Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

camillele's avatar

Managing Laravel API & Angular front-end in NGINX

I have configured my Laravel API with Angular front-end in my Nginx server as the following. But the Laravel API is not working. Can you help me in configuring the 2 apps properly.

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 {
        alias /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;
    }

}

0 likes
1 reply
ITwrx's avatar

You're not saying much about your overall config, what errors you're receiving, etc. but nginx is probably not able to pass the php related requests to php successfully. i would check your distro's documentation on php and nginx to see how to connect them, as this can depend on what software/methods you choose to use. If your distro has lame docs, then you might see the Arch wiki and extrapolate accordingly. Maybe try to serve a phpinfo.php file before worrying about the api. Double check where php is actually listening, that it's running, etc.

Please or to participate in this conversation.