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 mysqlChange Apache Port Configuration (Optional)
Edit ports.conf:
sudo nano /etc/apache2/ports.confReplace default http port on Listen 80 or https Listen 443.
Update Virtual Hosts:
sudo nano /etc/apache2/sites-available/000-default.confReplace default http port on <VirtualHost *:80>.
Restart Apache:
sudo systemctl restart apache2Directory Permissions (optional)
chmod -R 755 /var/www/htmlchown -R www-data:www-data /var/www/html