0

I've read the other posts but I can't get it. I have a Laravel app (listingnaples.test) in one directory and a Wordpress (blog.listingnaples.test) in another to keep things separately.

http://listingnaples.test works.

http://blog.listingnaples.test works.

http://listingnaples.test/blog/ should redirect but gives the "No input file specified" error.

Hopefully it doesn't matter for the answer but this is a Homestead box in Laravel for local development. Here is the server block:

block="server {
    listen ${3:-80};
    listen ${4:-443} ssl http2;
    server_name .$1;
    root \"$2\";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files \$uri \$uri/ /index.php?\$query_string;
        $headersTXT
    }

    $configureZray

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/$1-error.log error;

    sendfile off;

    client_max_body_size 100m;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php$5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
        $paramsTXT

        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
    }

    location ~ /\.ht {
        deny all;
    }
    location /blog/ {
        access_log off;
        proxy_pass http://blog.listingnaples.test;
    }
    ssl_certificate     /etc/nginx/ssl/$1.crt;
    ssl_certificate_key /etc/nginx/ssl/$1.key;
}

EDIT: ERROR LOG

The error log has these lines in it:

2018/11/26 21:09:28 [emerg] 600#600: location "/blog/" is outside location "\.php$" in /etc/nginx/sites-enabled/blog.listingnaples.test:50 2018/11/26 21:27:01 [emerg] 7798#7798: invalid URL prefix in /etc/nginx/sites-enabled/listingnaples.test:49 2018/11/26 21:51:48 [emerg] 23588#23588: invalid URL prefix in /etc/nginx/sites-enabled/listingnaples.test:49

EDIT 2: That's not where the code is

2018/11/26 21:25:41 [error] 5392#5392: *11 FastCGI sent in stderr: "Unable to open primary script: /home/vagrant/code/ln/public/blog/index.php (No such file or directory)" while reading response header from upstream, client: 192.168.10.1, server: listingnaples.test, request: "GET /blog/index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host: "listingnaples.test"

The blog isn't in /home/vagrant/code/ln/public/blog/index.php. It is in /home/vagrant/code/blog.listingnaples.com/index.php

It's therefor trying to redirect I guess but to the wrong directory altogether.

Normally a hint would help me but now I'm more confused.

Chris Farrugia
  • 1,024
  • 3
  • 17
  • 35
  • Do you want to access your blog as `blog.example.com` or `example.com/blog`. WordPress can be configured to do either, but not at the same time. It would be easy to fix `example.com/blog`, but it will break `blog.example.com`. – Richard Smith Nov 27 '18 at 08:51
  • Thanks Richard. I want to access it as example.com/blog. In fact, I'd never access it the other way. – Chris Farrugia Nov 27 '18 at 13:35
  • Your main problem is `location /blog` should be `location ^~ /blog` to avoid looking for WordPress `.php` files under Laravel's root. But if both apps run on the same Nginx instance, you might consider using `alias` instead of `proxy_pass` (such as in [this answer](https://stackoverflow.com/questions/47319049/nginx-subdirectory-root-with-php/47332159#47332159)). – Richard Smith Nov 27 '18 at 14:00

0 Answers0