I'm fairly new to Nginx, and I'm attempting to import legacy sites from Apache. I want to get rid of the virtual directories but unfortunately I cannot.
The virtual directories point to the same root at the primary site. There is logic in the code that detects the virtual directory and loads data based on that information, which is why it's there.
Here is the config I'm attempting to get to work:
server {
listen 80;
large_client_header_buffers 4 32k;
server_name site.domain.com;
access_log /var/log/sites/site.access.log;
error_log /var/log/sites/site.error.log error;
location / {
root /var/www/php/site;
index index.php;
include /etc/nginx/conf.d/php.inc;
}
location /sitea {
root /var/www/php/site;
index index.php;
include /etc/nginx/conf.d/php.inc;
}
location ~ /\.ht {
deny all;
}
}
Contents of php.inc:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
I have tried every thing that google has to offer to get this to work, but no matter what I do I continue to get the following error:
2018/11/15 20:28:32 [debug] 5056#5056: *1 http script var: "/sitea/index.php"
2018/11/15 20:28:32 [debug] 5056#5056: *1 trying to use file: "/sitea/index.php" "/var/www/php/site/sitea/index.php"
2018/11/15 20:28:32 [debug] 5056#5056: *1 trying to use file: "=404" "/var/www/php/site=404"
2018/11/15 20:28:32 [debug] 5056#5056: *1 http finalize request: 404, "/sitea/index.php?requestType=home" a:1, c:1
2018/11/15 20:28:32 [debug] 5056#5056: *1 http special response: 404, "/sitea/index.php?requestType=home"
2018/11/15 20:28:32 [debug] 5056#5056: *1 http set discard body
2018/11/15 20:28:32 [debug] 5056#5056: *1 xslt filter header
2018/11/15 20:28:32 [debug] 5056#5056: *1 HTTP/1.1 404 Not Found
Any help towards the right direction will be appreciated.
Note: it also does the same thing using the alias vs root
With alias I get the following:
2018/11/15 20:37:38 [error] 5189#5189: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: #.#.#.#, server: site.domain.com, request: "GET /sitea/index.php?requestType=home HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "site.domain.com"
Possible Solution
I'm not sure if this is the proper way of doing it, but it worked.
If I created a symbolic link for the virtual directory in the main folder the site loaded. I'd rather do this in Nginx, but if I have to go this route I will. Thoughts?