In this tutorial, you will learn install WordPress on Amazon Elastic Compute Cloud (EC2). First of all, you need to sign up for Amazon Web Services (AWS) here, therefore you can start using Amazon EC2 immediately.
In order to install applications on your EC2 instance, you will need to remotely access to your EC2 instance with SSH.
$ ssh -i "web-server.pem" ubuntu@xx.xx.xxx.xxx The authenticity of host 'xx.xx.xxx.xxx (xx.xx.xxx.xxx)' can't be established. ECDSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'xx.xx.xxx.xxx' (ECDSA) to the list of known hosts. Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-48-generic x86_64) ... ubuntu@ip-xxx-xx-xx-xxx:~$
$ sudo apt-get update $ sudo apt-get install apache2
By default, your instance could be access using only SSH (port: 22). You need to configure security group of your EC2 instance.
$ sudo apt-get install mysql-server php5-mysql
$ sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
$ sudo nano /etc/apache2/mods-enabled/dir.conf
It will look like this:
<IfModule mod_dir.c> DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm </IfModule>
We want to move the PHP index file highlighted above to the first position after the DirectoryIndex specification, like this:
<IfModule mod_dir.c> DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm </IfModule>
$ sudo service apache2 restart
$ sudo nano /var/www/html/info.php
This will open a blank file. We want to put the following text, which is valid PHP code, inside the file:
<?php phpinfo(); ?>
Running the following commands:
$ mysql -u root -p $ CREATE DATABASE wordpress; $ CREATE USER wordpressuser@localhost IDENTIFIED BY 'password'; $ GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost; $ exit
$ cd ~ $ wget http://wordpress.org/latest.tar.gz $ tar xzvf latest.tar.gz
$ sudo apt-get update $ sudo apt-get install php5-gd libssh2-php
This will allow you to work with images and will also allow you to install plugins and update portions of your site using your SSH login credentials.
$ cd ~/wordpress $ cp wp-config-sample.php wp-config.php $ nano wp-config.php
Edit wp-config.php as follow:
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'wordpress'); /** MySQL database username */ define('DB_USER', 'wordpressuser'); /** MySQL database password */ define('DB_PASSWORD', 'password');
$ sudo rsync -avP ~/wordpress/ /var/www/html/ $ cd /var/www/html $ sudo chown -R www-data:www-data *
$ sudo mkdir /var/www/html/wp-content/uploads $ sudo chown -R www-data:www-data /var/www/html/wp-content/uploads