Ravindra BagaleCourses & study guides

9. PHP, LAMP and LEMP Step by Step

9.3 LAMP on Amazon Linux 2023

Aata purna LAMP ek saath. Amazon Linux madhe Apache PHP-FPM la /etc/httpd/conf.d/php.conf dvaare aapoaap jodto.

                        +------------------ EC2 (Linux) -------------------+
  Browser ──HTTP:80──►  |  Apache (httpd / apache2)                        |
                        |     └─ PHP (mod_php or PHP-FPM) ──► MySQL/MariaDB|
                        |        /var/www/html/*.php         127.0.0.1:3306|
                        +--------------------------------------------------+

Full LAMP installation

Amazon Linux 2023:

sudo yum install -y httpd php php-fpm php-mysqlnd php-gd php-mbstring php-xml mariadb105-server
sudo service httpd start
sudo service php-fpm start
sudo service mariadb start
sudo systemctl enable httpd php-fpm mariadb
sudo mysql_secure_installation

mysql_secure_installation asks a few questions. Recommended answers: remove anonymous users Y, disallow root login remotely Y, remove test database Y, reload privilege tables Y.

echo "<?php echo 'LAMP OK – PHP ' . phpversion();" | sudo tee /var/www/html/test.php
curl -s http://localhost/test.php
sudo rm /var/www/html/test.php          # delete test files after use

Ravindra Bagale's Tip

Many students "skip" mysql_secure_installation because they don't understand the questions. That's a mistake – anonymous users and the test database are open doors for attackers. Always run it once on every new database server.

Lab

Build LAMP on your Amazon Linux instance and confirm the test page prints the PHP version. Then delete it.