Assuming that you have Launched an Instance, and Downloaded the Key Pair file i.e. your .pem file before connecting to it.
If you have not launched then you can do it by following this link – LAUNCHING AN INSTANCE
Connecting to your instance using SSH
- Open the Terminal application. You can also use the shortcut Ctrl+Alt+T
- Install the Amazon EC2 CLI tools : If you have already installed it then its okay otherwise use the following command
sudo apt-get install awscli
- Use the chmod command to make sure that your private key pair file isn’t publicly viewable.
chmod 400 /path/your_key_name.pem
where path is the directory in which your private key file i.e. PEM file is located.
- Use the ssh command to connect to the instance. You’ll specify the private key (
.pem) file and user_name@public_dns_name. For Amazon Linux, the user name is
ec2-user. The user name is either
ec2-user. For Ubuntu, the user name is
ubuntu. Otherwise, if
rootdon’t work, check with your AMI provider.
ssh -i /path/your_key_name.pem firstname.lastname@example.org
- Enter yes
Now, you are connected to your instance and all you need to configure your instance which will install apache on your instance.
To Configure your Instance using Terminal
- You will need to get the Access Keys i.e. your Access Key ID and Secret Access Key. If you don’t have it then you can get that by going to your Security Credentials
You will be redirected to the following page where it will ask to Create a New Access Key. Create a new Key and Download it.
- Now to configure, you need to enter the following command on your Terminal application provided you should be connected to your instance
- Then it will be asking you for the configuration variables which you have downloaded just above. Enter those variables to configure
- You have now successfully configured your instance now you just need to install the lamp-server on your instance by writing the following command on your terminal while connected to the instance
sudo apt-get install lamp-server^
- Then, it will ask for a new password enter it and you are done. Now just copy your instance’s Public DNS Name and paste in a new tab of your browser and you will see this apache page