3 months ago
Hi,
I am having trouble making my Laravel Application storage folder persistent. Logs, Sessions, and Public images that store on the storage folder would all be deleted when the application is rebuild on git push.
So I would like to for everyone help to solve this issue. How do I configure the volume of Railway to be able to store persistent data for my Laravel Application?
Please note:
I am using Laravel with Serversideup image. I have a startup bash shell to run php artisan commands. Most of the time I issue relating with container unable to startup due to permission issue with the folder I set for the volume path (/var/www/html/storage)
Error msg: "mkdir: cannot create directory 'storage/logs': Permission denied"
Pinned Solution
3 months ago
you need to mount a volume to your git service and point it to /var/www/html/storage, assuming that's where you want to store it (or change it accordingly). in your startup script run chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache && chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache so laravel is able to write logs between redeployments
5 Replies
3 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
3 months ago
you need to mount a volume to your git service and point it to /var/www/html/storage, assuming that's where you want to store it (or change it accordingly). in your startup script run chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache && chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache so laravel is able to write logs between redeployments
yeeet
you need to mount a volume to your git service and point it to /var/www/html/storage, assuming that's where you want to store it (or change it accordingly). in your startup script run chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache && chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache so laravel is able to write logs between redeployments
3 months ago
Thank you, your solution is working as expected. But I do have to change a few stuff in order for it to work.
Since, serversideup version 3.x.x use www-data as user. Then I need to add this RAILWAY_RUN_UID="33" in order for the volume to use the right user. Furthermore, I need to update my startup script to initially create /var/www/html/storage/logs folder to make it work.
3 months ago
You can just ssh into the service and do this manually, as it is just required one time.
Had the same problem with the Craft CMS image that dont run as the root user, and found this to be the easiest solution.
Status changed to Solved ray-chen • 3 months ago
espensgr
You can just ssh into the service and do this manually, as it is just required one time.Had the same problem with the Craft CMS image that dont run as the root user, and found this to be the easiest solution.
3 months ago
I did try SSH but I'm trying to find a solution with less manual steps. I managed to automate this on Kubernetes, so I'm hoping to get something similar here without needing to log in every time.
Status changed to Awaiting Railway Response Railway • 3 months ago
