Docker Apache Web Server

broken image


Deploy A Static Website with Docker The static websites are the HTML pages, directly severed by any web servers. It may also include some other static assets like css, js and images. In this tutorial you will learn, how to deploy a static website on Docker container. 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.

  1. Docker Apache Web Server Example
  2. See Full List On Hub.docker.com

Let's walk through how to setup PHP and Apache with Docker
We will use the following components to achieve this
1. Dockerfile
2. Docker compose file
3. Docker and Docker compose commands
With the PHP official Docker image, apache's implementation is already available
see this link:
https://hub.docker.com/layers/php/library/php/7.3-apache/images/sha256-0c3dbffed38021b5fae422ae0044b1bffc74f42330051b9bebdd2468c130eb89?context=explore

When we run this, PHP 7.3 along with apache will be launched in one container, we will use this image as a base image throughout this post.
With this default image, comes limited packages, you may want to add some PHP packages they are widely used for development.
Let's try to make Dockerfile where we will mention many of widely used packages and see how to build that and use it to launch containers.

You can add additional PHP extensions wherever needed, Do comment if you face any issues while adding more packages in Dockerfile

Let's create Docker-compose.yaml file as well

Above docker-compose file will do the following

  1. When built, creates a new docker image from Dockerfile
  2. 80 and 443 ports are exposed with the same system ports, so it is accessible through System.
  3. Volumes are mounted. /var/www/html contains code and /etc/apache2 contains apache configuration files, volumes are mounted to make it persistent even after container restarts.
  4. restart always policy is set up, so even if docker crashes or system crashes, when the system is up, the container will also re-run

Save this Dockerfile in the same folder as docker-compose files'
Run command

It will build this Docker image and give it name that will be written in docker-compose file, in our case php-apache-7.3

Apache

Docker Apache Web Server Example

Docker

Now, let's make container from this image and complete task.

Monitoring Apache Web Server running on Docker

Docker Apache Web Server Example

Now, let's make container from this image and complete task.

With docker ps, you can check if the container is running or not.

See Full List On Hub.docker.com

Do Comment, if you find any difficulties while implementing this





broken image