Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
This guide will walk you through installing a LAMP stack on Debian 12. The LAMP stack—Linux, Apache, MariaDB, and PHP—is a popular setup for hosting websites on Linux. While MySQL is commonly used in LAMP stacks, this guide opts for MariaDB, which offers improved speed, scalability, and features.
Note: This guide uses
nano
for editing text files, but feel free to usevim
or any preferred text editor.
useradd websrv
Set a password for this user:
passwd websrv
Grant sudo privileges:
usermod -a -G sudo websrv
Log in as the new user:
su websrv
Verify:
whoami
sudo apt update
sudo apt install mariadb-server mariadb-client -y
sudo mysql_secure_installation
Follow the prompts to configure security settings, choosing y
or n
as needed.
sudo apt install apache2 apache2-doc -y
sudo apt install php php-mysql -y
sudo nano /var/www/html/test.php
Add:
<?php phpinfo(); ?>
Navigate to http://<server-ip>/test.php
in your browser to see PHP details.
sudo apt install phpmyadmin -y
Choose apache2
for configuration when prompted.
sudo systemctl restart apache2
Access phpMyAdmin at http://<server-ip>/phpmyadmin
.
sudo mysql
CREATE USER 'mywpsite'@'localhost' IDENTIFIED BY 'AstrongSecurepassword%$';
GRANT ALL PRIVILEGES ON *.* TO 'mywpsite'@'localhost';
FLUSH PRIVILEGES;
exit;
sudo mkdir /var/www/examplesite
sudo nano /var/www/examplesite/index.html
Add sample content like Hello World!
sudo nano /etc/apache2/sites-available/examplesite.conf
Add:
<VirtualHost *:80>
ServerName www.examplesite.com
ServerAlias example.com
DocumentRoot "/var/www/examplesite"
</VirtualHost>
sudo a2ensite examplesite
sudo systemctl reload apache2
Following these steps, you’ll have a fully functional LAMP stack for website hosting on Debian 12. For scalable and flexible hosting, review our VPS packages.