R
Railwayβ€’15mo 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
Percyβ€’15mo ago
Project ID: 643c8ee2-66dc-413e-bcca-2d08a9c73466
Brody
Brodyβ€’15mo ago
php files should be inside an app directory, what framework is this?
Alberto
Albertoβ€’15mo ago
It should have been written without any framework (not by me) πŸ€”
Brody
Brodyβ€’15mo ago
okay well usually site files for a php project go into an app directory
Alberto
Albertoβ€’15mo 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
Brodyβ€’15mo ago
yeah i assume so, thats the folder railway will use
Alberto
Albertoβ€’15mo ago
wait sorry the first or the second? πŸ˜…
Brody
Brodyβ€’15mo ago
oh sorry, just the php files for the website
Alberto
Albertoβ€’15mo 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
Brodyβ€’15mo ago
can you send me a link to your repo?
Alberto
Albertoβ€’15mo ago
GitHub
GitHub - AlbertoNoris/MPP: test website
test website. Contribute to AlbertoNoris/MPP development by creating an account on GitHub.
Alberto
Albertoβ€’15mo ago
This is a new repo that I've built in order to make it public so the previous projectID doesn't match
Brody
Brodyβ€’15mo ago
that's fine, I can't do anything with a project id anyway
Alberto
Albertoβ€’15mo ago
ahahah ok
Brody
Brodyβ€’15mo ago
whats with the capital letters on the index files?
Alberto
Albertoβ€’15mo ago
I'm used to camel case
Brody
Brodyβ€’15mo ago
you should only have a sinlge index file named index.php
Alberto
Albertoβ€’15mo ago
Ok, working on it
Brody
Brodyβ€’15mo ago
$dbconn = pg_connect("host=localhost port=5432 dbname=Intersection user=postgres password=BIAR") thats also not gonna work on railway
Alberto
Albertoβ€’15mo ago
For test porpouses do you reccomend removing it?
Brody
Brodyβ€’15mo ago
that would just cause more errors
Alberto
Albertoβ€’15mo ago
Thanks again I'm gonna try it tomorrow!
Alberto
Albertoβ€’15mo 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
Brodyβ€’15mo ago
um, you are using your database password in plaintext thats not the main issue, but its something you should fix asap
Alberto
Albertoβ€’15mo ago
Yeah I know I'll fix it asap but first I wanted to at least see the website running!
Brody
Brodyβ€’15mo 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
Albertoβ€’14mo 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
Albertoβ€’14mo 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
Albertoβ€’14mo 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
Albertoβ€’14mo 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
Brodyβ€’14mo ago
you are setting the root directory to be /app, try just /WebSite
Alberto
Albertoβ€’14mo ago
If i try just /WebSite It fails
Alberto
Albertoβ€’14mo ago
Brody
Brodyβ€’14mo 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
Albertoβ€’14mo ago
Ok I fixed it by simply putting everything inside the app folder
Brody
Brodyβ€’14mo ago
didn't I say to do that a while ago?
Alberto
Albertoβ€’14mo ago
Yeah but you were suggesting only the php files
Alberto
Albertoβ€’14mo ago
But no prob we figured it out I should have tried eralier
Brody
Brodyβ€’14mo ago
yeah my bad, I don't have any experience with php glad you got it solved though
Alberto
Albertoβ€’14mo 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
Brodyβ€’14mo 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
Albertoβ€’14mo ago
I've tried but no luck unfortunately 😦 it still looks like I need to give write permission somehow
Brody
Brodyβ€’14mo ago
@aleks please advise? πŸ™
root
rootβ€’14mo ago
You're using /app/storage?
Alberto
Albertoβ€’14mo 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
Albertoβ€’14mo 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
Brodyβ€’14mo ago
will take a crack at that when I have some time whats the railway domain that your app is running on
Alberto
Albertoβ€’14mo ago
Intersection
Intersection between professionals and companies site
Brody
Brodyβ€’14mo 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
Albertoβ€’14mo ago
Looking into it! πŸ‘€ No errors but now the error codes never show themselves even when the button is pressed
Alberto
Albertoβ€’14mo ago
I replaced it like this
Brody
Brodyβ€’14mo ago
yes looks good
Alberto
Albertoβ€’14mo ago
No ok I need to try again because now also in local it doesn't show
Brody
Brodyβ€’14mo ago
lol