Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
| server_configuration:apache [2025/03/27 15:42] – external edit 127.0.0.1 | server_configuration:apache [2025/04/02 09:49] (current) – david | ||
|---|---|---|---|
| Line 52: | Line 52: | ||
| <code bash> | <code bash> | ||
| certbot --apache | certbot --apache | ||
| + | </ | ||
| + | |||
| + | ====== Apache2 Migration ====== | ||
| + | |||
| + | <code bash> | ||
| + | ################################################################################ | ||
| + | # Backup | ||
| + | ################################################################################ | ||
| + | |||
| + | cd / | ||
| + | |||
| + | sudo cp -r / | ||
| + | sudo cp -r /var/www . | ||
| + | sudo cp -r / | ||
| + | </ | ||
| + | |||
| + | <code bash> | ||
| + | ################################################################################ | ||
| + | # Fix hostname | ||
| + | ################################################################################ | ||
| + | sudo hostnamectl set-hostname roman-halliday | ||
| + | |||
| + | ################################################################################ | ||
| + | # Install LAMP Stack | ||
| + | ################################################################################ | ||
| + | sudo apt-get install apache2 libapache2-mod-php php-mysql php-pgsql | ||
| + | |||
| + | ################################################################################ | ||
| + | # MySQL - See : https:// | ||
| + | ################################################################################ | ||
| + | sudo apt-get install mysqld | ||
| + | ################################################################################ | ||
| + | # MySQL : Manage security setup script | ||
| + | |||
| + | ALTER USER ' | ||
| + | |||
| + | #> I wasn’t able to login to mysql with sudo mysql after running ALTER USER ' | ||
| + | #> I fixed this by logging it with mysql -p, then running ALTER USER ' | ||
| + | |||
| + | ALTER USER ' | ||
| + | |||
| + | FLUSH PRIVILEGES; | ||
| + | |||
| + | SELECT * FROM mysql.user \G | ||
| + | SELECT Host, User, plugin, password_last_changed FROM mysql.user \G | ||
| + | |||
| + | sudo systemctl restart mysql | ||
| + | |||
| + | # Uninstall (if you borked it) | ||
| + | sudo apt remove --purge mysql\* -y | ||
| + | sudo find / -name mysql | ||
| + | |||
| + | |||
| + | ################################################################################ | ||
| + | # WordPress requirements: | ||
| + | sudo apt-get install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip | ||
| + | |||
| + | ################################################################################ | ||
| + | # Firewall | ||
| + | ################################################################################ | ||
| + | sudo ufw allow Apache Full | ||
| + | |||
| + | |||
| + | ################################################################################ | ||
| + | # Backup (original configurations/ | ||
| + | ################################################################################ | ||
| + | sudo apt-get install bzip2 | ||
| + | mkdir -p ~/backups | ||
| + | sudo tar -cjf ~/ | ||
| + | sudo tar -cjf ~/ | ||
| + | sudo tar -cjf ~/ | ||
| + | |||
| + | ################################################################################ | ||
| + | # Restore Files (from backup) | ||
| + | ################################################################################ | ||
| + | |||
| + | cd / | ||
| + | |||
| + | sudo cp -r apache2 / | ||
| + | sudo cp -r www /var/www | ||
| + | sudo cp -r letsencrypt / | ||
| + | |||
| + | sudo chown -R www-data: | ||
| + | |||
| + | ################################################################################ | ||
| + | # Restore Configs - letsencrypt | ||
| + | # Also see: | ||
| + | # | ||
| + | # | ||
| + | ################################################################################ | ||
| + | |||
| + | # View dir | ||
| + | cd / | ||
| + | # Migrate backup | ||
| + | cp -r / | ||
| + | |||
| + | ################################################################################ | ||
| + | # Find apache2 log directories | ||
| + | ################################################################################ | ||
| + | # List all | ||
| + | find / | ||
| + | find / | ||
| + | find / | ||
| + | |||
| + | # Get path names | ||
| + | find / | ||
| + | |||
| + | ################################################################################ | ||
| + | # Create missing | ||
| + | ################################################################################ | ||
| + | sudo mkdir -p / | ||
| + | |||
| + | sudo chown -R root:adm / | ||
| + | |||
| + | sudo ls -lh / | ||
| + | ################################################################################ | ||
| + | # Make DNS Changes | ||
| + | ################################################################################ | ||
| + | # Enable sistes | ||
| + | ################################################################################ | ||
| + | # Get site names (without SSL version) | ||
| + | find / | ||
| + | |||
| + | # Enable | ||
| + | sudo a2ensite david-halliday.co.uk.conf | ||
| + | |||
| + | # Disable | ||
| + | sudo a2dissite david-halliday.co.uk.conf | ||
| + | |||
| + | # Restart Apache | ||
| + | sudo systemctl reload apache2 | ||
| + | |||
| + | ################################################################################ | ||
| + | # Refresh certificates (letsencrypt) | ||
| + | ################################################################################ | ||
| + | sudo certbot --apache | ||
| + | |||
| </ | </ | ||