Giter Site home page Giter Site logo

izdock-httpd's Introduction

Description

Production ready Apache HTTPD Web Server + mod_php + izsendmail for MTA logging

Supported tags

  • 2.4.43-php7.4.X-BUILD, 2.4.43-php7.4.X, 2.4-php7.4, php7.4, 2, 2.4, 2.4.43, latest
  • 2.4.43-php7.3.X-BUILD, 2.4.43-php7.3.X, 2.4-php7.3, php7.3
  • 2.4.43-php7.2.X-BUILD, 2.4.43-php7.2.X, 2.4-php7.2, php7.2
  • 2.4.43-php7.1.X-BUILD, 2.4.43-php7.1.X, 2.4-php7.1, php7.1

Where X is the patch version number, and BUILD is the build number (look into project Tags page to discover the latest versions)

Dockerfile

Features

  • Small image footprint
  • Based on official httpd and Debian Buster-Slim image
  • OnDemand configurable Apache MPM Worker (use event or worker for best scalability and memory optimization, PHP get automatically disabled because is not ZTS compiled). The default Apache MPM Worker is prefork (if prefork is used, mod_php will be enabled by default)
  • Build from scratch PHP as NTS (Not Threat Safe) and many useful php modules included, plus external modules (igbinary apcu msgpack opcache memcached redis xdebug phpiredis realpath_turbo tarantool)
  • Included izsendmail bash script as wrapper for msmtp used for smarthost delivery of mail messages sent from PHP scripts using sendmail() function
  • Automatically generate Self Signed SSL certificates if not found into configuration to avoid apache startup problems
  • Integrated PHP-FPM support using runit service manager
  • Many customizable variables to use

What is httpd?

The Apache HTTP Server, colloquially called Apache, is a Web server application notable for playing a key role in the initial growth of the World Wide Web. Originally based on the NCSA HTTPd server, development of Apache began in early 1995 after work on the NCSA code stalled. Apache quickly overtook NCSA HTTPd as the dominant HTTP server, and has remained the most popular HTTP server in use since April 1996.

wikipedia.org/wiki/Apache_HTTP_Server

logo

How to use this image.

This image only contains Apache httpd with the defaults from official httpd repository and the PHP already installed (mod_php) with many modules already compiled as libphp.

Environment default variables

You can change the default behaviour using the following variables (in bold the default values):

Apache Web Server:

: ${MULTISERVICE:=false}          # (true|**false**) enable multiple service manager
: ${UMASK:=0002}                  # (**0002**) default umask when creating new files
: ${SERVERNAME:=$HOSTNAME}        # (**$HOSTNAME**) default web server hostname
: ${HTTPD_ENABLED:=true}          # (**true**|false) # enable apache web server
: ${HTTPD_MOD_SSL:=false}         # (true|**false**) enable apache module mod_ssl
: ${HTTPD_CONF_DIR:=/etc/apache2} # (**/etc/apache2**) # apache config dir
: ${HTTPD_MPM:=prefork}           # (event|worker|**prefork**) # default apache mpm worker to use
: ${PHP_ENABLED:=true}            # (**true**|false) enable apache module mod_php
: ${PHPFPM_ENABLED:=false}        # (true|**false**) enable php-fpm service
: ${PHPINFO:=false}               # (true|**false**) if true, then automatically create a **info.php** file into webroot
: ${DOCUMENTROOT:=/var/www/localhost/htdocs} # (**directory path**) default webroot path

MSMTP MTA Agent:

: ${domain:="$HOSTNAME"}                # local hostname
: ${from:="[email protected]"} # default From email address
: ${host:="localhost"}                  # remote smtp server
: ${port:=25}                           # smtp port
: ${tls:="off"}                         # (**on**|**off**) enable tls
: ${starttls:="off"}                    # (**on**|**off**) enable starttls
: ${username:=""}                       # username for auth smtp server
: ${password:=""}                       # password for auth smtp server
: ${timeout:=3600}                      # connection timeout

Create a Dockerfile in your project

FROM izdock/httpd:2.4-php7.2
COPY ./public-html/ /usr/local/apache2/htdocs/

Then, run the commands to build and run the Docker image:

$ docker build -t my-httpd .
$ docker run -dit --name my-webapp -p 8080:80 my-httpd

Visit http://localhost:8080 and you will see It works!

Without a Dockerfile

If you don't want to include a Dockerfile in your project, it is sufficient to do the following:

$ docker run -dit --name my-webapp -p 8080:80 -v "$PWD":/var/www/localhost/htdocs izdock/httpd:2.4-php7.2

Configuration

To customize the configuration of the httpd server, just COPY your custom configuration in as /etc/apache2/conf/httpd.conf.

FROM izdock/httpd:2.4-php7.2
COPY ./my-httpd.conf /etc/apache2/conf/httpd.conf

SSL/HTTPS

If you want to run your web traffic over SSL, the simplest setup is to COPY or mount (-v) your server.crt and server.key into /etc/apache2/conf/ and then customize the /etc/apache2/conf/httpd.conf by removing the comment symbol from the following lines:

...
#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
...
#LoadModule ssl_module modules/mod_ssl.so
...
#Include conf/extra/httpd-ssl.conf
...

The conf/extra/httpd-ssl.conf configuration file will use the certificate files previously added and tell the daemon to also listen on port 443. Be sure to also add something like -p 443:443 to your docker run to forward the https port.

This could be accomplished with a sed line similar to the following:

RUN sed -i \
		-e 's/^#\(Include .*httpd-ssl.conf\)/\1/' \
		-e 's/^#\(LoadModule .*mod_ssl.so\)/\1/' \
		-e 's/^#\(LoadModule .*mod_socache_shmcb.so\)/\1/' \
		conf/httpd.conf

Quick reference

httpd:<version>

This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.

This image is based on the popular Alpine Linux project, available in the alpine official image. Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general.

This variant is highly recommended when final image size being as small as possible is desired. The main caveat to note is that it does use musl libc instead of glibc and friends, so certain software might run into issues depending on the depth of their libc requirements. However, most software doesn't have an issue with this, so this variant is usually a very safe choice. See this Hacker News comment thread for more discussion of the issues that might arise and some pro/con comparisons of using Alpine-based images.

To minimize image size, it's uncommon for additional related tools (such as git or bash) to be included in Alpine-based images. Using this image as a base, add the things you need in your own Dockerfile (see the alpine image description for examples of how to install packages if you are unfamiliar).

License

View Apache license information and PHP license information and for the software contained in this image.

As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).

Some additional license information which was able to be auto-detected might be found in the repo-info repository's httpd/ directory.

As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.