How to setup a wordpress website on AWS EC2 within few minutes

Image
"Learn, Learn and Learn"

Here we are going to discuss how can we setup our own WordPress website in our amazon EC2 within few minutes. There are several platforms which gives you the option to pay for their services and have a WordPress site. Then you can build whatever you need to do. But today we will discuss how to build our own server, install WordPress and setup the rest.

What is the benefits of choosing AWS to setup WordPress ?

Because you don't need to pay for services which other platforms provides. In AWS, you are the owner of your server and you are the person who install and setup your installation. So no monthly charges for anonymous companies . Only pay is for as you go. From this article we will learn how to setup our own WordPress site. In AWS also there are options to use pre-installed WordPress and make our site.  But here we will discuss how to do it without using pre-installations.

Follow the steps as below. 

1) First we need to create a AWS EC2 instance.…

NFS Server and Client Installation with Configurations.

"Start everyday with a smile and start it over with."


What is NFS ( Network File System ) ?

This is a distributed file system protocol which is basically shares files/folders in between Linux servers. Keep it in mind, this is sharing in between only with Linux systems, not with Windows. Through NFS, we can allow a system to share it's folders and files with other Linux servers ( Linux clients ) over the network.
NFS is operating in a client-server environment and NFS server is deciding the files and folders which should be shared and nfs server is configured with whom these files are shared.

From this article we will discuss how to configure NFS server side and client side architecture briefly with the commands.

1) How to set up NFS server 


here, i have created two EC2 instances in AWS. First instance is for NFS client and the second one is NFS server.  So, Let's log into the NFS server.


I have attached a separate disk for the NFS share ( Partition is /dev/xvdb1 ) and mounted to the directory named /nfs-share.  So now we are going to make this location as an shared location.

Change the ownership and file permissions as below.

chown nobody:nogroup /nfs-share
chmod 777 /nfs-share


Before everything, we will get the latest update for all applications from ubuntu repositories.

sudo apt-get update

Above command will update your all applications with the latest updates.



Then, Follow the steps as below.

Installing NFS Kernel server in my system.

sudo apt-get install nfs-kernel-server -y






* We can see at the end of the package installation, it creates a path named "/etc/exports". That is the place where we mention our files and folders which want to be shared with the selected client machines.

According to our scenario, we are going to share /nfs-share folder as i mentioned in the above.
Simply what we have to do is, just mention the folder which we have to share inside of our server and the client machine who needs to access our shared folder over the network.

We have to edit /etc/exports file.


Inside of the exports file we have to mention our shared location ( /nfs-share folder in our server ) and the client IP ( 172.31.19.131 which is our client server ip ) with some of options as below.

syntax :

<shared location>  <client IP> ( options )

rw - Allow both read and write requests on the nfs shared volume. We can make it as "ro" if it needs Read Only.

sync - Write the changes to the disk before replying.

no_subtree_check - This  disables subtree checking. This has a middle security implications, but can improve reliability in some circumstances.

If we want to add multiple client servers to get the same shared folder, just add the next server ip and the options having a space.

eg - /nfs-share1 172.31.19.131(options) 172.31.19.132(options) 172.31.19.133(options)
/nfs-share3 172.31.19.134(options)

So, after editing /etc/exports file, save it and close.


exportfs -a command exports all shared folders and later we need to restart nfs-kernel-server service in the nfs-server.




Now we have configured NFS server side completely.

Accidently my two servers got corrupted. so i re created two servers from aws console with two different ips. Now i created my nfs share named as "myshare" in nfs server.

To verify if your exports have been successfully exported, we can use the below command.

showmount -e




2) How to set up NFS client. 

Get the client server and give a apt-get update to update all the applications to the latest from the repository.

Before doing anything, we can see the mounts as below in the client machine.


What we are expecting to do is, mounting the folder which we exported in nfs server inside of this nfs client.

Follow the below steps.

Install nfs-common client in your  machine.



command - apt-get install nfs-common -y

Create a mount point for the nfs shared folder. Then only we can access the shared content in nfs server from our nfs client machine.

I created the folder named as "myshare" inside of the client machine. So the path is /mnt/myshare.




Now we are going to mount our nfs share from nfs server to our client machine. After that the files/folders in nfs server share can be accessed from our client machine ( from path /mnt/myshare ).


Firstly we will try to mount temporally.


syntax :

mount -t nfs <nfs-server-ip>:<nfs-share-folder-path> <client-server-mountpath>




In order to make the mount persistent with the boots, we need to update file /etc/fstab as below.




Now you can try creating new files inside of the /mnt/myshare path, editing files and removing file from the client machine. So everything can be seen when you check from the server side too. Everything is synced in between the nfs server and nfs client.

Important ( This has to be considered only if you are using AWS EC2 instances ) -

When you are trying to mount the nfs-share in your client machine, i mean when you try to run the mount -t nfs command, you have to enable nfs from the AWS security groups. Without enabling nfs, you can't mount the nfs share. Because nfs is blocked by default from the security group.

To enable nfs from security group

Go to security groups under EC2 dashboard

Edit the Inbound rules

Add nfs as a inbound rule. Select the source as Anywhere.

Save the changes.



Cheers!





Comments

Popular posts from this blog

Why i can't ping to my AWS EC2 Instances ?

Different types of users in linux