One of the Nautilus DevOps team members was working to configure services on a kkloud container that is running on App Server 1 in Stratos Datacenter. Due to some personal work he is on PTO for the rest of the week, but we need to finish his pending work ASAP. Please complete the remaining work as per details given below:
Install apache2 in kkloud container using apt that is running on App Server 1 in Stratos Datacenter.
Configure Apache to listen on port 6000 instead of default http port. Do not bind it to listen on specific IP or hostname only, i.e it should listen on localhost, 127.0.0.1, container ip, etc.
Make sure Apache service is up and running inside the container. Keep the container in running state at the end.
Let’s check the running containers
docker ps
[tony@stapp01 ~]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dcdc693d1175 ubuntu:18.04 "/bin/bash" 8 minutes ago Up 8 minutes kkloud
Login inside the container
docker exec -it kkloud /bin/bash
[tony@stapp01 ~]$ docker exec -it kkloud /bin/bash
root@dcdc693d1175:/#
Install apache2 inside the container
So, we are already inside the container. lets run the following command to install apache2:
apt install apache2 vim -y
We have installed apache2 and vim
Configure Apache2
We have installed apache2 and vim so far. Now let’s configure Apache2 to change the default port 80 to 6000.
To modify port, we have to edit file in /etc/apache2/ports.conf:
vim /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 80
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
just change 80 to 6000
Another part is to update the 000-default.conf.
Just changed 80 to 6000:
<VirtualHost *:6000>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Let’s start the apache2 service
To run apache2 service inside the container:
/usr/sbin/apache2ctl start
To verify if apache2 is started or not:
ps aux | grep apache2
It will show running process of apache2
root@dcdc693d1175:~# ps aux | grep apache2
root 116 0.0 0.0 73972 4632 ? Ss 02:12 0:00 /usr/sbin/apache2 -k start
www-data 117 0.0 0.0 2067072 4464 ? Sl 02:12 0:00 /usr/sbin/apache2 -k start
www-data 118 0.0 0.0 2067072 4464 ? Sl 02:12 0:00 /usr/sbin/apache2 -k start
root 174 0.0 0.0 11472 1076 pts/1 S+ 02:13 0:00 grep --color=auto apache2
To test if apache2 is running or not:
curl localhost:6000
-it flags for interactive terminal