Wednesday, April 24, 2024

Install LAMP Stack on CentOS

Assalamu Alaikum.
Welcome to Uddoyon, in this article we try to know about LAMP (Linux, Apache, MySQL, and PHP) Installation on CentOS System so keep reading…

The LAMP stack consisting of Linux, Apache, MySQL and PHP is a powerful combination that allows you to set up a web server environment for hosting dynamic websites and applications. In this guide, we will walk you through the process of installing a LAMP stack on an CentOS system.

- Advertisement -

Step 1 – Update System:
Before installing any software, it’s a good practice to update the system’s package repositories and software packages. Open a terminal and run the following commands:

sudo yum update

Step 2 – Install Apache:
Install the Apache web server using the following command:

- Advertisement -
sudo yum install httpd

Step 3 – Start Apache:
Start the Apache service and enable it to start on boot:

sudo systemctl start httpd
sudo systemctl enable httpd

Step 4 – Install MySQL:
Install the MySQL database server and related packages:

- Advertisement -
sudo yum install mariadb-server mariadb

Step 5 – Secure MySQL:
Run the MySQL security script to improve the security of your installation:

sudo mysql_secure_installation

Step 6 – Start MySQL:
Start the MySQL service and enable it to start on boot:

sudo systemctl start mariadb
sudo systemctl enable mariadb

Step 7 – Install PHP:
Install PHP and necessary modules:

sudo yum install php php-mysql

Step 8 – Test PHP:
Create a PHP test file to ensure PHP is working properly:

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

“You can then access this file in your web browser by navigating to http://your_server_ip/info.php.”

Step 9 – Configure Firewall:
Allow HTTP and HTTPS traffic through the firewall:

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

Step 10 – Adjust SELinux Settings (Optional):
If you have SELinux enabled, you might need to adjust its settings to allow Apache to serve content. Run the following command:

sudo setsebool -P httpd_can_network_connect on

Step 11 – Test Your LAMP Stack:
Open a web browser and navigate to your server’s IP address or domain name. You should see the default Apache welcome page. To test PHP, access the info.php file you created earlier, and it should display PHP configuration details.

Congratulations, you’ve successfully installed the LAMP stack (Apache, MySQL, PHP) on CentOS! You now have a powerful platform for developing and hosting dynamic websites and applications.

Thanks for Reading, stay with us to know more things as like this.

- Advertisement -
- Advertisement -
Related Articles
- Advertisement -

Popular Articles

- Advertisement -
error: Content is protected !!