Linux, Apache, MySQL, PHP
sudo apt install apache2
Adjust firewall
### Check info
sudo ufw app info "Apache Full"
### Add
sudo ufw allow in "Apache Full"
### Verify
sudo ufw app list
Install MySQL
sudo apt install mysql-server
sudo mysql_secure_installation
Use a password when connecting to MySQL
### Login
sudo mysql
sudo mysql -u root -p
### view current
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
### Set password for root
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PASSWORD';
### Reload with new change
mysql> FLUSH PRIVILEGES;
### Verify new change
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
mysql> exit
(Optional). Disable validate_password_policy
### Set policy to LOW
mysql> SET GLOBAL validate_password_policy=LOW;
### Verify
mysql> SHOW VARIABLES LIKE 'validate_password%';
(Optional) If you need to reconfigure
sudo dpkg-reconfigure phpmyadmin
Install PHP
sudo apt install php libapache2-mod-php php-mysql
(Optional). Make Apache to look for index.php first then index.html
sudo nano /etc/apache2/mods-enabled/dir.conf
### reload after change
sudo systemctl restart apache2
sudo systemctl status apache2
Create folder for hosting websites
sudo mkdir /var/www/domain
sudo chown -R kim:kim /var/www/domain
###Fix permission (optional if not changed)
sudo chmod -R 755 /var/www/domain
Modify the virtual host file
sudo nano /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName yourdomain.com
ServerAlias www.yourdomain.com
DocumentRoot /var/www/domain
<Directory /var/www/domain>
Options -Indexes
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Configtest your virtualhost
### config test
sudo apache2ctl configtest
### to disable
sudo a2dissite 000-default.conf
### to enable
sudo a2ensite 000-default.conf
sudo systemctl restart apache2
Fix /var/www/folder permission
sudo chown -R www-data:www-data folder_name