Day 18 of 100 Days of Devops
Configure LAMP server
xFusionCorp Industries is planning to host a WordPress website on their infra in Stratos Datacenter. They have already done infrastructure configuration—for example, on the storage server they already have a shared directory /vaw/www/html that is mounted on each app host under /var/www/html directory. Please perform the following steps to accomplish the task:
a. Install httpd, php and its dependencies on all app hosts.
b. Apache should serve on port 8088 within the apps.
c. Install/Configure MariaDB server on DB Server.
d. Create a database named kodekloud_db8 and create a database user named kodekloud_roy identified as password Rc5C9EyvbU. Further make sure this newly created user is able to perform all operation on the database you created.
e. Finally you should be able to access the website on LBR link, by clicking on the App button on the top bar. You should see a message like App is able to connect to the database using user kodekloud_sam
Setting up database servers(stdb01)
So lets start with Database
1
2
3
4
5
6
7
8
9
10
sudo yum install mariadb-server -y # install mariadb
sudo cat /etc/passwd # Run to list all users
# Other login paths
mysql:x:27:27:MySQL Server:/var/lib/mysql:/sbin/nologin # this means mysql user does not have login
# Edit the mysql user to login as follows so that we can make changes
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
Setting up the user names for db
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
[peter@stdb01 ~]$ sudo su - mysql # Login with mysql user to access mysql instance
Last login: Sat Dec 13 09:04:03 UTC 2025 on pts/0
[mysql@stdb01 ~]$ mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.5.29-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> ^C
MariaDB [(none)]> CREATE DATABASE kodekloud_db5 ;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> CREATE USER 'kodekloud_sam'@'%' IDENTIFIED BY 'Rc5C9EyvbU'; # Using % to allow all type of hostnames
Query OK, 0 rows affected (0.003 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'hostname';
ERROR 1133 (28000): Can't find any matching row in the user table
MariaDB [(none)]> GRANT ALL PRIVILEGES ON kodekloud_db5.* TO 'kodekloud_sam'@'%';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> CREATE USER 'kodekloud_sam'@'%' IDENTIFIED BY 'Rc5C9EyvbU';
ERROR 1396 (HY000): Operation CREATE USER failed for 'kodekloud_sam'@'localhost'
MariaDB [(none)]> SELECT User, Host FROM mysql.user;
+---------------+-----------+
| User | Host |
+---------------+-----------+
| kodekloud_sam | % |
| mariadb.sys | localhost |
| mysql | localhost |
| root | localhost |
+---------------+-----------+
4 rows in set (0.004 sec)
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| kodekloud_db5 |
| mysql |
| performance_schema |
+--------------------+
Configuring App Servers (stapp01,stapp02,stapp03)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
sudo yum install httpd php php-mysqlnd -y
sudo vi /etc/httpd/conf/httpd.conf
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on a specific IP address, but note that if
# httpd.service is enabled to run at boot time, the address may not be
# available when the service starts. See the httpd.service(8) man
# page for more information.
#
#Listen 12.34.56.78:80
Listen 8084 # Change this line to the port that requires to update
As usual restart the httpd service
1
sudo systemctl restart httpd
Verification of the app server
1
2
[tony@stapp01 ~]$ curl localhost:8084
App is able to connect to the database using user kodekloud_roy[tony@stapp01 ~]$