Company Logo


LAMP Installation



br>




LAMP Installation on CentOS 9

1. Download the Linux server setup for the system on which you want to install it....

Flavor of Linux ServerDownload Link
RedhatDownload
CentosDownload
UbuntuDownload
DebianDownload
Fedora ServerDownload
Click Installation to go to the CentOS installation page.Installation

Update the System


First, update your CentOS system to ensure all packages are up to date.


sudo dnf update -y

Step 1: Install Apache Web Server


Install the Apache web server using dnf:


sudo dnf install httpd -y

Enable Apache to start on boot and start the service:


sudo systemctl enable httpd

sudo systemctl start httpd

You can check if Apache is running with:


sudo systemctl status httpd

Step 2: Install MariaDB (MySQL Alternative)


CentOS 9 uses MariaDB as the default database server. Install it using dnf:


sudo dnf install mariadb-server -y

Enable MariaDB to start on boot and start the service:


sudo systemctl enable mariadb

sudo systemctl start mariadb

Secure the MariaDB installation:


sudo mysql_secure_installation

Follow the prompts to set the root password and improve security.


Step 3: Install PHP


Install PHP and the necessary PHP extensions:


sudo dnf install php php-mysqlnd php-fpm php-xml php-json php-common -y

To verify the PHP installation, check the version:


php -v

Step 4: Configure Firewall


If you're running a firewall, allow HTTP and HTTPS traffic:


sudo firewall-cmd --permanent --add-service=http

sudo firewall-cmd --permanent --add-service=https

sudo firewall-cmd --reload

Step 5: Test the LAMP Stack


Apache Test


Open a web browser and navigate to your server's IP address. You should see the Apache test page.


PHP Test


Create a test PHP file in the web root directory:


echo "" | sudo tee /var/www/html/info.php

Now, go to http://your_server_ip/info.php in a web browser. If you see the PHP information page, PHP is working correctly.


MariaDB Test


Log into MariaDB:


sudo mysql -u root -p

You should be prompted for the root password. If you can log in, MariaDB is working.


Conclusion


That's it! You've successfully installed and configured the LAMP stack on CentOS 9.

© 2024 My Blog. All Rights Reserved.