Skip to content

Install Wordpress in EC2

Adrian Quintana edited this page Jun 22, 2017 · 3 revisions

Install the dependencies:

$ yum install httpd mysql-server php php-mysql
$ service httpd start
$ service mysql start

Make sure the services are started on boot:

$ sudo chkconfig mysqld on
$ sudo chkconfig httpd on
$ sudo chkconfig --list | grep "mysqld\|httpd"

Create and secure the database:

$ mysqladmin -uroot create blog
$ mysql_secure_installation
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

Install wordpress:

$ cd /var/www/html
$ sudo wget http://wordpress.org/latest.tar.gz
$ sudo tar -xzvf latest.tar.gz
$ sudo mv wordpress blog
$ cd blog
$ sudo mv wp-config-sample.php wp-config.php
$ sudo chown -R apache:apache /var/www/html/blog/

Edit /var/www/html/blog/wp-config.php with the credentials:

define('DB_NAME', 'blog');
define('DB_USER', 'root');
define('DB_PASSWORD', 'PASSWORD');
define('DB_HOST', 'localhost');

Reload apache ( $ sudo service httpd reload) and the blog should be now accesible at http://ec2-host/blog.

If you want to configure permalink in your blog, you will need to go to /etc/httpd/conf then open http.conf by running sudo vi httpd.conf and then change "AllowOverride" to:

<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

You may also need to change AllowOverride All here:

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride All

Then you need to change the configuration on wordpress (Settings > Permalink) and restart httpd and it is done.