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.
Ravindra Bagale's Tip – मराठी
mysql_secure_installation ला बरेच students "skip" करतात कारण प्रश्न समजत नाहीत. ही चूक आहे – anonymous users आणि test database attackers साठी उघडे दरवाजे आहेत. प्रत्येक नवीन database server वर हे एकदा नक्की चालवा.
Ravindra Bagale's Tip – हिंदी
बहुत से students mysql_secure_installation को "skip" कर देते हैं क्योंकि सवाल समझ नहीं आते. यह गलती है – anonymous users और test database attackers के लिए खुले दरवाज़े हैं. हर नए database server पर इसे एक बार ज़रूर चलाओ.
Lab
Build LAMP on your Amazon Linux instance and confirm the test page prints the PHP version. Then delete it.