I can't deploy a PHP application using Slim Framework

FFelinto3/3/2023
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:
sh: 2: daemon: not found
sh: 4: worker_rlimit_nofile: not found
sh: 6: events: not found
sh: 7: worker_connections: not found
sh: 8: Syntax error: "}" unexpected
sh: 2: daemon: not found
sh: 4: worker_rlimit_nofile: not found
sh: 6: events: not found
sh: 7: worker_connections: not found
sh: 8: Syntax error: "}" unexpected
sh: 2: daemon: not found
sh: 4: worker_rlimit_nofile: not found
sh: 6: events: not found
sh: 7: worker_connections: not found
sh: 8: Syntax error: "}" unexpected
Server starting on port 6615
nginx: [emerg] open() "/conf/mime.types" failed (2: No such file or directory) in /nginx.conf:11
UUUnknown User3/4/2023
3 Messages Not Public
Sign In & Join Server To View
Bbrody3/5/2023
@Willian
@codehaven
this should be fixed now, could you try redeploying and let me know how it goes?
UUUnknown User3/5/2023
Message Not Public
Sign In & Join Server To View
Bbrody3/5/2023
Do you have an index.php file?
UUUnknown User3/5/2023
Message Not Public
Sign In & Join Server To View
Bbrody3/5/2023
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
UUUnknown User3/5/2023
2 Messages Not Public
Sign In & Join Server To View
FFelinto3/6/2023
I get the same error
FFelinto3/6/2023
FFelinto3/6/2023
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?
UUUnknown User3/6/2023
Message Not Public
Sign In & Join Server To View
ADA Dumb3/6/2023
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
FFelinto3/7/2023
Is someone has an example about how to deploy a PHP application using Apache for Railway app ?
Bbrody3/7/2023
this is a known problem, hopefully fix coming soon
Rroot3/7/2023
PHP should be fixed soon.
FFelinto3/7/2023
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.
Rroot3/7/2023
You don't need to set any custom values
Rroot3/7/2023
And if it's Laravel, it automatically uses public/
FFelinto3/7/2023
i'm using slim framework
FFelinto3/7/2023
how railway can figure out this ?
Rroot3/7/2023
Figure out what exactly?
Rroot3/7/2023
And actually I guess it won't autodetect Laravel if it isn't laravel
Rroot3/7/2023
I'll fix that in a bit
FFelinto3/7/2023
1. I'm using "public/index.php" and not "index.php"
2. post_max_filesize should be 50MB
Rroot3/7/2023
Ah. The first one I'll fix in a bit, and the second one should be fine to set in php.ini
FFelinto3/7/2023
I use apache mod_rewrite to avoid the user needs to type "public/index.php" in browser
Rroot3/7/2023
Ah, Railway uses nginx instead of apache by default
FFelinto3/7/2023
I need to create a nginx.conf in the main directory ?
Rroot3/7/2023
No; nixpacks creates it for you.
FFelinto3/7/2023
how could I get the same result and avoid the user needs to type "public/index.php" ?
FFelinto3/7/2023
I want the user just type the domain
FFelinto3/7/2023
and that's it
Rroot3/7/2023
As I said, I'll fix that in a bit, and it should be the default behavior soon.
FFelinto3/7/2023
thanks 🙂
FFelinto3/9/2023
@aleks do you will tell us here when you fix the issue ?
Bbrody3/9/2023
@Felinto
Changes Should be live, can you try deploying again and let me know how it goes?
UUUnknown User3/9/2023
Message Not Public
Sign In & Join Server To View
FFelinto3/10/2023
I received the same error again
FFelinto3/10/2023
FFelinto3/10/2023
FFelinto3/10/2023
I know that is not necessary .htaccess but I use apache in development environment.
Bbrody3/10/2023
its been a very long time since ive had to write htaccess rules, so im no help there
FFelinto3/10/2023
but the problem is not .htaccess
FFelinto3/10/2023
you guys use nginx
FFelinto3/10/2023
FFelinto3/10/2023
maybe @aleks could look ?
Bbrody3/10/2023
you have a good point there, why would the railway provided template have a htaccess file then
Bbrody3/10/2023
please dont directly ping team / conductor
FFelinto3/10/2023
Is there anything I can do to resolve this issue?
Bbrody3/10/2023
try setting the NIXPACKS_PHP_ROOT_DIR = /public
FFelinto3/10/2023
environment variable, right ? ok, i'll check
Bbrody3/10/2023
service variable in the service settings
FFelinto3/10/2023
done
I'll wait and check
FFelinto3/10/2023
I receive the 404 error now
FFelinto3/10/2023
FFelinto3/10/2023
FFelinto3/10/2023
maybe is that the reason ? I'll check
FFelinto3/10/2023
I removed the slash
(because relative path...) and the issues continue
FFelinto3/10/2023
Bbrody3/10/2023
i can see how this would be frustrating, i will bring this up to aleks
sorry for the poor php support
FFelinto3/10/2023
Thank you for understanding
Rroot3/10/2023
Ah, try setting NIXPACKS_PHP_ROOT_DIR=/app/public
Rroot3/10/2023
I'm not sure if that will help, but it might
FFelinto3/10/2023
It worked! Thanks 🙂
Rroot3/10/2023
Great!
Rroot3/10/2023
Also, if you want to have a custom configuration, it should now be possible.
FFelinto3/10/2023
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
FFelinto3/10/2023
maybe I will need to use environment variables 😦
FFelinto3/10/2023
FFelinto3/10/2023
php.ini, right ? I'll check
Rroot3/10/2023
nginx.conf
Rroot3/10/2023
I'm pretty sure it should use your public/ dir; that's the root passed to the NGINX configuration.
FFelinto3/10/2023
How could I simulate the same environment of railway in my computer to test this issue ?
FFelinto3/10/2023
to avoid do a lot of "trash commits" in git repository
Rroot3/10/2023
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>
FFelinto3/10/2023
Rroot3/10/2023
It should be running as root anyway, so there shouldn't be any permission issues.
FFelinto3/10/2023
the files are from the root user
FFelinto3/10/2023
FFelinto3/10/2023
but the PHP server run using the "nobody" user
FFelinto3/10/2023
and that the reason because I can't create the folder
FFelinto3/10/2023
do you have any suggestion ?
FFinn3/10/2023
the fs is frozen at built time
Rroot3/10/2023
Huh, that's interesting. I haven't dug into that part of the codebase in a bit.
FFinn3/10/2023
so you cant create any new folders
Rroot3/10/2023
No, it isn't.
FFinn3/10/2023
on railway it is?
Rroot3/10/2023
Nope.
Rroot3/10/2023
Just not persisted across deployments.
FFinn3/10/2023
you can create new files but no folders?
Rroot3/10/2023
You can create folders.
Rroot3/10/2023
And files.
FFinn3/10/2023
im 90% sure you cant