aws wordpress

Steps to setup WordPress site on EC2 instance in 2-3 minutes

Now host your own website on AWS + WordPress – Absolutely Free!

Step 1 – Launch an EC2 (Amazon Linux or Centos/RHEL flavor) instance with PublicIP/ElasticIP address.
Step 2 – Connect to the above instance.
Step 3 – Install Apache (httpd)
Step 4 – Install PHP
Step 5 – Install MySQL Database
Step 6 – Install WordPress
Step 7 – DNS mapping (Optional Step)

Step 1 – Launch an EC2 (Amazon Linux or Centos/Rhel flavor) instance with PublicIP/ElasticIP address:
– Launching an EC2 instance.
– Associating ElasticIP with the above instance.

Step 2 – Connect to the above instance:
– You may follow this aws documentation to connect to your EC2 instance (t2.micro should be good in case you want it all free).

Step 3 – Install Apache web server (httpd) application:
– To install the Apache Web Server, type sudo yum install httpd -y
– Start the Apache Web Server by typing sudo service httpd start
– To test your Web Server, open a browser and access your web site: (Use your actual public DNS name). You should see a standard Amazon place holder page.

Step 4 – Install PHP and restart httpd
sudo yum install php php-mysql -y
sudo service httpd restart
– Create a page to test your PHP installation:
cd /var/www/html
sudo vi test.php
Type i to start the insert mode
Type <?php phpinfo() ?>
Type :wq! to write the file and quit vi
– Open a browser and access test.php to test your PHP installation: (Use your actual public DNS name).

Step 5 – Install MySQL Database
– Switch to root by typing sudo su (We will run rest of the commands by root)
– Get the repository by typing rpm -Uvh
– Installation – sudo yum install mysql-server -y
– Start MySQL – sudo service mysqld start
– Create your DB (Replace your_db_name with any name) – mysqladmin -uroot create your_db_name
– Secure your database: mysql_secure_installation
– Answer the wizard questions as follows:
Enter current password for root: Press return for none
Change Root Password: Y
New Password: Enter your new password
Remove anonymous user: Y
Disallow root login remotely: Y
Remove test database and access to it: Y
Reload privilege tables now: Y

Step 6 – Install WordPress
– To install WordPress, type the following commands which will uncompress WordPress in its own “wordpress” directory:
cd /var/www/html
tar -xzvf latest.tar.gz
– Move the contents of the wordpress directory in the current (/var/www/html) directory:
mv wordpress/* .
– Create the WordPress wp-config.php file:
mv wp-config-sample.php wp-config.php
– Configure wp-config.php file so that WordPress can talk to the database:
vi wp-config.php
Type i to start insert mode.
– Modify the database connection parameters as follows:
define(‘DB_NAME’, ‘your_db_name’);
define(‘DB_USER’, ‘root’);
define(‘DB_PASSWORD’, ‘your_db_password’);
define(‘DB_HOST’, ‘localhost’);
Type :wq! to write the file and quit vi
– Open a Browser and access your blog: (Use your actual public DNS name). This should trigger the WordPress configuration process.

Step 7 – DNS mapping (Optional Step)
– To map your domain name to your IP address, you will have to use the tools provided by your domain registrar. If you use GoDaddy, follow this documentation and use the DNS Manager to modify the A record and point to your IP address.

  • Once everything is configured and mapped correctly, access the General Settings in the WordPress management console and make sure the WordPress Address and Site Address are specified correctly using your domain name.

Thanks for your time! Hope you enjoyed following!

2 thoughts on “Steps to setup WordPress site on EC2 instance in 2-3 minutes”

  1. I’m not sure why but this site is loading incredibly slow for me.
    Is anyone else having this problem or is it a issue on my
    end? I’ll check back later and see if the problem still exists.

  2. Hi Lorenzo, sorry for the inconvenience. Could be some issue with the CDN. Are you still facing slowness?

Leave a Reply

Your email address will not be published. Required fields are marked *

seventeen − 9 =