Question: One of the Nautilus DevOps team members was working to configure services on a kkloud container that is running on App Server 2 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 the details given below:
a. Install apache2 in kkloud container using apt that is running on App Server 2 in Stratos Datacenter.
b. Configure Apache to listen on port 8085 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.
c. Make sure Apache service is up and running inside the container. Keep the container in running state at the end.
Please Note:- Perform the below commands based on your question server, user name & other details that might differ. So please read the task carefully before executing it. All the Best 👍
Solution:
1. At first login on app server as per the task & switch to root user
thor@jump_host
~$ ssh steve@stapp02 The
authenticity of host 'stapp02 (172.16.238.11)' can't be established. ECDSA
key fingerprint is SHA256:ex4GrKD63g3QBiK0GO03JJ0WTuWEy/eu+U/DqLFNV40. ECDSA
key fingerprint is MD5:14:5b:4b:80:61:19:b1:18:45:cb:7d:90:41:2a:02:0b. Are
you sure you want to continue connecting (yes/no)? yes Warning:
Permanently added 'stapp02,172.16.238.11' (ECDSA) to the list of known hosts. steve@stapp02's
password: [steve@stapp02
~]$ sudo su - We trust you have received the usual lecture from the local System Administrator.
It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great
responsibility. [sudo] password for steve: [root@stapp02
~]# |
2. Run the Below command to check the existing docker container running
[root@stapp02
~]# docker ps CONTAINER
ID IMAGE COMMAND CREATED STATUS PORTS NAMES 84ec34eabef9 ubuntu:latest "bash" 3 minutes ago Up 3 minutes kkloud [root@stapp02
~]# |
3. Login on docker container (ubuntu ) & install apache2
[root@stapp02 ~]# docker exec -it kkloud /bin/sh # apt install apache2 -y Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be
installed: apache2-bin
apache2-data apache2-utils file libapr1 libaprutil1
libaprutil1-dbd-sqlite3 libaprutil1-ldap libexpat1 libgdbm-compat4
libgdbm6 libicu66
libjansson4 liblua5.2-0 libmagic-mgc libmagic1 libperl5.30 libxml2
mime-support netbase perl perl-modules-5.30 ssl-cert tzdata xz-utils Suggested packages: apache2-doc
apache2-suexec-pristine | apache2-suexec-custom www-browser ufw gdbm-l10n
perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl make
libb-debug-perl liblocale-codes-perl openssl-blacklist The following NEW packages will be installed: apache2
apache2-bin apache2-data apache2-utils file libapr1 libaprutil1
libaprutil1-dbd-sqlite3 libaprutil1-ldap libexpat1 libgdbm-compat4
libgdbm6 libicu66
libjansson4 liblua5.2-0 libmagic-mgc libmagic1 libperl5.30 libxml2
mime-support netbase perl perl-modules-5.30 ssl-cert tzdata xz-utils 0 upgraded, 26 newly installed, 0 to remove and 0
not upgraded. Need to get 18.8 MB of archives. After this operation, 101 MB of additional disk
space will be used. Get:1 http://archive.ubuntu.com/ubuntu
focal-updates/main amd64 perl-modules-5.30 all 5.30.0-9ubuntu0.2 [2738 kB] Get:2 http://archive.ubuntu.com/ubuntu focal/main
amd64 libgdbm6 amd64 1.18.1-5 [27.4 kB] Setting up tzdata (2021a-0ubuntu0.20.04) ... debconf: unable to initialize frontend: Dialog debconf: (No usable dialog-like program is
installed, so the dialog based frontend cannot be used. at
/usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.) debconf: falling back to frontend: Readline Configuring tzdata ------------------ Please select the geographic area in which you
live. Subsequent configuration questions will narrow this down by presenting a
list of cities, representing the time zones in which they are located. 1.
Africa 4. Australia 7. Atlantic
10. Pacific 13. Etc 2.
America 5. Arctic 8. Europe 11. SystemV 3.
Antarctica 6. Asia 9. Indian 12. US Geographic area: 12 2.
Aleutian 5. Eastern 8. Michigan 11. Samoa 3.
Arizona 6. Hawaii 9. Mountain Time zone: 1 Local time is now: Tue Jul 20 09:06:22 AKDT 2021. Universal Time is now: Tue Jul 20 17:06:22 UTC 2021. Run 'dpkg-reconfigure tzdata' if you wish to change
it. debconf: unable to initialize frontend: Dialog debconf: (No usable dialog-like program is
installed, so the dialog based frontend cannot be used. at
/usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.) debconf: falling back to frontend: Readline Setting up xz-utils (5.2.4-1ubuntu1) ... Enabling conf security. Enabling conf serve-cgi-bin. Enabling site 000-default. invoke-rc.d: could not determine current runlevel invoke-rc.d: policy-rc.d denied execution of start. Processing triggers for libc-bin (2.31-0ubuntu9.2)
... # |
4.Go to the apache2 folder where all configuration files you will find
#
cd /etc/apache2 #
ls -l total
80 -rw-r--r--
1 root root 7224 Jul 4 23:16 apache2.conf drwxr-xr-x
2 root root 4096 Jul 20 09:06
conf-available drwxr-xr-x
2 root root 4096 Jul 20 09:06
conf-enabled -rw-r--r--
1 root root 1782 Jul 4 23:11 envvars -rw-r--r--
1 root root 31063 Jul 4 23:11 magic drwxr-xr-x
2 root root 12288 Jul 20 09:06 mods-available drwxr-xr-x
2 root root 4096 Jul 20 09:06
mods-enabled -rw-r--r--
1 root root 320 Jul 4 23:11 ports.conf drwxr-xr-x
2 root root 4096 Jul 20 09:06
sites-available drwxr-xr-x
2 root root 4096 Jul 20 09:06
sites-enabled # |
5. Since in this Container no Vi editor was installed, hence using sed commands.
If you want you cant install vi editor and edit the below config
#
sed -i 's/Listen 80/Listen 5001/g' ports.conf #
sed -i 's/:80/:5001/g' apache2.conf #
sed -i 's/#ServerName www.example.com/ServerName localhost/g' apache2.conf # |
6. Start apache2 service & confirm the running status
#
service apache2 start * Starting Apache httpd web server
apache2 AH00558: apache2: Could not reliably
determine the server's fully qualified domain name, using 192.168.3.2. Set
the 'ServerName' directive globally to suppress this message * #
service apache2 status * apache2 is running # |
7. Validate the task by Curl
#
curl -Ik localhost:5001 HTTP/1.1
200 OK Date:
Tue, 20 Jul 2021 17:11:47 GMT Server:
Apache/2.4.41 (Ubuntu) Last-Modified:
Tue, 20 Jul 2021 17:06:23 GMT ETag:
"2aa6-5c79112d77f8d" Accept-Ranges:
bytes Content-Length:
10918 Vary:
Accept-Encoding Content-Type:
text/html # |
8. Click on Finish & Confirm to complete the task successfully
Happy Learning!!!!
1 Comments
TQ u
ReplyDelete