Here’s a step-by-step guide to install the LAMP (Linux, Apache, MariaDB, PHP) stack on CentOS and RHEL 7:
- Install Apache:
sudo yum install httpd
- Start and enable the Apache service:
sudo systemctl start httpd
sudo systemctl enable httpd
- Install MariaDB:
sudo yum install mariadb-server mariadb
- Start and enable the MariaDB service:
sudo systemctl start mariadb
sudo systemctl enable mariadb
- Secure MariaDB:
sudo mysql_secure_installation
- Install PHP:
sudo yum install php php-mysql
- Restart Apache to enable PHP:
sudo systemctl restart httpd
- Test PHP by creating a file called ‘info.php’ in the document root directory ‘/var/www/html’ with the following content:
phpinfo();
- Open a web browser and access ‘http://localhost/info.php‘ to view the PHP information page.
With these steps, you have installed and set up a basic LAMP stack on your CentOS or RHEL 7 system. You can now use Apache and PHP to serve web content, and MariaDB to store and manage data.