LAMP stands for Linux, Apache, MySQL, and PHP, which are all open-source software that can be used to create a dynamic web server. Here are the steps to install LAMP on your CentOS or Ubuntu server:
Installing LAMP on CentOS
First, update the package manager by running the following command:
sudo yum update
Next, install Apache by running the following command:
sudo yum install httpd
Start the Apache service by running the following command:
sudo systemctl start httpd
Enable Apache to start on boot by running the following command:
sudo systemctl enable httpd
Install MySQL by running the following command:
sudo yum install mariadb-server mariadb
Start the MySQL service by running the following command:
sudo systemctl start mariadb
Enable MySQL to start on boot by running the following command:
sudo systemctl enable mariadb
Run the MySQL secure installation script by running the following command:
sudo mysql_secure_installation
Install PHP by running the following command:
sudo yum install php php-mysql
Restart Apache by running the following command:
sudo systemctl restart httpd
Installing LAMP on Ubuntu
First, update the package manager by running the following command:
sudo apt-get update
Install Apache by running the following command:
sudo apt-get install apache2
Install MySQL by running the following command:
sudo apt-get install mysql-server
Run the MySQL secure installation script by running the following command:
sudo mysql_secure_installation
Install PHP by running the following command:
sudo apt-get install php libapache2-mod-php php-mysql
Restart Apache by running the following command:
sudo systemctl restart apache2
That's it! You should now have a LAMP stack installed on your CentOS or Ubuntu server. To test that everything is working correctly, create a file called "info.php" in the Apache root directory (usually /var/www/html) with the following content:
<?php
phpinfo();
?>
Then, open your web browser and navigate to "http://server-ip/info.php". You should see a page displaying information about your PHP installation.