Install LAMP stack on Ubuntu/Debian
Published:
• Updated:
Install Apache2, MySQL and phpMyAdmin on a Linux server:
Update System
sudo apt update && sudo apt upgrade -y; apt install sudoInstall Apache2
sudo apt install apache2 -yFedora/CentOS/RHEL-based systems:
sudo yum install httpdEnable and start the Apache service:
sudo systemctl enable apache2sudo systemctl start apache2Install MySQL Server
sudo apt install mysql-server -ySecure the MySQL installation:
sudo mysql_secure_installationInstall PHP and Required Extensions
sudo apt install php libapache2-mod-php php-mysql php-mbstring php-zip php-gd php-json php-curl -yInstall phpMyAdmin
sudo apt install phpmyadmin -yEnable phpMyAdmin in Apache
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadminRestart Apache:
sudo systemctl restart apache2Solution: Change the authentication plugin for the root user to mysql_native_password
- Connect to MySQL as root:
sudo mysql -u root -pExecute the following SQL commands:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root_password';FLUSH PRIVILEGES;Replace root_password with your actual root password.
- Exit the MySQL client:
exit- Restart the MySQL service:
sudo systemctl restart mysql