Saturday, February 14, 2015

Script for setting up Wordpress on an AWS machine

I found the documentation a bit of a headache to run through. This is a quick way to get a wordpress server up and running on Amazon Web Services.

DBPASSWORD="yourdbpassword"
DBSERVERPASSWORD="yourdbserverpassword"

sudo apt-get -y update
sudo apt-get -y upgrade

sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password yourdbserverpassword'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password yourdbserverpassword'
sudo apt-get -y install mysql-server

sudo apt-get -y install apache2 php5 php5-mysql mercurial

sudo service mysql start
mysql -u root -p
yourdbserverpassword
CREATE USER 'wordpress-user'@'localhost' IDENTIFIED BY 'yourdbpassword';
CREATE DATABASE `wordpress-db`;
GRANT ALL PRIVILEGES ON `wordpress-db`.* TO "wordpress-user"@"localhost";
FLUSH PRIVILEGES;
exit

cd ~
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz

cd wordpress/
cp wp-config-sample.php wp-config.php
sed -i 's/database_name_here/wordpress-db/g' wp-config.php
sed -i 's/username_here/wordpress-user/g' wp-config.php
sed -i 's/password_here/yourdbpassword/g' wp-config.php

curl https://api.wordpress.org/secret-key/1.1/salt/ >> wp-config.php

sudo rm /var/www/html/index.html
sudo mv * /var/www/html/
sudo chown -R www-data:www-data /var/www/html