Next lesson playing in 5 seconds

  • Overview
  • Transcript

3.1 Installing httpd and NGINX

In this lesson, I'll show you how to configure containers for the httpd and NGINX web servers.

3.1 Installing httpd and NGINX

Hello everyone, this is Reggie Dawson. Welcome to the Docker for Deployment course for Tots plus. In this video, we will use Docker to set up two web servers. First, we will set up the official Apache server HTTPD, then we will set up an Nginx server. As you will see, setting up these servers is a simple affair once you understand how Docker works. It's useful as a developer to set up a web server when testing a web app or a site. For example, restrictions prevent JavaScript files from being run locally in Chrome. As a result we need a way to get a web server up and running locally. Open up Kitematic and search for HTTPD, then click on Create to start a container from the image. This will go out and grab the image if we don't have it locally and start a container, the preview should start and the log should display. If we click on this window it will display our preview. Now I know our preview doesn't match what it actually displays but that's a little bug in Kitematic where it keeps remnants of other containers that you may have run. But as you can see it's actually serving a web page from the Apache server. If we click on settings and go to ports we can see what ports are exposed. Here we have port 32768 as the port on our host, map the port 80 from our container. Notice we didn't have to specify this before we ran our image. This is because this was specified in the Docker file. Here I am gonna illustrate the limitations of using Kitematic alone. If the image is not configured properly it won't work well in Kitematic. This is the same reason our changes did not propagate when we saved our image, since the volumes were not exposed in the Docker file. The good news is there are a lot of images out there that are configured properly for use with guide Kitematic. We will be using some of these as we configure our servers going forward. Next, let's go over to volumes. Here we don't have any volumes exposed and as a result, this image is not very useful for us. In order to make full use of this image, we would need to configure this image from the terminal. Open up the quickstart terminal. Then use this Docker run command. We are naming our image true Apache and are exposing a port of 2244 on our host map the port 80 on our container. Then we have our local folder map to our exposed volume from the image. This is the default location that Apache will look at to serve HTML files. As a result we will build our project here. Previously we set up this folder to serve the example HTML file we had. In that example we were using an unofficial version of the Apache image while this is the official repository. Now if we preview the page we can see our sample content. And that's all we need to set up the Apache web server. After that all we need to do is stop our container when we're done with it and restart it when we're ready to use it again. Next we're going to configure the Nginx web server. As opposed to the Apache image this will be even easier to configure. For those who don't wanna use the command line at all in Docker, Nginx is your best bet. The image is configured properly to run on Kitematic alone. Do a search in Kitematic for Nginx. Choose the official Nginx version and click Create. You'll notice an area named volumes appears when our container starts. This is because the volume has already been mapped in the Docker file. If we click on the volume you will be prompted to enable volumes. And then it will display the local folder that is mapped to our volume. Here we can change the mapping to our content if we like. If we look at the ports for Nginx, we will find port 80 and 443 exposed in the Nginx container. 80 of course is HTTP while port 443 if for HTTPS. Another thing to note is that we can change the ports we use on the host directly from the screen as well. At this point the only thing left to do is create our web content and test. In the next video we will set up a ghost in WordPress server.

Back to the top