file not found
I'm using my own router and want everything to work trough the index.php
But i get the message file not found idk which file they mean since i'm just echoing hello as a test
Solution:Jump to solution
https://test-service2.up.railway.app/
https://test-service2.up.railway.app/test
```
NIXPACKS_PHP_ROOT_DIR=/app/public...
130 Replies
Project ID:
5a0ee64c-4acb-4b7a-a156-b53fd08e9edd
5a0ee64c-4acb-4b7a-a156-b53fd08e9edd
NIXPACKS_PHP_FALLBACK_PATH=/index.php
NIXPACKS_PHP_ROOT_DIR=public
beat me to it
applicable docs link https://nixpacks.com/docs/providers/php#php
I already followed the docs
thats why im asking here
oh so you already have those variables set and you are getting a 404?
.
I'm not getting a 404
im getting the literal message file not found
how is that not the same as 404 lol
I thought you meant the nginx 404 view
my bad
but ok its a so called 404
what does your project structure look like?
well
a public
folder for my routing
with a index.php
an app folder
and a views folder
thats it
and some other files like composer.json
I did this before and it worked.
idk why not rn
so your root directory is the project directory itself?
what do you mean
the root directory of your php app is just the root directory of the project?
no
please show me your project structure
inside public
idk what this is
lol
i used this before and it worked perfectly fine
so weird
you already have these set, correct?
yes
@aleks - any ideas here?
I even tried a clean folder
made a new folder called public with a index.php
just a message saying hello
and still the same issue
where have you set those nixpacks variables?
in my variable tab
is your build detected as php?
yes
show me please
like that right
yes
show the specific error you get?
gotcha
this is so weird
we shall wait for aleks
is aleks an expert
yes
he wrote the php provider
oh nice
it worked before
perhaps something changed
uh
i still didnโt fix it
could you try
@Brody
making a new project with same file structure
and see if it works on your end
dont know php
oh
<?php
echo โmessageโ;
๐
wheres the closing tag
you donโt need it if youโre purely writing php
sometimes if you close a php file with only php in it you could cause issues
told you I didn't know php
thas ok
you probably know other stuff
that I donโt
have you tried to do what you're asking me to do?
yes
still file not found
I worked with railway before and had zero issues
what's your root dir set to
public
fallback path index
what
show me the raw editor for these variables please
okay iโll finish my pizza first if you donโt mind
haha ofc not
NIXPACKS_PHP_FALLBACK_PATH=/index.php
NIXPACKS_PHP_ROOT_DIR=public
there
shouldn't it be
/public
i tried both
have you tried setting the fallback path to
/public/index.html
no i'll try that
i read this before
still file not found
we will have to wait for aleks then
hmm
Try using
/app/public
as a root directory.okay
will do so now
if i remove nixpacks variables
and put my index outside public it works
Well, it should work on
/
, but if you don't have FALLBACK_PATH
set it won't work on other paths
but ROOT_DIR
defaults to /app
, which is where Nixpacks puts your project in the built containeroh
so like /app/public
and fallback path to index.php
(
ROOT_DIR
is relative to the filesystem root, not the project root)yes I understand
yes, that should do it
should probably add that to the docs
Its ok
so like fallback just to index.php
/index.php
root to /app/public
It worked before as the way I did it
just
index.php
, not /index.php
okay
it works
how could i not discover this myself ;/
Hooray! ๐
but
when i want to go to another route
i get file not found again
Huh.
only /
works
when i wanna do /example (for example)
Where are you seeing file not found? In the browser or in the logs?
i get file not found again
browser
Hmm, it looks like this is a misconfiguration in the PHP provider that I've never run into before
not sure why I never ran into this before
damn
no, never mind, it's not that
hmm
Is 'file not found' the only thing you're seeing? Is there anything in the logs?
in deploy logs?
yes
@aleks have you changed some stuff in the last months
my last project had zero issues
These are the only recent ones - the only major one is the Perl -> JS transition, and I thought I had tested that to make sure that functionality was equivalent
I see
is there a possible way i could do it trough nginx config?
You can add a custom nginx config - just put an nginx.conf in your project and it'll be used
okay i'm not familar with that but i'll see if i can make it work
Alright, sorry I couldn't help with the PHP provider
Let me send an nginx config that should work
put this in
nginx.template.conf
in your project:
There are some pitfalls with this configuration due to Nix, try the one aboveokay
can i delete the nix variables
What do you mean?
Oh, I see, yes, you can
okay thanks
still getting file not found
im confused
in my root
Kind of shooting in the dark here, but maybe this'll work?
.
iโll try 1 sec
file not found from index now
this is so weird
I don't know what's going on here, you'd probably have more luck asking in a PHP community
Sorry
its ok ty for trying
I hope you could or someone else fix it in the future
back to when it worked fine
๐
this just a misconfiguration
i always configured like this
and it always worked
unfortunately that's doesn't mean it's not a misconfiguration
from whose end
mine?
yeah
how lol
when im literally doing the things i always did and it just doesnt wanna work
I'm not sure what's being done wrong, sorry
imma start a new repo
and see what happens
after a few tests
i notice
NIXPACKS_PHP_FALLBACK_PATH=/index.php
this is acting up
i tried /app/public/index.php
/public/index.php but no luck sadly
you tried just
index.php
without the /
, right?yes
same message
i give up for now
Solution
my folder structure is
it works?????????
was it because mine was
NIXPACKS_PHP_FALLBACK_PATH=/index.php
NIXPACKS_PHP_ROOT_DIR=/app/public
instead of
NIXPACKS_PHP_ROOT_DIR=/app/public
NIXPACKS_PHP_FALLBACK_PATH=/index.php
no
then what
I don't know
.
im confused
I did what you asked me to and it works, you're doing something wrong somewhere else
wish I knew what that something was though
It also worked on my test application
when i used this
.
https://railway-test-production-e88a.up.railway.app/
https://railway-test-production-e88a.up.railway.app/test
That should not affect it, but glad it's fixed!
very weird
i'll try on my main application
๐
oh sorry, I didn't scroll down, I was responding to the env var ordering
i mean it is fixed, just something wrong on their end
how tho
we literally have the same variables
.
bruh that's not the same
lol
you have /app/public
i also tried that
๐
if it works for me it means you have something missconfigured somewhere else
it also works for me now
in my main project
there you go
i literally copied your variables
and pasted them
but i had the same before
weird but glad it works
woohoo
typo always gets ya
i dont think thats it
because i also copied the lines from nixpacks website
and tried the nginx
but thanks anyways