Here are the steps to install the LAMP stack on Debian 9 Stretch:
- Install Apache Web Server:
sudo apt-get update
sudo apt-get install apache2
- Install MySQL Server:
sudo apt-get install mysql-server
During the installation, you’ll be prompted to set a root password for MySQL.
- Install PHP:
sudo apt-get install php libapache2-mod-php php-mysql
- Configure Apache to use PHP:
sudo nano /etc/apache2/mods-enabled/dir.conf
Change the order of the files so that index.php is listed first:
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
- Restart Apache:
sudo systemctl restart apache2
- Verify the LAMP installation by creating a test PHP file:
sudo nano /var/www/html/info.php
Add the following code to the file:
phpinfo();
- Access the test PHP file in your web browser:
http://your_server_ip_or_domain/info.php
The LAMP stack should now be installed and working on your Debian 9 system.