WordPress on Amazon Web Services (AWS) Linux EC2 Micro Instance, For Free

I’ve been wanting to get a write up done for WordPress on AWS, the fact that it is free for a year, since they’ve released the free-tier many months ago. Well I finally got around to it, however it isn’t a write up. I went ahead and put the work in to produce a video of the steps for setup & configuration. Enjoy.

The commands to install php, mysql, httpd (apache), and manipulate the config files are included below for copy and paste needs.

Create a Linux Instance on AWS – create & assign an IP Address

Login with ‘ec2-user’

sudo -i
lsof -i

yum -y install httpd

service httpd start

yum -y install php mysql
yum install mysql-server

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
yum install phpmyadmin

vi /etc/httpd/conf.d/phpmyadmin.conf

Hit insert hey to make changes to the conf file.

————————————————————————————
# Web application to manage MySQL

# Order Deny,Allow
# Deny from all
Allow from all

Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin
————————————————————————————

service httpd restart
service mysqld start
/usr/bin/mysqladmin -u root password ‘somepassword’
vi /etc/httpd/conf.d/phpmyadmin.conf
vi /usr/share/phpmyadmin/config.inc.php

————————————————————————————
[…] /* Authentication type */
$cfg[‘Servers’][$i][‘auth_type’] = ‘http’;
[…]
————————————————————————————

Watch the video for the WordPress Database creation in mysql w/ phpmyadmin.

