Install LAMP In CentOS Server

You are currently viewing Install LAMP In CentOS Server

To install the LAMP (Linux, Apache, MySQL/MariaDB, PHP/Python/Perl) stack on CentOS, follow these steps:

  1. Update the System:
   sudo yum update
  1. Install Apache:
   sudo yum install httpd
  1. Start and Enable Apache:
   sudo systemctl start httpd
   sudo systemctl enable httpd
  1. Install MySQL (MariaDB):
   sudo yum install mariadb-server
  1. Start and Enable MariaDB:
   sudo systemctl start mariadb
   sudo systemctl enable mariadb
  1. Run MySQL Secure Installation:
   sudo mysql_secure_installation

Follow the on-screen instructions to set the root password and secure your MySQL installation.

  1. Install PHP and Required Modules:
   sudo yum install php php-mysqlnd
  1. Restart Apache:
   sudo systemctl restart httpd
  1. Test the LAMP Stack:
    Create a PHP info file to test the installation. Create a file named info.php in your web root directory (often /var/www/html/):
   <?php
   phpinfo();
   ?>

Open your web browser and navigate to http://your_server_ip/info.php. You should see the PHP information page.

  1. Firewall Configuration:
    If you have a firewall enabled, you may need to open the necessary ports. For Apache, you can use:
    sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --reload

These steps provide a basic LAMP stack on CentOS. Depending on your application requirements, you might need to install additional PHP modules or configure Apache for specific use cases. Adjust the configurations as needed for your environment and application.

Leave a Reply