Skip to main content

Install WordPress on AWS Ubuntu EC2 Instance

Step By Step Installing WordPress on EC2 Ubuntu Server

Creating a EC2 instance

Note down the IPv4 Public IP

Make sure to add Auth Key to insure successful session

Click Yes and provide user name. In my case it is ‘ubuntu’ which is default by AWS. Once we are logged in, our first task to update apt source so that we can have updated packages and module.

sudo apt update

As WordPress is a web based application so our next tast is to install Apache Web Server. Install apache via below command.

apt-get install apache2 –y

Once installed you can verity it via typing hostname or IP on the web browser. It should get you Apache2 Ubuntu Default Page

However WordPress needs other mandatory component as PHP, MySQL so combo of all these service environment is known as LAMP (Linux, Apache, MySQL, PHP). We can install all these component one by one like Apache or directly via typing below command.

apt-get install lamp-server^

Now it’s time to download latest version of WordPress. Let’s go to temp folder and download the zip installer.

cd /tmp

wget https://wordpress.org/latest.tar.gz

Let’s unzip the installer for further install.

sudo tar xvfz latest.tar.gz

After this you should be able to see WordPress folder. You can verify via running ‘ls’ command. Now it’s time to move installation files and components to Document Root folder. By default installer folder for Apache Web Server is /var/www/html.

cd /tmp/wordpress

cp –a * /var/www/html

To check the permission and ownership we can use ls –ll command. www-data should have ownership of the html folder in order to work. If not we can update the ownership via below command.

chown -R www-data:www-data /var/www/html

Now it’s time create a Database for WordPress so that installer can make a connection to the database. It’s a mandate for WordPress installation. Login into MySQL via below command.

mysql –u root –p

As you are first time login into MySQL, it will ask for to configure a new password for root user. Make sure to provide an strong password here. Once you logged in you will get mysql>prompt. Now let’s check databases. Below command will show you all the available databases.

show databases;

To create a new Database

create database wordpress;

To create a new user for DB

create user 'abhay'@'localhost' identified by 'admin@123';

Assign permission to user

GRANT ALL PRIVILEGES ON * . * TO 'abhay'@'localhost';

flush privileges;

quit

We are all set for the databases prerequisite prospective. Now navigate to Root Directory folder (cd /var/www/html)and copy wp-config-sample.php to wp-config.php.

cp wp-config-sample.php wp-config.php

update the file by changing

/** The name of the database for WordPress */

define( 'DB_NAME', 'wordpress' );

 /** MySQL database username */

define( 'DB_USER', 'abhay' );

 /** MySQL database password */

define( 'DB_PASSWORD', 'admin@123' );

 add below parameter at the end

define("FS_METHOD", "direct");


Navigate to sites-available. Verify the vim  000-default.conf. Document root path should be /var/www/html/. If not change it to /var/www/html/.

cd /etc/apache2/sites-available/

Now navigate to Sites-enabled to check how many enabled sites are there. If single default one is there ensure that is loaded by below command.

cd /etc/apache2/sites-enabled/

a2ensite 000-default.conf

It should show Site 000-default already enabled. Now restart the Apache service. And we are good to go to final installation of WordPress.

service apache2 restart

Try to browse using IP



We are all set now! We will also needed to install below modules in order to run smoothly with WordPress plugins.

apt-get install php-xml libapache2-mod-php php-curl

Many Thanks!

 Home

 

 

 


Comments