R
Railway16mo ago
Alberto

Trying to deploy a website returns error

Service ID: 643c8ee2-66dc-413e-bcca-2d08a9c73466 Hi!! I'm trying to deploy a web app to railway. Sorry if I say something wrong but this is my first time working with websites. We have a website written in http, css, php and javascript which i loaded on github but trying to deploy it on railway I get the error: " context: f62c7b62599d441440438a1ad86d113c Nixpacks build failed Nixpacks was unable to generate a build plan for this app. Please check the documentation for supported languages: https://nixpacks.com The contents of the app directory are: b ootstrap/ Login/ Registrazione/ Errore/ SQL/ Home/ Images/ PHP/ Utenti/ " I'll leave the file structure of the project. Thanks in advance for the help!
Getting Started | Nixpacks
App source + Nix packages + Docker = Image
54 Replies
Percy
Percy16mo ago
Project ID: 643c8ee2-66dc-413e-bcca-2d08a9c73466
Brody
Brody16mo ago
php files should be inside an app directory, what framework is this?
Alberto
Alberto16mo ago
It should have been written without any framework (not by me) 🤔
Brody
Brody16mo ago
okay well usually site files for a php project go into an app directory
Alberto
Alberto16mo ago
Ok, so should I move every file and directory into a root folder called app? Or simply put every php file into an app folder?
Brody
Brody16mo ago
yeah i assume so, thats the folder railway will use
Alberto
Alberto16mo ago
wait sorry the first or the second? 😅
Brody
Brody16mo ago
oh sorry, just the php files for the website
Alberto
Alberto16mo ago
Hi, thanks for the tips! I've tryed to put all of the php code inside an app directory like in the image. Now the deployment goes on for longer but still returns the same error as before !
Brody
Brody16mo ago
can you send me a link to your repo?
Alberto
Alberto16mo ago
GitHub
GitHub - AlbertoNoris/MPP: test website
test website. Contribute to AlbertoNoris/MPP development by creating an account on GitHub.
Alberto
Alberto16mo ago
This is a new repo that I've built in order to make it public so the previous projectID doesn't match
Brody
Brody16mo ago
that's fine, I can't do anything with a project id anyway
Alberto
Alberto16mo ago
ahahah ok
Brody
Brody16mo ago
whats with the capital letters on the index files?
Alberto
Alberto16mo ago
I'm used to camel case
Brody
Brody16mo ago
you should only have a sinlge index file named index.php
Alberto
Alberto16mo ago
Ok, working on it
Brody
Brody16mo ago
$dbconn = pg_connect("host=localhost port=5432 dbname=Intersection user=postgres password=BIAR") thats also not gonna work on railway
Alberto
Alberto16mo ago
For test porpouses do you reccomend removing it?
Brody
Brody16mo ago
that would just cause more errors
Alberto
Alberto16mo ago
Thanks again I'm gonna try it tomorrow!
Alberto
Alberto16mo ago
Ok so I've put every file inside the app folder, created only one file with the name "index" and fixed the connection to the postgre databse by connecting it to a railway deployd postgre database. But while the website locally on my machine runs fine when I deploy it on railway I can only see one (broken) page and when I try to click on a new page of the website it returns "file not foud" https://intersection-production.up.railway.app/ . Do you have any tips? Maybe the structure of the folders are still wrong? It seems like the website cannot find the other pages but I cannot figure out how to fix it! Thanks in advance!!
Intersection
Intersection between professionals and companies site
Brody
Brody16mo ago
um, you are using your database password in plaintext thats not the main issue, but its something you should fix asap
Alberto
Alberto16mo ago
Yeah I know I'll fix it asap but first I wanted to at least see the website running!
Brody
Brody16mo ago
so in the root of your repo you have a WebSite folder, but in the root you should have the app folder, so bring your app folder into the root of the project then place all asset folders into a single asset or static folder at this point it's just a matter of correct folder structure
Alberto
Alberto16mo ago
You have to forgive me but I still don't get what I should do. 1. Thanks for the tip about hiding the passwords now they are hidden. 2. "in the root you should have the app folder, so bring your app folder into the root of the project" since the repo cotains also other folders which are not specific to the website can I just change the root directory in the settings of my deployment?
Alberto
Alberto16mo ago
3. "then place all asset folders into a single asset or static folder" do you mean that I need to put all of the folders inside of /app ? Right now this is the structure:
Alberto
Alberto16mo ago
I had to change the repo which now must be private so I cannot share it here but if you need anything just ask me and I'll send everything! btw thanks for the help and sorry if this stuff is trivial but I'm dying for this deplyment!!
Alberto
Alberto16mo ago
Just to be clear now the error is simply that the website doesn't work properly ( take a look here: https://website-production-39ee.up.railway.app/ ) wheares on my local machine the pages are all working properly!
Intersection
Intersection between professionals and companies site
Brody
Brody16mo ago
you are setting the root directory to be /app, try just /WebSite
Alberto
Alberto16mo ago
If i try just /WebSite It fails
Alberto
Alberto16mo ago
Brody
Brody16mo ago
your folder structure is just so un-orthodox, railway doesn't know what to make of it I don't even know how you managed to run it locally
Alberto
Alberto16mo ago
Ok I fixed it by simply putting everything inside the app folder
Brody
Brody16mo ago
didn't I say to do that a while ago?
Alberto
Alberto16mo ago
Yeah but you were suggesting only the php files
Alberto
Alberto16mo ago
But no prob we figured it out I should have tried eralier
Brody
Brody16mo ago
yeah my bad, I don't have any experience with php glad you got it solved though
Alberto
Alberto15mo ago
Hi! I still have some issues 😅 I'm trying to create a new file by doing file_put_contents($nameOfFile, $contentsToPutInsideFile); as usual in local everything works fine but when deployed I get the error "file_put_contents(): failed to open stream: permission denied" which looks like it should only be an error caused from permissions. But every forum I found online only talks about using the command line which from railway I don't have access to. For example a possibility was doing "chmod -R 777 /app" which I tried putting inside the Start Command of the deployment which results in the website deploying correctly on the railway page but on the website a text with "Server Error" is displayed. any tips? the app one was perfect and helped me going forward a lot!
Brody
Brody15mo ago
I have seen our php guy say something about using a /storage folder? apparently that folder is available and has the correct perms, but I might be making that up lol
Alberto
Alberto15mo ago
I've tried but no luck unfortunately 😦 it still looks like I need to give write permission somehow
Brody
Brody15mo ago
@aleks please advise? 🙏
root
root15mo ago
You're using /app/storage?
Alberto
Alberto15mo ago
Fixed it!! Yeah it was the storage folder missing 😅 I still have one last issue and then I should be ready to have it public to the internet! Javascript seems to not work properly when deployed but it's fine on local. [what it should do]: in local when a user is registering we check if it has inserted the email after having pressed an "invia" (it means register) button. If the email hasn't been inserted a red box comes up under the text field in which you insert the email [what it does]: when deployed the red box comes up as soon as the page is loaded and not after the button has been pressed.
Alberto
Alberto15mo ago
I leave the file that containts the javascript and 2 images that should explain better wht's the error ... thanks as always for the help!! 💪💪💪
Brody
Brody15mo ago
will take a crack at that when I have some time whats the railway domain that your app is running on
Alberto
Alberto15mo ago
Intersection
Intersection between professionals and companies site
Brody
Brody15mo ago
look at the browser console errors for that registration page, fix the super simple console errors and your problem will be solved so that means use this link to load jquery lib instead of the google based link https://code.jquery.com/jquery-3.6.0.min.js
Alberto
Alberto15mo ago
Looking into it! 👀 No errors but now the error codes never show themselves even when the button is pressed
Alberto
Alberto15mo ago
I replaced it like this
Brody
Brody15mo ago
yes looks good
Alberto
Alberto15mo ago
No ok I need to try again because now also in local it doesn't show
Brody
Brody15mo ago
lol