DEV Community

Wycliffe A. Onyango
Wycliffe A. Onyango

Posted on

100 Days of DevOps: Day 18

Web Deployment: My LAMP Stack Configuration

I successfully configured a full LAMP stack to host a WordPress site for XFusionCorp Industries. It was a hands-on experience that took me through every layer of the web hosting stack, from the web server to the database.

Here's a breakdown of the steps I took:


1. The Core Components: Apache and PHP

First, I had to ensure the foundation was solid. On all the app hosts, I installed Apache and PHP. The commands I used were:

On CentOS/RHEL:

sudo yum install -y httpd php php-mysqlnd
Enter fullscreen mode Exit fullscreen mode

On Debian/Ubuntu:

sudo apt-get update
sudo apt-get install -y apache2 php php-mysql
Enter fullscreen mode Exit fullscreen mode

I then configured Apache to listen on a specific, non-standard port, 3002, as required by the project. I opened the Apache configuration file and changed the Listen directive.

On CentOS/RHEL (/etc/httpd/conf/httpd.conf):

# Change: Listen 80
# To:     Listen 3002
Enter fullscreen mode Exit fullscreen mode

On Debian/Ubuntu (/etc/apache2/ports.conf):

# Change: Listen 80
# To:     Listen 3002
Enter fullscreen mode Exit fullscreen mode

I then restarted the Apache service to apply the change:

sudo systemctl restart httpd # or sudo systemctl restart apache2
Enter fullscreen mode Exit fullscreen mode

2. The Data Backbone: MariaDB

Next, I shifted my focus to the database server. I installed MariaDB, a robust relational database that would store all of the WordPress site's information.

On CentOS/RHEL:

sudo yum install -y mariadb-server
Enter fullscreen mode Exit fullscreen mode

On Debian/Ubuntu:

sudo apt-get install -y mariadb-server
Enter fullscreen mode Exit fullscreen mode

Once installed, I started and enabled the service to ensure it would run automatically:

sudo systemctl start mariadb
sudo systemctl enable mariadb
Enter fullscreen mode Exit fullscreen mode

3. The Database Setup

This was a critical step. I logged into the MariaDB shell to perform a series of commands.

sudo mysql
Enter fullscreen mode Exit fullscreen mode
  • I created a dedicated database named kodekloud_db9:

    CREATE DATABASE kodekloud_db9;
    
  • I created a database user, kodekloud_joy, with a unique password:

    CREATE USER 'kodekloud_joy'@'%' IDENTIFIED BY 'LQfKeWWxWD';
    
  • Most importantly, I granted this new user all privileges on the new database:

    GRANT ALL PRIVILEGES ON kodekloud_db9.* TO 'kodekloud_joy'@'%';
    FLUSH PRIVILEGES;
    
  • I then exited the MariaDB shell:

    EXIT;
    

4. The Final Check

With all the pieces in place, the moment of truth arrived. I accessed the website through the load balancer link. The site successfully loaded, and a message confirmed that the application was able to connect to the database using the user kodekloud_joy. This final successful connection proved that every component—from the web server to the database—was properly configured and communicating, completing the deployment.

Top comments (0)