The main static website (mirror) is located in: /home/mirrors/mirror
I'm trying setup PHP website only in the subdirectory /home/mirrors/mirror/phpweb/
. So far it loads PHP, but all the images, css and url links point to /home/mirrors/mirror/filename*
instead of /home/mirrors/mirror/phpweb/filename*
I've tried with:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
But that results in error logs showing:
FastCGI sent in stderr: "Unable to open primary script: /home/mirrors/mirror/phpweb/phpweb/index.php
The closest to working config is the incorrect way of setting the path with:
fastcgi_param SCRIPT_FILENAME /home/mirrors/mirror$fastcgi_script_name;
What am I overlooking? Here's the entire config. Basically it works except that images/css/js are not pointed to the phpweb/ directory. My config seems to be missing some lines that will allow statics inside of root /home/mirrors/mirror/phpweb; to point to that folder.
server {
listen 80;
listen 443 ssl http2;
server_name mirrors.domain.com;
if ($scheme = http) {
return 301 https://$http_host$request_uri;
}
location / {
root /home/mirrors/mirror;
index index.html index.htm;
include /home/mirrors/Nginx-Fancyindex-Theme/fancyindex.conf;
}
location /phpweb {
root /home/mirrors/mirror/phpweb;
index /phpweb/index.php;
}
location ~ /phpweb/.*\.php$ {
root /home/mirrors/mirror/phpweb;
# try_files $uri =404;
# try_files $uri $uri/ =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/mirrors/mirror$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Here's where I found a config example.
UPDATE: Here's updated config:
server {
listen 80;
listen 443 ssl http2;
server_name mirrors.domain.com;
root /home/mirrors/mirror;
if ($scheme = http) {
return 301 https://$http_host$request_uri;
}
location / {
index index.html index.htm;
include /home/mirrors/Nginx-Fancyindex-Theme/fancyindex.conf;
}
location /phpweb {
index /phpweb/index.php;
}
location ~ /phpweb/.*\.php$ {
try_files $uri =404;
# try_files $uri $uri/ =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param SCRIPT_FILENAME /home/mirrors/mirror/phpweb$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Which results in:
Warning: include(/home/mirrors/mirror/include/site.inc): failed to open stream: No such file or directory in /home/mirrors/mirror/phpweb/include/prepend.inc on line 78
Warning: include(): Failed opening '/home/mirrors/mirror/include/site.inc' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/mirrors/mirror/phpweb/include/prepend.inc on line 78
Warning: include(/home/mirrors/mirror/include/langchooser.inc): failed to open stream: No such file or directory in /home/mirrors/mirror/phpweb/include/prepend.inc on line 81
Warning: include(): Failed opening '/home/mirrors/mirror/include/langchooser.inc' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/mirrors/mirror/phpweb/include/prepend.inc on line 81
Warning: include(/home/mirrors/mirror/include/ip-to-country.inc): failed to open stream: No such file or directory in /home/mirrors/mirror/phpweb/include/prepend.inc on line 84
Warning: include(): Failed opening '/home/mirrors/mirror/include/ip-to-country.inc' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/mirrors/mirror/phpweb/include/prepend.inc on line 84
Warning: include(/home/mirrors/mirror/include/layout.inc): failed to open stream: No such file or directory in /home/mirrors/mirror/phpweb/include/prepend.inc on line 87
Warning: include(): Failed opening '/home/mirrors/mirror/include/layout.inc' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/mirrors/mirror/phpweb/include/prepend.inc on line 87
Warning: include(/home/mirrors/mirror/include/last_updated.inc): failed to open stream: No such file or directory in /home/mirrors/mirror/phpweb/include/prepend.inc on line 92
Warning: include(): Failed opening '/home/mirrors/mirror/include/last_updated.inc' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/mirrors/mirror/phpweb/include/prepend.inc on line 92
Warning: include_once(/home/mirrors/mirror/include/releases.inc): failed to open stream: No such file or directory in /home/mirrors/mirror/phpweb/include/branches.inc on line 2
Warning: include_once(): Failed opening '/home/mirrors/mirror/include/releases.inc' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/mirrors/mirror/phpweb/include/branches.inc on line 2
Warning: include_once(/home/mirrors/mirror/include/version.inc): failed to open stream: No such file or directory in /home/mirrors/mirror/phpweb/include/branches.inc on line 3
Warning: include_once(): Failed opening '/home/mirrors/mirror/include/version.inc' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/mirrors/mirror/phpweb/include/branches.inc on line 3
Fatal error: Call to undefined function mirror_setcookie() in /home/mirrors/mirror/phpweb/index.php on line 44
Previously (original config pasted in this post) there we no php errors and the page loads. But images/statics were broken as described above.