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

  • EDIT: After much help from ryecoaaron, I got a working webserver that runs perfectly for my needs.

    Please see the last post in this topic for the details. (You can read the whole topic for the info contained in it, if you wish.)





    Can anyone recommend (by full name as they would appears in the Docker search) a good working image for PHP 7.1 (or 7.2), and Apache?


    I'm striking out finding PHP and Apache images that have adequate info/doc pages with needed parameters (though it could be that I'm not searching properly).


    Thanks in advance.

    • Offizieller Beitrag

    Can anyone recommend (by full name as they would appears in the Docker search) a good working image for PHP 7.1 (or 7.2), and Apache?

    Did you try the official php image with the 7.2-apache tag? https://hub.docker.com/_/php?tab=tags&page=7


    Unfortunately, you may have to download the image from the command line since the search requires four letters and the official image is just php.

    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!

  • I did manage to get the image downloaded via command-line (docker pull php) and now have it in the Repository list in OMV docker.


    Problem is, there's no documentation as to how to set it up. I assume it should be run in Host mode, but no clues as to what parameters/settings are needed here:



    I tried pointing it up to a volume I used previously as my http folder, but no matter what values I put in "Volumes and Bind Mounts" it just won't run. It exits with Code: 0


    I fear this is simply over my head, or I have a very basic misunderstanding about how Docker works.

    • Offizieller Beitrag

    I fear this is simply over my head, or I have a very basic misunderstanding about how Docker works.

    I will look at what it needs in a bit but in the mean time, watch a few of the docker videos to get a feel for how the plugin works.

    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!

  • Thank you. I got Plex installed via Docker last night, and that went smoothly once I watched the video about it (I did have to fix the "noexec" issue using another video), so I do have a basic idea of how Docker works.


    it's just the PHP/Apache parameters issue that's left now. Appreciate the help.

    • Offizieller Beitrag

    Ok, command line isn't needed.

    • Click Pull Image
    • Enter php for the repository and 7.2-apache for the tag.
    • Click Run Image
    • In port fowarding, select 80/tcp from exposed port
    • Use 9080 in the host port
    • Click the plus (add)
    • Add volume with host path of /sharedfolders/test1 and container path of /var/www/html
    • Click the plus (add)

    You will have to change the sharedfolders path to what you want and probably the 9080 port to a port that is open. Remember port 80 is in use by the OMV web interface.

    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!

  • Well, using the info you gave, I got farther. And thank you very much for following up.


    Using Pull image, it wouldn't download even though I got a match in the pull menu. But I clicked the Info button, and it went to the same info page where I previously retrieved the manual pull line, "docker pull php", so I used that instead and retrieved it.


    And I got the service to at least run without an exit code. However.........


    First, I have OMV set to use Port 90 so that I free up the "default" http port of 80.


    And in the setup, the "Select" menu for the Exposed Port won't drop down, clicking ir produces nothing, so I specified a custom port.


    Here's what I have setup in the Container, and when I save, then it is running, but I can't tell where it's running exactly:



    I've navigated to both the Container Path and Host path with SSH and did: php -v


    but in both cases it returned PHP 7.0.33-0+deb9u1


    What am I missing?

    • Offizieller Beitrag

    "docker pull php", so I used that instead and retrieved it.

    When you don't specify a tag without a web server (just php uses latest which does not have a web server), it isn't going to work. Not sure why you can't get pull to work in the web interface but use docker pull php:7.2-apache from the command line. Then the port stuff should work.

    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!

  • Thank you!


    That worked, and now I have it setup. I can reach a "requirements checker" php file I have in place.


    I do have MySQL installed via Plugins, which was what I was using before, and it's working.


    Most of the other requirements have been met as well.


    But... I need both the GD and MySQLi PHP Extensions and I'm not sure how to get those installed.


    Something tells me that's going to require more than a couple lines of parameters passed to the container at runtime. I've thrashed around with the info I found at the php container Info page (https://hub.docker.com/_/php) but no go so far.

    • Offizieller Beitrag

    But... I need both the GD and MySQLi PHP Extensions and I'm not sure how to get those installed.


    Something tells me that's going to require more than a couple lines of parameters passed to the container at runtime. I've thrashed around with the info I found at the php container Info page (hub.docker.com/_/php) but no go so far.

    You could either find a different docker image or create a dockerfile like I did.


    nano Dockerfile


    ctrl-o to save, ctrl-x to exit


    The next line has the name of the that I created. You don't have to name it that.
    docker build -t php-apache-gd .
    This will build a new image based on the official php image. Then it will show up in your image list in the plugin. Run it instead of the php image with the same settings. phpinfo() is telling me that gd and mysqli are enabled.

    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!

  • Thanks once again, that worked. Docker is quite the amazing utility. Took a long time to do all the building, but in the end I have all the PHP requirements met.


    But now the other shoe dropped, lol. The version of MySQL from the OMV Plugin is 4.x but I need 5.6 or better.


    I've found what I thought was a good docker repo (https://hub.docker.com/_/mysql) and it appears that will work.


    I have it "running", but apparently not setup quite right so that it's using the default socket/directories/etc.


    My requirements checker can't check mysql connections directly, I have to run the software install, and that fails at the sql database connection with varying errors depending on what values I try in the container setup.


    The two most common errors are "No such file or directory" or "Host '172.17.0.2' is not allowed to connect to this MariaDB server". (errr..... what??? ...... where does 172.17.0.2 come into play here? O_o ....... My server is set to use both a domain via no-ip.com, an internal IP of 192.168.5.x and an external IP 66.41.x.x)


    It appears there's no video from TechnoDadLife on how to set up MySQL


    But I did find one video about installing MariaDB and will give that a watch, unless you have an easy way to get that MySQL image above working properly at its usual defaults??

    • Offizieller Beitrag

    But I did find one video about installing MariaDB and will give that a watch, unless you have an easy way to get that MySQL image above working properly at its usual defaults??

    mariadb is a fork of mysql and also what you would be using with the plugin on OMV 4.x. So, i would try that. Either way, you need to set the bind-address to 0.0.0.0 (or something other than localhost/127.0.0.1).

    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!

  • Hmm. I spoke too soon. While everything does work now, I am being prompted:


    • You do not have the Zip PHP extension loaded.
    • You do not have the Exif PHP extension loaded.

    While those two extensions aren't actually required, I'd like to get them installed.


    (The Zip Extension allows me to use an automated version update for the software, the Exif Extension allows better image handling.)


    Can those be added to the existing PHP (which I built using your Dockerfile above)?


    Or do I have to rebuild it using that file plus..... some added lines?


    EDIT: After some reading and experimenting with apt-get install from SSH to install exif and zip then noting what dependent libraries it added along with them...... I took a leap of faith and edited the Dockerfile you provided, as follows:



    and while that DID get exif installed properly, it did not install zip. I suspect my choice of words on lines 5 and 11 are wrong. The output was:



    Code
    E: Unable to locate package libzip
    The command '/bin/sh -c apt-get update   && DEBIAN_FRONTEND=noninteractive apt-get install -y   libc6 libstdc++6 libkrb5-3 libcurl3 openssl debconf libexif12 libzip   libfreetype6-dev libjpeg-dev libpng-dev   && docker-php-ext-install mysqli pdo_mysql   && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/   && docker-php-ext-install gd   && docker-php-ext-install exif   && docker-php-ext-install zip   && apt-get clean   && rm -r /var/lib/apt/lists/*' returned a non-zero code: 100

    I tried libzip4 on line 5 and php-zip on line 11 as well, but that failed too with the same error.


    I suspect (ok, hope) I'm just two words away from getting this done..... can you spot where I went wrong?

  • EDIT: Google to the rescue. Here's how to enable mod_rewrite......


    In the running instance of PHP, use "Run Cmd" and enter


    a2enmod rewrite


    followed by:


    service apache2 restart


    and voila.


    Still would like to get the zip extension installed though.

    • Offizieller Beitrag

    Still would like to get the zip extension installed though.

    maybe this will help? https://stackoverflow.com/ques…ed-libzip-is-deprecated-w

    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!

  • Thank you, that did the trick! I appreciate all the help you've given me with this.


    For anyone reading this at a later date........ please go to the last post of the topic for the latest Dockerfile I used.


    P.S. ryecoaaron was great help, without him I'd still be flailing around.

    • Offizieller Beitrag

    a2enmod rewrite

    Did you try adding that to the end of your dockerfile?


    && rm -r /var/lib/apt/lists/* \
    && a2endmod rewrite

    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!

    Einmal editiert, zuletzt von ryecoaaron ()

  • Hmm... no, I didn't, I just ran it based on a Google search result.
    I'll try that right now and edit my post if it does the trick, thanks!


    EDIT: That failed with the error:


    Error response from daemon: Dockerfile parse error line 15: unknown instruction: && (or line number 12 in another attempt)


    Not sure why. I tried positioning it a few lines up and appending a / on the line, but it failed there as well.


    Here's the end of the Dockerfile with both attempts:


    Code
    && docker-php-ext-install gd \
      && docker-php-ext-install exif \
      && apt-get clean \
      && rm -r /var/lib/apt/lists/*
      && a2endmod rewrite



    Code
    && docker-php-ext-install gd \
      && docker-php-ext-install exif \
      && a2endmod rewrite \
      && apt-get clean \
      && rm -r /var/lib/apt/lists/*

    Not sure what's up there.

    • Offizieller Beitrag

    Not sure why. I tried positioning it a few lines up and appending a / on the line, but it failed there as well.

    Sorry, I forgot to add a backslash \ to the end the lists line. So, here is what it should look like (just built it on my laptop). The service shouldn't have to be restarted because there is no service with docker and it isn't running at this point.


    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!

Jetzt mitmachen!

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