I can't deploy a PHP application using Slim Framework
I have a simple application that uses slim framework:
https://github.com/felinto-dev/wp-package-parser-api-php
but I receive this error in railway deployment:
GitHub
GitHub - felinto-dev/wp-package-parser-api-php
Contribute to felinto-dev/wp-package-parser-api-php development by creating an account on GitHub.
123 Replies
Project ID:
48866d2b-59f7-4e12-889d-1f377cee4c17
Unknown Userβ’2y ago
Message Not Public
Sign In & Join Server To View
@Willian
@codehaven
this should be fixed now, could you try redeploying and let me know how it goes?
Unknown Userβ’2y ago
Message Not Public
Sign In & Join Server To View
Do you have an index.php file?
Unknown Userβ’2y ago
Message Not Public
Sign In & Join Server To View
Well unfortunately it looks like PHP apps on railway aren't quite fixed yet, I know zero about PHP so the best advice I could give would be to put together your own Dockerfile for your app
Unknown Userβ’2y ago
Message Not Public
Sign In & Join Server To View
I get the same error
I didn't know I could put personalized dockerfile on Railway. How is resource allocation control done so that I do not pay more than it is necessary for my application to work?
Unknown Userβ’2y ago
Message Not Public
Sign In & Join Server To View
Your app always has access to the maximum amount of resources for your plan (8GB ram 8vCPU for dev plan). Itβs up to what your app uses for how much youβll pay
Is someone has an example about how to deploy a PHP application using Apache for Railway app ?
this is a known problem, hopefully fix coming soon
PHP should be fixed soon.
I don't feel confident using railway's PHP builder because I need to set custom values in php.ini and my "index.php" is currently in "public/index.php" and not in the main directory. I couldn't find any documentation or template about it.
You don't need to set any custom values
And if it's Laravel, it automatically uses
public/
i'm using slim framework
how railway can figure out this ?
Figure out what exactly?
And actually I guess it won't autodetect Laravel if it isn't laravel
I'll fix that in a bit
1. I'm using "public/index.php" and not "index.php"
2. post_max_filesize should be 50MB
Ah. The first one I'll fix in a bit, and the second one should be fine to set in
php.ini
I use apache mod_rewrite to avoid the user needs to type "public/index.php" in browser
Ah, Railway uses nginx instead of apache by default
I need to create a nginx.conf in the main directory ?
No; nixpacks creates it for you.
how could I get the same result and avoid the user needs to type "public/index.php" ?
I want the user just type the domain
and that's it
As I said, I'll fix that in a bit, and it should be the default behavior soon.
thanks π
@aleks do you will tell us here when you fix the issue ?
@Felinto
Changes Should be live, can you try deploying again and let me know how it goes?
Unknown Userβ’2y ago
Message Not Public
Sign In & Join Server To View
I received the same error again
you can check the code repository
https://github.com/felinto-dev/wp-package-parser-api-php
GitHub
GitHub - felinto-dev/wp-package-parser-api-php
Contribute to felinto-dev/wp-package-parser-api-php development by creating an account on GitHub.
I know that is not necessary
.htaccess
but I use apache in development environment.take a look at this
.htaccess
file
https://github.com/railwayapp-templates/laravel/blob/main/.htaccess
its been a very long time since ive had to write htaccess rules, so im no help therebut the problem is not
.htaccess
you guys use nginxmaybe @aleks could look ?
you have a good point there, why would the railway provided template have a htaccess file then
please dont directly ping team / conductor
Is there anything I can do to resolve this issue?
try setting the NIXPACKS_PHP_ROOT_DIR = /public
environment variable, right ? ok, i'll check
service variable in the service settings
done
I'll wait and check
I receive the 404 error now
maybe is that the reason ? I'll check
I removed the slash
(because relative path...) and the issues continue
i can see how this would be frustrating, i will bring this up to aleks
sorry for the poor php support
Thank you for understanding
Ah, try setting NIXPACKS_PHP_ROOT_DIR=/app/public
I'm not sure if that will help, but it might
It worked! Thanks π
Great!
Also, if you want to have a custom configuration, it should now be possible.
Do you know what the PHP server resolves for
$_SERVER["DOCUMENT_ROOT"]
?
I need to create a temporary directory but I don't get the right permissions
maybe I will need to use environment variables π¦php.ini, right ? I'll check
nginx.conf
I'm pretty sure it should use your
public/
dir; that's the root passed to the NGINX configuration.How could I simulate the same environment of railway in my computer to test this issue ?
to avoid do a lot of "trash commits" in git repository
You should be able to download Nixpacks from https://github.com/railwayapp/nixpacks, and then (assuming you have Docker installed) run
nixpacks build . --name <image name>
and docker run -p 8080:80 -it <image name>
It should be running as root anyway, so there shouldn't be any permission issues.
the files are from the
root
userbut the PHP server run using the "nobody" user
and that the reason because I can't create the folder
do you have any suggestion ?
the fs is frozen at built time
Huh, that's interesting. I haven't dug into that part of the codebase in a bit.
so you cant create any new folders
No, it isn't.
on railway it is?
Nope.
Just not persisted across deployments.
you can create new files but no folders?
You can create folders.
And files.
im 90% sure you cant
is this a new thing?
do you know any workaround ?
I'll look into it.
Nope.
does railway run now run commands inside the container hosted on railway?
No, that was locally messing around with docker.
But it works the same way on Railway - if it didn't, Laravel wouldn't work at all
i guess yea
Since it caches built templates in the
storage
folder at runtimewonder why a dumb thaught that then... i based my comment of that
π€·ββοΈ
A dumb said they also don't know why they said that, guess it's a telephone situation
lmao
guess we both thaught it sounded wierd but didnt ask
I would have accepted it too, but I've created folders and files inside a railway container
It's just not recommended because the no persistent storage thingy
ye
Just store temp files in a memory fs for super speed
how did you bypass the user permissions issue ?
I don't honestly know why it's running as
nobody
; there's nothing in the generated dockerfile to make it do that.
And the perl script that runs for laravel apps can access the filesystem just fineI never had any permission issues since I was creating folder / files in my apps own directory
If you want replicate the issue, you can git clone my repository
https://github.com/felinto-dev/wp-package-parser-api-php
=\
I also build with a dockerfile, nixpacks is mid (jokes)
I mean, dockerfile is probably better
do you have any example than you can share ?
could I create a custom Dockerfile based on nixpacks and change the ownership of folder manually ?
No sorry, I don't do php
Yes, I think so.
I'm not sure where Nixpacks puts the generated Dockerfile, though.
Oh, actually, that could get pretty complicated.
Oh π€¦ββοΈ
Create a
nixpacks.toml
@Felinto ^thanks for ping me
i'll check
I get the same issue again
If AFTER the container was created I login and change the permissions, everything works fine
but I can't do that using nixpacks.yaml
If I execute this command AFTER the container was created everything works fine
=\
welp, dockerfile time
π’
its a very simple php app, im sure it wont be that hard to create a caddy + php dockerfile for it
theres a few resources on creating a caddy + php dockerfile
I wait so much time to works with nixpacks that I kind of fell guilty if I give up just because one line of code guess... should to have a "pre-start" command or "post-build" like in NPM
IDK
I'll check
haha i get what you mean, but either way a caddy + php dockerfile isnt a bad idea
I know. I'll keep trying Brody
If I know that was not possible to works with Nixpacks I could use Dockerfile since last friday
I found this image that works very well in development environment
https://hub.docker.com/r/webdevops/php-nginx
PHP + Nginx
however, does not works in railway
Dockerfile.png
caddy + php please
i don't find any template
https://dockerfile.readthedocs.io/en/latest/content/DockerImages/dockerfiles/php-nginx.html
Uh, that error isn't an error
Set PORT to 80 in your Variables tab.
that what I guess
thanks
i'll do
It worked!
i knew it!
ohhhh guys :3
GitHub
wp-package-parser-api-php/Dockerfile at main Β· felinto-dev/wp-packa...
Contribute to felinto-dev/wp-package-parser-api-php development by creating an account on GitHub.
If someone has the same issue you can use my repository as template
I will delete the
.htaccess
files and use the same image for development tooyay happy for you!
Great!