wget http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz -C /var/www/html/
cp -avr /var/www/html/wordpress/* /var/www/html/
rm -rf /var/www/html/wordpress/

cd /etc/httpd/conf
vi httpd.conf
Find the user here… it should be ‘apache’

cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
vi /var/www/html/wp-config.php

…Add the database settings.

chown -R apache /var/www/html
chmod -R 755 /var/www/html

49 thoughts on “WordPress on Amazon Web Services (AWS) Linux EC2 Micro Instance, For Free

  1. Pingback: DotNetShoutout
  2. Dear Mr. Hall,

    I have tried repeatedly to follow these instructions and set this up but the 2 times I did it I received the same answer. I was wondering if I might be able to chat with you some time? I can send you the notes & questions ahead of time.

    Thanks,

    Scott M. Shepard

  3. I found that I needed to include php-mysql in the yum -y install line

    1. Yup, very true. You guys have a very easy setup too. Much easier than manually setting it up as I’ve shown in the video. However, for those that are hard core and want to manage it themselves. 😉

      I’ve actually pointed a number of people toward your AMIs. 🙂 Cheers!

  4. “Watch the video for the WordPress Database creation in mysql w/ phpmyadmin”

    Could you type this out please? I can’t watch the video at work and it’s extremely graining on my personal computer (I’m not able to get a decent connection where I’m at geographically).
    It would be very helpful. So far, your directions have been great.

    1. I would if I had the time… hit up the website for mysql and phpmyadmin. There are steps on those sites that are written out. Cheers! 🙂

      1. I’m 100% now – used your post and a couple of others to cover gaps. Great work and thanks for posting!

  5. I’m stuck here vi /etc/httpd/conf.d/phpmyadmin.conf What commands did you use to exit the session i saw something like “ix” and then “clear” after modifying (allow from all) and etc, i can’t exit from here. Thanks.

  6. Ctrl Colon and then x clear. I tried it but it doesn’t work. We need some help from the expert. Can you explain it. I will link you to all my sites if you help me with this.

  7. Dumb question #2: when I go to http://x.x.x.x/phpmyadmin and it prompts me for the username and password I’m getting stuck. I see in the video that you’re using root as the username, but when was the password set? I don’t recall setting a password for phpmyadmin. I tried the password that I set for mysql previous in the instructions, but that didn’t work. Thanks.

    1. NM. Nuked my instance and started over. This time it worked with the mysql pword. PFM. Feel free to delete my last comment if you want. Thanks.

  8. My AWS WordPress install went well. But it is not sending registration confirmation emails. All else works well. Help, please?

  9. Hey great post and lessons, thank you! I dont know what im doing wrong: i came to: /usr/bin/mysqladmin -u root password ‘somepassword’, but then I get answer:

    /usr/bin/mysqladmin: connect to server at ‘localhost’ failed
    error: ‘Access denied for user ‘root’@’localhost’ (using password: NO)’

    Can you help me please?

  10. On your 1’s & 0’s with this one here! Nicely detailed install and I like how you cleaned the repositories and you went along. That showed “maintenance….MAAAAN!”

  11. Hi, thanks for the great tutorial, it helped me get PHP and MySQL running on an EC2 real quick!

    There’s a minor “bug” though that seems to be bothering many users – if you copy-paste the commands, then you end up with erroneus mysql root password. The reason is that your WordPress has replaced ‘ (ascii apostrophe) with some unicode counterpart.

    For example if you copy and paste the following command and replace only the somepassword part (but not the quotes), then the password will not be somepassword but ‘somepassword’ (including the unicode apostrophes).

    /usr/bin/mysqladmin -u root password ‘somepassword’

    You need to skip the quotes if the password is one word, or replace them with ascii apostrophes or quotes.

  12. Followed your instructions to the tee.
    Everything worked as far as installing apache and mysql is concerned, as you see below.
    However, when I got to my ec2 instance in the browser, it get site not found.
    Not sure what to check for to get around this issue?

    COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
    dhclient 986 root 5u IPv4 1899 0t0 UDP *:bootpc
    sshd 1167 root 3u IPv4 4173 0t0 TCP *:ssh (LISTEN)
    sshd 1167 root 4u IPv6 4175 0t0 TCP *:ssh (LISTEN)
    ntpd 1187 ntp 16u IPv4 4257 0t0 UDP *:ntp
    ntpd 1187 ntp 17u IPv6 4258 0t0 UDP *:ntp
    ntpd 1187 ntp 18u IPv4 4260 0t0 UDP localhost:ntp
    ntpd 1187 ntp 19u IPv4 4261 0t0 UDP domU-12-31-39-0A-2C-4B.compute-1.internal:ntp
    ntpd 1187 ntp 20u IPv6 4262 0t0 UDP localhost:ntp
    ntpd 1187 ntp 21u IPv6 4263 0t0 UDP [fe80::1031:39ff:fe0a:2c4b]:ntp
    sendmail 1202 root 4u IPv4 4334 0t0 TCP localhost:smtp (LISTEN)
    sshd 1284 root 3r IPv4 4646 0t0 TCP domU-12-31-39-0A-2C-4B.compute-1.internal:ssh->CPE00222d1e0129-CM00222d1e0125.cpe.net.cable.rogers.com:62807 (ESTABLISHED)
    sshd 1288 ec2-user 3u IPv4 4646 0t0 TCP domU-12-31-39-0A-2C-4B.compute-1.internal:ssh->CPE00222d1e0129-CM00222d1e0125.cpe.net.cable.rogers.com:62807 (ESTABLISHED)
    httpd 1508 root 4u IPv6 7564 0t0 TCP *:http (LISTEN)
    httpd 1510 apache 4u IPv6 7564 0t0 TCP *:http (LISTEN)
    httpd 1511 apache 4u IPv6 7564 0t0 TCP *:http (LISTEN)
    httpd 1512 apache 4u IPv6 7564 0t0 TCP *:http (LISTEN)
    httpd 1513 apache 4u IPv6 7564 0t0 TCP *:http (LISTEN)
    httpd 1514 apache 4u IPv6 7564 0t0 TCP *:http (LISTEN)
    httpd 1515 apache 4u IPv6 7564 0t0 TCP *:http (LISTEN)
    httpd 1516 apache 4u IPv6 7564 0t0 TCP *:http (LISTEN)
    httpd 1517 apache 4u IPv6 7564 0t0 TCP *:http (LISTEN)
    mysqld 1695 mysql 10u IPv4 7840 0t0 TCP *:mysql (LISTEN)

    1. NM .. i had not added http rule to my security group, which fixed the issue.
      Did the rest of the setup and all went smoothly.
      The file permissions changes are tricky, but your video has all the steps correct.

      Thanks again, this was my first time with ec2 and glad how easy it has been!!

  13. Hi. Thanks for these instructions.

    I have set it all up.

    Now how do I view the website in the browser? I mean do I have to enter the VirtualHost etc in httpd.conf by myself? Where do I connect the “public dns” to a website domain name?

    Thanks so much!

    1. You’ll have to contact your registrar, or whoever it is that has your DNS to get things repointed with an ‘a record’ or cname.

      1. Sorry if I was not clear. To me, coming from the dedicated server world, the WHM/Cpanel system is quite clear. The same dedicated server has “BIND” (named) running, which handles the DNS.

        I am trying to replicate basically a dedicated hosting server on the Ec2. So I would like BIND running on the same server, and therefore A records and CNAME running from there too.

        Is this NOT how you are setting up EC2?

  14. Hi Adron,
    This is very nice tutorial. I am new to EC2 and I have no knowledge of Php and mysql. I followed your instructions and I was able to complete the set up through this past weekend. However, upon returning on Monday to set up the DB, I could no longer connect using my Elastic IP. It says “Connection timed out.” Even though I cleared my cache, the message was the same.
    I can I resolve this issue? Should I restart the whole process? Thanks for your input.

      1. Hi Adron,
        I was able to log back in and to restart the server. However, I don’t understand how you went from
        [root@ip-10.170.78.111 ~] sudo -i
        [root@ip-10.170.78.111 ~]#

        to this line :
        [root@ip-10.170.78.111 html] chown -R apache /var/www/html

        Thanks!

  15. Hello Sir,
    I watched your video tutorial, I’ve been following it but when I run WordPress it show error “can not connect to Database”, please help me

      1. Hi Sohappy;
        I have this same problem but what are the steps to set the crontab to restart every 1 minute when “Error can not connect to Database”.

      2. Hi Sohappy,
        I also have the same problem, but what are the steps to follow to set the crontab to restart every 1 minute.

  16. Hello Adron,

    Thanks for the wonderful tutorial you put up. I followed every step and was successful all the way but got stocked at the very end to access my wordpress installation through my new elastic IP. I can access the MySQL server through phpmyadmin with my new IP but to finish the installation through “http://184.xx.xxx.60/wp-admin/install.php”, I get the “Error can not connect to Database”. I edit the wp-config.php file giving the “db-name”, “db-user” and “db-password” (I used same password for “db-name” and “db-user”).

    I don’t know what kind of changes to make again or what went wrong. I have reviewed the process again and again but can’t get through with this, please I need your help with any suggestions.

    Thank once more.

    plotos.

    1. Hello Adron;

      I finally resolved this problem by running the mysql secure installation as this will be a production environment. I used the following command:

      /usr/bin/mysql_secure_installation

      – then gave the password I created for mysql (note: on typing the password, it does not appear on the screen)
      – say no to change the root password …….’n’
      – then remove the default user …….’y’
      – disallow root login remotely …….’y’
      – remove the test database and access to it …….’y’
      – reload privilege tables now …….’y’

      and that did the magic, I could now connect to the Database.

      Thanks very much Adron for the wonderful tutorial.

      plotos.

  17. Hi Sohappy,

    Yes I had everything correct, as I mentioned above on my next post “I finally resolved the problem by running the mysql secure installation”. This brought everything to perfect order.

    Thanks for the reply.

    amigosplotos.

  18. I followed each step listed. Still when i launched my website with public DNS. wp-admin is working fine. but when i click any of the link of wordpress site it gives error Not Found. I am unable to figure out the reason. can you please tell me on this? I tried it by changing public DNS to ip address of my domain too but still same error.

  19. Hii,

    I followed every step listed. When i login admin panel using Public DNS every thing is fine. But when i open wodpress website and clicks on any of the link it gives “Not Found” error. I treid it by ip address also but same error. Can you please guide me why i am facing this issue. because of the apache owner? i am not sure. can you please tell me what can cause it?

  20. I think your instructions are great. However at some point I did something wrong. I get error establishing data base.

    At this point in your instructions – /usr/bin/mysqladmin -u root password ‘somepassword’ I put in my own password. When I went to check my config.php I didn’t know what my user name was or database name.

    Please help!

    Bob

  21. I hardly leave a response, but i did a few searching
    and wound up here WordPress on Amazon Web Services (AWS) Linux EC2 Micro Instance, For Free – Composite Code.
    And I actually do have a couple of questions for you if it’s allright.
    Is it only me or does it look like a few of these responses appear
    like coming from brain dead visitors? 😛 And, if you are writing on additional sites,
    I would like to follow everything fresh you have to post.
    Could you list of all of your social pages like your twitter feed, Facebook page or linkedin profile?

Comments are closed.