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
On Debian/Ubuntu:
sudo apt-get update
sudo apt-get install -y apache2 php php-mysql
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
On Debian/Ubuntu (/etc/apache2/ports.conf
):
# Change: Listen 80
# To: Listen 3002
I then restarted the Apache service to apply the change:
sudo systemctl restart httpd # or sudo systemctl restart apache2
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
On Debian/Ubuntu:
sudo apt-get install -y mariadb-server
Once installed, I started and enabled the service to ensure it would run automatically:
sudo systemctl start mariadb
sudo systemctl enable mariadb
3. The Database Setup
This was a critical step. I logged into the MariaDB shell to perform a series of commands.
sudo mysql
-
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)