Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. App Packaging & Development
  3. Need help on probably something very easy (Apache Setup)

Need help on probably something very easy (Apache Setup)

Scheduled Pinned Locked Moved App Packaging & Development
8 Posts 2 Posters 1.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • LonkleL Offline
    LonkleL Offline
    Lonkle
    wrote on last edited by Lonkle
    #1

    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 the app/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

    M 1 Reply Last reply
    0
    • LonkleL Lonkle

      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 the app/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

      M Offline
      M Offline
      malvim
      wrote on last edited by malvim
      #2

      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 inside home/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 like mkdir -p /app/data/sessions (and also chown it to the correct user since start.sh runs as root), and it should work.

      1 Reply Last reply
      2
      • LonkleL Offline
        LonkleL Offline
        Lonkle
        wrote on last edited by
        #3

        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 an install 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 default start.shscript 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 their start.sh script. Thanks so much for how thorough your explanation was!

        1 Reply Last reply
        1
        • LonkleL Offline
          LonkleL Offline
          Lonkle
          wrote on last edited by
          #4

          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.sh

          Thanks 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). ☺️

          M 1 Reply Last reply
          0
          • LonkleL Lonkle

            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.sh

            Thanks 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). ☺️

            M Offline
            M Offline
            malvim
            wrote on last edited by
            #5

            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.

            LonkleL 2 Replies Last reply
            1
            • M malvim

              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.

              LonkleL Offline
              LonkleL Offline
              Lonkle
              wrote on last edited by
              #6

              @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?

              1 Reply Last reply
              0
              • M malvim

                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.

                LonkleL Offline
                LonkleL Offline
                Lonkle
                wrote on last edited by
                #7

                @malvim But also thanks for being so kind about my simplistic question. Sometimes I ask too complex ones, sometimes too simple ones. But the way you explained everything was perfect and I got it working! ☺️

                M 1 Reply Last reply
                0
                • LonkleL Lonkle

                  @malvim But also thanks for being so kind about my simplistic question. Sometimes I ask too complex ones, sometimes too simple ones. But the way you explained everything was perfect and I got it working! ☺️

                  M Offline
                  M Offline
                  malvim
                  wrote on last edited by
                  #8

                  @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. 🙂

                  1 Reply Last reply
                  1
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Bookmarks
                  • Search