Amazon EC2 Setup with Ubuntu and XAMPP Installation
Tags: php, mysql, aws, amazonec2
Published: 2019-11-16 07:19:12

---
title: Amazon EC2 Setup with Ubuntu and XAMPP Installation
published: True
description: Host PHP + MySQL website on aws
tags: PHP, MYSQL, AWS, Amazon EC2
---

Step 1
First of all, login our Aws account. Aws log in ( link )

Step 2
After Amazon console login you find the following screen, select EC2 from Compute category.

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573122065230_image.png)


Step 3 
Click Launch Instance button.

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573122150616_image.png)


Step 4 

Now choose operating system for web server. I suggest use Ubuntu for more package advantage. Make sure, that should be listed in free tier. 

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573122285356_image.png)


Step 5 

After select button. you will click for review and instance

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573122398947_image.png)


Step 6 

After clicking Review and Launch You find the below screen, now click Launch button.

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573122510726_image.png)


Step 7

In this step. you see this screen. Select “create a new key pair” 

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573122611647_image.png)

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573122668820_image.png)


a. Set key pair name. What ever you want 
b. Give valid name and click to Download Key Pair. You will get an .pem file.





Step 8 

Now Instance has been created successfully.

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573122812474_image.png)


Step 9 

Firewall Security Settings 

     You will find the instance status here.
    
![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573122887552_image.png)


Step 10

Select the instance box and scroll down the page, you will find inbound rules for firewall security

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573122962361_image.png)


Step 11

Add HTTP rule for web server access.

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573122991719_image.png)


Elastic IP - Create Static IP Address

Basically, Amazon instance will provide you a dynamic public DNS name, this is not stable. So you need a static IP.

Step 12

Go to Network & Security category and select Elastic IPs, click Allocate New Address

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573123036701_image.png)


Step 13

Amazon will provide you a random IP address.

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573123062080_image.png)


Step 14

Now associate IP address with instance box.

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573123085635_image.png)


Step 15

Choose instance box here.

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573123117414_image.png)


Step 16

Click Associate address.

![Launch instance](https://lh3.googleusercontent.com/-mNrEJ00A4bI/VmZMHx8rObI/AAAAAAAANP0/Qer57U7j1VA/s550-Ic42/Associate_ip_instance.png)


Step 17

Associated IP address with instance.

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573123161748_image.png)



Linux & MAC connection


Executing following command with Linux or MAC terminal, you can directly access your box.

    ssh -i keyname.pem ubuntu@IP_ADDRESS

Sometimes you will get following error.


    Permissions 0640 for 'keyname.pem' are too open.
    It is required that your private key files are NOT accessible by others.
    This private key will be ignored.
    Load key "keyname.pem": bad permissions
    Permission denied (publickey).

Give only READ permission for .pem file, then execute SSH command again.

    sudo chmod 400 keyname.pem


Windows connection

Run following command


    ubuntu@ip-172-31-19-204:~$ sudo su
    root@ip-172-31-19-204:/home/ubuntu#

This will update Ubuntu OS Packages


    sudo apt-get update


XAMPP Installation Commands for Ubuntu

Download XAMPP for 64 bit

    wget https://www.apachefriends.org/xampp-files/7.0.23/xampp-linux-x64-7.0.23-0-installer.run

Make Execute Installation

    sudo chmod +x xampp-linux-x64-7.0.23-0-installer.run

Run Installation

    sudo ./xampp-linux-x64-7.0.23-0-installer.run



XAMPP instructions


    Select the components you want to install; clear the components you do not want to install. Click Next when you are ready to continue.
    XAMPP Core Files : Y (Cannot be edited)
    XAMPP Developer Files [Y/n] : Y
    Is the selection above correct? [Y/n]: Y


    Installation Directory
    XAMPP will be installed to /opt/lampp
    Press [Enter] to continue:
    Do you want to continue? [Y/n]:Y

Run XAMPP

    sudo /opt/lampp/lampp start

XAMPP Access Forbidden
Open your browser and access http://IP-ADDRESS/ you will find this Access forbidden screen.

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573123525799_image.png)

XAMPP Configurations

Edit XAMPP configurations.

    vi /opt/lampp/etc/extra/httpd-xampp.conf

In this image there are default value is local you have to set “ all granted ”

![](https://paper-attachments.dropbox.com/s_132101326B419C26F49673FEC4C8CAE7FFA4E0D888CBBD1284FE12420C7F97AD_1573123625063_image.png)


Restart XAMPP


    sudo /opt/lampp/lampp restart


Security Settings

sudo /opt/lampp/xampp security


    XAMPP: Your XAMPP pages are NOT secured by a password.
    XAMPP: Do you want to set a password? [yes]
    XAMPP: Your XAMPP pages are NOT secured by a password.
    XAMPP: Do you want to set a password? [yes] no
    XAMPP: MySQL is accessable via network.
    XAMPP: Normaly that's not recommended. Do you want me to turn it off? [yes] yes
    XAMPP: Turned off.
    XAMPP: Stopping MySQL...ok.
    XAMPP: Starting MySQL...ok.
    XAMPP: The MySQL/phpMyAdmin user pma has no password set!!!
    XAMPP: Do you want to set a password? [yes] yes
    XAMPP: Password:*******
    XAMPP: Password (again):*******
    XAMPP: Setting new MySQL pma password.
    XAMPP: Setting phpMyAdmin's pma password to the new one.
    XAMPP: MySQL has no root passwort set!!!
    XAMPP: Do you want to set a password? [yes] yes
    XAMPP: Write the password somewhere down to make sure you won't forget it!!!
    XAMPP: Password:*******
    XAMPP: Password (again):*******
    XAMPP: Setting new MySQL root password.
    XAMPP: Change phpMyAdmin's authentication method.
    XAMPP: The FTP password for user 'daemon' is still set to 'xampp'.
    XAMPP: Do you want to change the password? [yes] no
    XAMPP: Done.


PhpMyAdmin

Access PhyMyAdmin at http://IP-Address/phpmyadmin/

Domain Settings
If you own a domain address, go to domain DNS(Domain name settings). Add host value @ points to IP-Address

![Launch instance](https://lh3.googleusercontent.com/-yFNhTNd0eXc/VmZZ8bN19PI/AAAAAAAANQs/Bkzb-Cay6Ys/s550-Ic42/godaddy.png)



----------
                                    Thanks for Reading