Here's a working PHP 7.x and Apache setup for Docker

  • That worked perfectly.


    And it's a bit odd, because I had that exact contents, but with the "a2enmod rewrite" line after the exif line. And I did have a trailing \ as well.


    I'll update my post.


    One last question, if you know..... where is the phpi.in file located within this container?


    I'd like to setup some "disable_functions" and increase a few of the default parameters like post_max_size and upoad_max_filesize, but am running into a dead end.


    In my software, phpinfo shows a lot of directories/folders that simply don't exist on disk when viewed with command-line SSH.


    This isn't a "must do", just something I'd prefer to do.

    • Offizieller Beitrag

    where is the phpi.in file located within this container?

    There isn't one. It uses all defaults. If you want to change settings, I would create settings files in /usr/local/etc/php/conf.d/. Then it would be an easy additions to your dockerfile:


    && echo "upload_max_filesize = 32M" > /usr/local/etc/php/conf.d/maxsizes.ini \
    && echo "post_max_size = 32M" >> /usr/local/etc/php/conf.d/maxsizes.ini

    omv 7.0.4-2 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.10 | compose 7.1.2 | k8s 7.0-6 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Not sure what you mean by "create settings files in /usr/local/etc/php/conf.d/."


    Using SSH, I see there is a /usr/local/etc/ folder but nothing in it.


    So I created /usr/local/etc/php/ and /usr/local/etc/php/conf.d/ then did a Run Cmd twice in the container with:


    echo "upload_max_filesize = 128M" > /usr/local/etc/php/conf.d/maxsizes.ini


    followed by


    echo "post_max_size = 129M" >> /usr/local/etc/php/conf.d/maxsizes.ini


    and that file was created with the two lines.



    Code
    root@debian:/usr/local/etc/php/conf.d# ls -la
    total 12
    drwxr-sr-x 2 root staff 4096 Mar  5 13:02 .
    drwxr-sr-x 3 root staff 4096 Mar  5 13:01 ..
    -rw-rw-rw- 1 root staff   50 Mar  5 13:02 maxsizes.ini
    root@debian:/usr/local/etc/php/conf.d# cat maxsizes.ini
    upload_max_filesize = 128M
    post_max_size = 129M
    root@debian:/usr/local/etc/php/conf.d#

    But phpinfo in my software shows no change.


    Do I have to actually build this container again, adding those two lines as you showed them, to my Dockerfile file? (Easy enough to do, I just want to be sure.)

    • Offizieller Beitrag

    Do I have to actually build this container again, adding those two lines as you showed them, to my Dockerfile file? (Easy enough to do, I just want to be sure.)

    Yes. Adding the files won't restart fpm and since it isn't a service, there isn't a good way to do that.

    and that file was created with the two lines.

    That is what it is supposed to do. Not sure why the directory wasn't created (it was on mine) but you may want to add mkdir -p /usr/local/etc/php/conf.d to the dockerfile before the echo commands.

    omv 7.0.4-2 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.10 | compose 7.1.2 | k8s 7.0-6 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • That worked perfectly, thank you again! I'll put the final iteration of the build below for anyone interested.


    For anyone reading this at a later date, here is the Dockerfile for installing Apache/PHP 7.3.2 with Exif, gd, mysqli, the Zip PHP extension, and mod_rewrite.


    It also has post_max_size set to 257 MB, upload_max_filesize set to 256 MB, and a PHP memory_limit of 512 MB, as well as disabling a number of functions that are recommended to be disabled (for my software anyway) and display_errors disabled (Off).

    You can adjust those limits as appropriate for your needs, or remove the lines which are not needed, but remember that the first echo line should have a single ">" and subsequent echo lines have two of them like so: ">>" (Because > in echo overwrites the file, while >> appends to the file).




    From command-line (SSH), first pull PHP with this command:


    Code
    docker pull php

    Then from command-line (SSH or shellinabox), and in the folder where you placed the file named "Dockerfile", run this command:


    Code
    docker build -t my-php-custom .

    (Or whatever image name you prefer, if you don't want to name it "my-php-custom".)


    Once done you can configure it in the usual fashion. Use a Container Name of your choosing, Restart Policy as you prefer. You can leave Host Name blank if you wish, it will auto-populate a name.


    I use my machines internally assigned IP Address, with the Host Port = 80, Exposed Port = 80/tcp.


    Host Path is the volume and folder where you will place your .php web script(s), HTML pages, etc. Container Path should be set to /var/www/html


    Here's a screenshot of my setup for reference. I suspect you can change some of the values to suit your own needs, but these work for me so I'll stick with them:


    Hope this helps someone else!

  • UPDATE:


    If you want to add cron and nano to the container build (the native php Docker image does not contain them), use the following Dockerfile, and read the notes below it; cron is a bit fussy.



    NOTE: cron cannot be installed in the first "apt-get install" block, because some of what is installed with that first run, itself needs to have "apt-get update" run again, as shown later in the file.


    FURTHER NOTE: For some reason I cannot get cron to auto-start after a crontab edit, and I use a software package which first must run. to give you the cron job to enter.


    For these reasons, I use the following process to get the job in place, and get it running within cron. If I find a solution that gets cron to auto-start on container start, I'll update this topic.


    Using SSH or shellinabox run "docker exec -it <Container-Name> bash" (<Container-Name> is the name of the container you used when first running the image. I used "webserver" in my build, so the line I enter is: docker exec -it webserver bash)


    At the next prompt, which will look similar to this:


    root@90d943253d56:/var/www/html#


    run this command:


    crontab -e -uwww-data (note: www-data seems to be the native default account which PHP/Apache uses for .php files; it's the account my software uses, anyway)


    Once in nano, you'll see a placeholder file:



    (The bottom line is my cron job, set to run every minute)



    Press ctrl-x and then press y to save


    Finally, from the prompt, run:


    service cron restart


    and you should see:


    [ ok ] Restarting periodic command scheduler: cron[....] Stopping periodic command scheduler: cron.
    [ ok ] Starting periodic command scheduler: cron.



    FINAL NOTE: Whenever you restart your server or the Container, you will need to restart cron either by Run Cmd in the container in OMV->Docker, or with SSH.
    I'm not sure why it's happening, but I have to restart it as it isn't auto-starting on container startup.

    Maybe someone can comment with what's needed? I'll edit this and credit you.

  • I read through this whole thread multiple times, ran through ever stacker and reddit I could find and I still can't get apache (in any form) to run properly.


    I'm met with every time:

    Zitat

    Forbidden

    You don't have permission to access /index.html on this server.

    ____________________________________________________________________________________

    Apache/2.4.10 (Debian) Server at 10.1.1.10 Port 9080


    The logs always say this (below), I have tried even setting the sharedfolder location to 777, tried a+x, even went as far as to set the Docker overlay var/ to 777 and a+x. I have followed every troubleshooting I can find, but nothing seems to work.


    Code
    AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.3. Set the 'ServerName' directive globally to suppress this message
    AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.3. Set the 'ServerName' directive globally to suppress this message
    [Sun Aug 09 02:00:15.105264 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.10 (Debian) PHP/7.1.12 configured -- resuming normal operations
    [Sun Aug 09 02:00:15.105389 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
    [Sun Aug 09 02:00:24.543660 2020] [core:error] [pid 16] (13)Permission denied: [client 10.1.1.2:41440] AH00035: access to /index.html denied (filesystem path '/var') because search permissions are missing on a component of the path
    10.1.1.2 - - [09/Aug/2020:02:00:24 -0700] "GET /index.html HTTP/1.1" 403 513 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36"
    [Sun Aug 09 02:00:24.585510 2020] [core:error] [pid 16] (13)Permission denied: [client 10.1.1.2:41440] AH00035: access to /favicon.ico denied (filesystem path '/var') because search permissions are missing on a component of the path, referer: http://10.1.1.10:9080/index.html
    10.1.1.2 - - [09/Aug/2020:02:00:24 -0700] "GET /favicon.ico HTTP/1.1" 403 513 "http://10.1.1.10:9080/index.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36"


    Do either of you know what's going on?

    I have pulled the basic apache image, I built this one on the thread (newest and previous ones) and tried finding other apache images to use, but still no go.



    My reason is I need to deploy Sentrifugo for testing, but can't get the docker for it to work either and Ngnix doesn't work (tried for hours as well) because the php is the wrong version and parts refuse to run on it. Any help would be great, I'm pulling my hair out after hours last night and tonight of trying to get something to just run...

    Modpic.gif

    Dell Precision T3500
    Processor:
    Intel Core i7 960 @3.2ghz
    Memory:
    26GB RAM
    Kernel: Linux 5.10.0-0.bpo.9-amd64
    Version: 5.6.2-1 (Usul) Debian Buster [From Fresh Install of 5]

  • Can you post your docker-compose file? And the respective nginx / php conf?


    Greetings

    David

    "Well... lately this forum has become support for everything except omv" [...] "And is like someone is banning Google from their browsers"


    Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.

    Upload Logfile via WebGUI/CLI
    #openmediavault on freenode IRC | German & English | GMT+1
    Absolutely no Support via PM!

  • Can you post your docker-compose file? And the respective nginx / php conf?


    Greetings

    David

    How do I get the docker-compose file from the plugin wizard on omv? I use all the defaults from the build your own in this thread (and sentrifugo docker image from the repo), run as the primary user (PUID 100 PGID 1000), 80/9080 and set /var/www/html to sharedfolders/extended/web/apache (also tried /srv/(disk-ID)/web/apache


    The web folder houses public folder (web/public) for ngnix websites.


    But all files apache create are created as root still and even if I manually change ownership/permissions them apache still fails to work no matter what settings I try.


    The php nginx conf isn't the issue, it's the php7.0 and that Sentrifugo uses the "allowoverride all" setting for apache and between 7.0 and nginx not having something similar to override it doesn't work. The 2 tutorials for ngnix I found say it ran on 5.x and the other tutorial says they have it running on 7.3. According to forum posts on here I should not change my php to 7.3 or it could break stuff.

    Modpic.gif

    Dell Precision T3500
    Processor:
    Intel Core i7 960 @3.2ghz
    Memory:
    26GB RAM
    Kernel: Linux 5.10.0-0.bpo.9-amd64
    Version: 5.6.2-1 (Usul) Debian Buster [From Fresh Install of 5]

  • But all files apache create are created as root still and even if I manually change ownership/permissions them apache still fails to work no matter what settings I try.


    Can you post the exact log output?


    The 2 tutorials for ngnix I found say it ran on 5.x and the other tutorial says they have it running on 7.3. According to forum posts on here I should not change my php to 7.3 or it could break stuff.


    Uh, if you're using a container you can run whatever you want. The container is independent from the host php.


    Greetings

    David

    "Well... lately this forum has become support for everything except omv" [...] "And is like someone is banning Google from their browsers"


    Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.

    Upload Logfile via WebGUI/CLI
    #openmediavault on freenode IRC | German & English | GMT+1
    Absolutely no Support via PM!

  • I read the article, I do think the problem stems from the bad directions given on hub.docker.com. If he runs this, he will get the application to run, I installed it today after reading about his issue.


    Problem diretions, do not follow

    docker run -d --name sentrifugo -p 80:80 -v /local_path_for_persistent_data:/var/www/html/public -v /local_path_for_logs:/var/www/html/logs --link mariadb:mysql gofaustino/sentrifugo - this came from hub.docker.com


    In order to install this solution you have to first install the mariadb (preferred) in a docker container (corrected issue):


    1) docker run --name mariadb -d -e MYSQL_ROOT_PASSWORD=<passwd> -e MYSQL_DATABASE=sentrifugo -e MYSQL_USER=sentrifugo -e MYSQL_PASSWORD=<passwd> --net=host mariadb


    2) docker run --name sentrifugo -d -e DB_HOSTNAME=127.0.0.1 -e DB_USERNAME=sentrifugo -e DB_PASSWORD=<passwd> -e DB_NAME=sentrifugo -p 80:80 -v <directory>:/var/www/html/public -v /var/logs:/var/www/html/logs --net=host gofaustino/sentrifugo


    In addition, the 4th section (email), make sure the user has a valid email address:

    -> email - acct/pass

    -> server - smtp.gmail.com

    -> Encryption - ssl

    -> port - 465

    (use email account/pass, smtp.gmail.com, ssl, port 465)


    He should be good to go from here.


    Todd

  • I have the mysql and maria dockers both and the mysql plug-in. Errors posted are directly linked to apache issues on docker with omv. It's the same errors on 3 different taged apache images, an apache branch image, this thread's custom build apache image and the sentrifugo image.


    Thank you for your thoughts though.

    Modpic.gif

    Dell Precision T3500
    Processor:
    Intel Core i7 960 @3.2ghz
    Memory:
    26GB RAM
    Kernel: Linux 5.10.0-0.bpo.9-amd64
    Version: 5.6.2-1 (Usul) Debian Buster [From Fresh Install of 5]

  • It's the same errors on 3 different taged apache images, an apache branch image, this thread's custom build apache image and the sentrifugo image.

    In case you overlooked my question: Care to share that specific log?


    Greetings

    David

    "Well... lately this forum has become support for everything except omv" [...] "And is like someone is banning Google from their browsers"


    Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.

    Upload Logfile via WebGUI/CLI
    #openmediavault on freenode IRC | German & English | GMT+1
    Absolutely no Support via PM!

  • In case you overlooked my question: Care to share that specific log?


    Greetings

    David

    Sorry, I missed that post.


    My initial post had the log output, it's just that basically repeating. But here's the a big chunk of the log given from the gui, it just repeats.


    Modpic.gif

    Dell Precision T3500
    Processor:
    Intel Core i7 960 @3.2ghz
    Memory:
    26GB RAM
    Kernel: Linux 5.10.0-0.bpo.9-amd64
    Version: 5.6.2-1 (Usul) Debian Buster [From Fresh Install of 5]

  • Can you show the config of your volumes?


    Then we can dig deeper.


    Greetings

    David

    "Well... lately this forum has become support for everything except omv" [...] "And is like someone is banning Google from their browsers"


    Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.

    Upload Logfile via WebGUI/CLI
    #openmediavault on freenode IRC | German & English | GMT+1
    Absolutely no Support via PM!

  • Restarted the image fresh so there's nothing extra. This is the build image from this thread...


    Folder Permissions:

    Code
    root@omvnas:/sharedfolders/web/apache# ll
    total 0
    drwxrwsrwx+ 2 hakarune users 24 Aug  9 01:59 html/
    drwxr-sr-x+ 3 hakarune users 61 Aug  9 00:18 public/



    Shared Folder Info:

    Attached Images


    Config (from "Container Details" tab):

  • (Sorry, post was too long to include the new full log from restarting so made a double post with the logs added)


    LOGS:

    Code
    AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
    AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
    [Tue Aug 11 01:27:10.181946 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) PHP/7.3.21 configured -- resuming normal operations
    [Tue Aug 11 01:27:10.182075 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
    [Tue Aug 11 01:27:50.362852 2020] [core:error] [pid 17] (13)Permission denied: [client 10.1.1.2:55797] AH00035: access to / denied (filesystem path '/var') because search permissions are missing on a component of the path
    10.1.1.2 - - [11/Aug/2020:01:27:50 -0700] "GET / HTTP/1.1" 403 493 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36"
    10.1.1.2 - - [11/Aug/2020:01:27:50 -0700] "GET /favicon.ico HTTP/1.1" 403 492 "http://10.1.1.10:7080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36"
    [Tue Aug 11 01:27:50.409049 2020] [core:error] [pid 17] (13)Permission denied: [client 10.1.1.2:55797] AH00035: access to /favicon.ico denied (filesystem path '/var') because search permissions are missing on a component of the path, referer: http://10.1.1.10:7080/

    Modpic.gif

    Dell Precision T3500
    Processor:
    Intel Core i7 960 @3.2ghz
    Memory:
    26GB RAM
    Kernel: Linux 5.10.0-0.bpo.9-amd64
    Version: 5.6.2-1 (Usul) Debian Buster [From Fresh Install of 5]

  • Folder Permissions:
    Code
    root@omvnas:/sharedfolders/web/apache# ll
    total 0
    drwxrwsrwx+ 2 hakarune users 24 Aug 9 01:59 html/
    drwxr-sr-x+ 3 hakarune users 61 Aug 9 00:18 public/

    When you configured your container. Did you set it to run as the user hakarune? Every other User won't write have permission.


    Edit: A thread on stackexchange also suggests a missing execute flag on the folder path (which i can't verify due to your ACL ussage).


    Greetings

    David

    "Well... lately this forum has become support for everything except omv" [...] "And is like someone is banning Google from their browsers"


    Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.

    Upload Logfile via WebGUI/CLI
    #openmediavault on freenode IRC | German & English | GMT+1
    Absolutely no Support via PM!

  • Yes it's running as PGID 1000 (users) and PUID 100 (my default account, hakarune). I also tried running with elevated perms, run as default and run as root; still nothing.


    The folders are set as 777 (you can see the html folder is listed as such too). I've also run chmod -R a+x on the root folder and again on html folder. I didn't use ACL to set permissions for folders/volumes, attached the image so you could see everyone can rw. If there's a way to wipe ACL settings let me know because I don't recall ever setting them up and always use SSH for setting perms.


    I went through many stack Qs as well before posting on here because I'm stumped.

    Modpic.gif

    Dell Precision T3500
    Processor:
    Intel Core i7 960 @3.2ghz
    Memory:
    26GB RAM
    Kernel: Linux 5.10.0-0.bpo.9-amd64
    Version: 5.6.2-1 (Usul) Debian Buster [From Fresh Install of 5]

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!