You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This FAQ suggests the following nginx configuration to serve Lychee from a subdirectory:
location ^~ /lychee {
alias /var/www/lychee/public;
index index.php;
try_files$uri$uri/ @lychee;
location ~ \.php$ {
if (!-e $request_filename) {
rewrite^/lychee/?(.*)$ /lychee/index.php?/$1 last;
break;
}
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}
location@lychee {
rewrite/lychee/(.*)$ /lychee/index.php?/$1 last;
}
I'm new to nginx, and I'm not sure I fully understand how this works.
Why the two separate rewrite rules, one in location @lychee invoked by try_files and one in if (!-e $request_filename)? I tried with the latter commented out and it still seemed to work.
Why location ~ \.php$? AFAICS Lychee has only one PHP file, index.php.
What is fastcgi_index index.php for? According to the documentation, it does something with $fastcgi_script_name. But I used log_format to view the value of $fastcgi_script_name and it looked correct (/lychee/index.php). Removing fastcgi_index didn't change anything.
Why the location ^~ /lychee instead of location /lychee?
This seems to be working for me:
location/lychee {
alias /var/www/selim/lychee/public;
index index.php;
try_files$uri$uri/ @lychee;
location/lychee/index.php {
include fastcgi-include.conf;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}
location@lychee {
rewrite/lychee/(.*)$ /lychee/index.php?/$1 last;
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This FAQ suggests the following nginx configuration to serve Lychee from a subdirectory:
I'm new to nginx, and I'm not sure I fully understand how this works.
Why the two separate
rewrite
rules, one inlocation @lychee
invoked bytry_files
and one inif (!-e $request_filename)
? I tried with the latter commented out and it still seemed to work.Why
location ~ \.php$
? AFAICS Lychee has only one PHP file,index.php
.What is
fastcgi_index index.php
for? According to the documentation, it does something with$fastcgi_script_name
. But I usedlog_format
to view the value of$fastcgi_script_name
and it looked correct (/lychee/index.php
). Removingfastcgi_index
didn't change anything.Why the
location ^~ /lychee
instead oflocation /lychee
?This seems to be working for me:
Beta Was this translation helpful? Give feedback.
All reactions