Need help on probably something very easy (Apache Setup)
-
Installing an Apache instance and I can't get PHP sessions to save (folder doesn't exist error) anywhere except
app/data
.RUN mkdir -p /app/run/sessions
RUN crudini --set /etc/php/7.3/apache2/php.ini Session session.save_path /app/run/sessions && \
RUN chown -R www-data.www-data /app/code /app/data /tmp
I've tried
/app/code/sessions
and/app/data/sessions
- I guess I could just use PHP to create theapp/data/sessions
but I still don't know why the DOCKERFILE isn't creating the folder on the only user write allowed files.This is something simple right? What am I missing here? I mean sessions work if I tell php.ini to write them to
/app/data
but that's just messy.I based the above code on the tutorial-php app in the Cloudron Git so I'm surprised sessions don't work: https://git.cloudron.io/cloudron/tutorial-php-app/-/blob/master/Dockerfile
-
They won't work on
/app/code
, as it is mounted as readonly inside the docker container. A subdirectory of/app/data
would work (though/app/data
goes to you backups, not sure if sessions are something you want to backup, but that's not your point).I've been through trying to create
/app/data
subdirectories on the Dockerfile, but this doesn't work because/app/data
is mounted when Cloudron brings the container up. So/app/data
when your app is running points to another filesystem (namely, it mounts a directorie that lives insidehome/yellowtent/appsdata/<app-id>
on your server). It's a runtime vs "compile time" thing (in this case, runtime vs image build time).So your best bet is to ensure this directory is created on your
start.sh
script. Run something likemkdir -p /app/data/sessions
(and alsochown
it to the correct user sincestart.sh
runs as root), and it should work. -
Thank you so much for all of that insight! I'm very very new to this!
I actually added
/sessions
via the File Manager just to get it to work. Even though I knew that wouldn't work for aninstall
and thanks to your input, I have what will make that work.My main question is here then:
How does the literal "Cloudron PHP Tutorial" have it wrong? Maybe I'm the first person to use it to develop a new app with PHP sessions. But by default it does set a specific place for "sessions" it just doesn't exist,
app/run/sessions
but maybe since you just taught me the defaultstart.sh
script has root priveleges, it writes it there. I can copy that mentality if that's how the Cloudron developer's tackled it. Just gotta check theirstart.sh
script. Thanks so much for how thorough your explanation was! -
It was almost on the first line of the tutorial app's start.sh.
mkdir -p /run/app/sessions
- https://git.cloudron.io/cloudron/tutorial-php-app/-/blob/master/start.shThanks for getting me to understand why that works. I'm glad I know what user start.sh runs in (well,
root
to it's individual container anyway). ️ -
Hahaha no worries, I've been using cloudron for quite a while now and STILL have some very basic questions, you're doing great.
Yeah,
start.sh
is the place to create this kind of thing, and then it will work across restarts, reinstalls, backups, etc. -
@malvim said in Need help on probably something very easy (Apache Setup):
Hahaha no worries, I've been using cloudron for quite a while now and STILL have some very basic questions, you're doing great.
Yeah,
start.sh
is the place to create this kind of thing, and then it will work across restarts, reinstalls, backups, etc.You know the funniest thing about that, the tutorial-php-app doesn't chown the folder it creates for sessions like you mentioned I should do (and when I didn't, it didn't work cause I forgot at first). So, I think the tutorial app may need to add that or somehow I missed it?
-
@Lonk said in Need help on probably something very easy (Apache Setup):
Sometimes I ask too complex ones, sometimes too simple ones. But the way you explained everything was perfect and I got it working! ️
I feel that's usually the process of learning something new. Glad to be of help.