V
V
Viktor Yanyshev2019-06-03 23:09:09
Nginx
Viktor Yanyshev, 2019-06-03 23:09:09

Why "Primary script unknown" at different locations?

I need to run 2 applications on different URLs on 1 domain. The first one is vue.js (location /), the second one is Yii2. Now the vue application opens normally along the app.loc/ path, but the app.loc/api path in the nginx logs reports "Primary script unknown" .
Why is the path not being passed correctly to php-fpm and how can I fix it?

nginx config
server {
    charset utf-8;
    client_max_body_size 128M;

    listen 80; ## listen for ipv4
    #listen [::]:80 default_server ipv6only=on; ## слушаем ipv6

    server_name app.loc;
    root        /home/user/app;
    index       index.html index.php;

    access_log  /var/log/nginx/app.access.log;
    error_log   /var/log/nginx/app.error.log;

    location /api {
      root /home/user/app/api/web;
      try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include fastcgi.conf;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }

    location / {
      root /home/user/app/dist; 
      try_files $uri $uri/ /index.html;
    }

    location ~ /\.(ht|svn|git) {
        deny all;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TyzhSysAdmin, 2019-06-03
@POS_troi

It tells you that it cannot find the index file specified in the settings, see the php-fpm logs (respectively, they must be enabled in the config), as an option also
Enable logs
https://github.com/rlerdorf/php7dev/issues/48
And you will culturally see where requests go and what is not in place.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question