Last active
May 18, 2021 04:51
-
-
Save Chizaram-Igolo/ad74f5fba57ebd25040c75b8511cb9ea to your computer and use it in GitHub Desktop.
Script for Setting Up WordPress on EC2 Ubuntu Instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Update the server | |
sudo apt-get update -y | |
# Install Apache | |
sudo apt-get install apache2 -y | |
# Install MySQL Server | |
sudo apt-get install mysql-server -y | |
# Change root password for database | |
sudo mysql -e "SET PASSWORD FOR root@localhost = PASSWORD($1);FLUSH PRIVILEGES;" | |
sudo mysql -e "DELETE FROM mysql.user WHERE User='';" | |
sudo mysql -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');" | |
sudo mysql -e "DROP DATABASE IF EXISTS test; DELETE FROM mysql.db WHERE Db='test' OR Db='test_%';" | |
sudo mysql -u root -p$1 -e "CREATE USER 'ubuntu'@'localhost' IDENTIFIED BY $1; GRANT ALL PRIVELEGES ON *.* TO 'ubuntu'@'localhost';FLUSH PRIVILEGES;" | |
sudo mysql -e "CREATE DATABASE db;" | |
# Install PHP and PHP Libraries | |
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql | |
# Start Apache server | |
sudo service apache2 restart | |
# Download and unzip WordPress | |
cd /var/www/html | |
sudo wget https://wordpress.org/latest.tar.gz | |
sudo tar -xzf latest.tar.gz | |
rm latest.tar.gz | |
cd wordpress | |
cp wp-config-sample.php wp-config.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment