Welcome to our comprehensive guide on setting up a LAMP (Linux, Apache, MySQL, PHP) stack on Debian 12, a popular choice for many web developers and hosting environments. This tutorial will walk you through the installation of Apache, PHP, and MySQL, setting up a solid foundation for your web applications, such as WordPress.
Step 1: Update Your System
Before installing any new packages, it’s a good practice to update your system’s package list. Open your terminal and execute the following command:
sudo apt update && sudo apt upgrade -y
Step 2: Install Apache
Apache is one of the most popular web servers in the world. To install Apache on Debian 12, use the following command:
Once the installation is complete, you can check the status of Apache to ensure it is running:
sudo systemctl status apache2
Step 3: Install MySQL
MySQL is a widely-used database management system. To install MySQL, run the following command:
sudo apt install default-mysql-server -y
After installation, secure your MySQL installation:
sudo mysql_secure_installation
Follow the on-screen prompts to configure your MySQL server securely.
Step 4: Install PHP
PHP is a server-side scripting language designed for web development. You can install PHP and its Apache module by executing:
sudo apt install php libapache2-mod-php php-mysql -y
To confirm the installation, create a test PHP file in Apache’s root directory:
echo “” | sudo tee /var/www/html/phpinfo.php
Now, you can access this page in your web browser by visiting http://your_server_ip/phpinfo.php to see all PHP configurations.
Step 5: Test and Restart Apache
To make all the changes effective, restart Apache:
sudo systemctl restart apache2
Ensure everything is set up correctly by visiting your server’s IP address in a web browser. If Apache is running, you should see the default Debian Apache web page.
Conclusion
You have successfully installed Apache, PHP, and MySQL on Debian 12. This setup is ideal for hosting dynamic websites and applications. For further customization and security enhancements, continue to explore Apache and PHP configurations.