0

I am trying to configure Wordpress and Laravel within Nginx, but am struggling to get the configuration right.

Wordpress is installed in /var/www/site/blog Laravel is installed in /var/www/site/exam

Navigating the the site.local brings up the wordpress site, but site.local/laravel shows "No input file specified." Looking in the error logs: Unable to open the primary script: /var/www/site/exam/public//exam/index.php which is the alias plus the location, whereby the script location is /var/www/site/exam/public/index.php

Any feedback will be appreciated. See config file below:

server {
    listen 80;
    server_name site.local;
    root /var/www/site/blog;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.php index.html;
    error_page 404 /index.php;

    access_log off;
    error_log  /var/log/nginx/site.local-error.log error;

    sendfile off;

    charset utf-8;

    #laravel
    location /exam/ {       
        alias /var/www/site/exam/public/;
        try_files $uri $uri/ /index.php?$args;                  

        location ~ \.php$ {                         
            fastcgi_pass unix:/run/php-fpm/php-fpm.sock;            
            fastcgi_index index.php;

            include fastcgi_params;
        }   
    }
    

    #blog
    location / {                
        try_files $uri $uri/ /index.php?$args;                              
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }

    location ~ \.php$ {     
            fastcgi_pass unix:/run/php-fpm/php-fpm.sock;            
            fastcgi_index index.php;

            include fastcgi_params;
    }
}

1 Answers1

0

I think you need to change location like this

   location /laravel {
    ...
    ...
   }
  • Thanks but this doesn’t work. The issues seems to be php-fpm is expecting the script location to have the location amended to the alias, where the actually location is just the alias. – user3313446 Jul 20 '20 at 13:23