Amazon EC2 Setup with Ubuntu and XAMPP Installation
Wall Script
Wall Script
Tuesday, December 08, 2015

Amazon EC2 Setup with Ubuntu and XAMPP Installation

Very long time back I had published an article about Amazon Cloud installation, nowadays Amazon Web Services is offering 12 months free trial for micro instance with 700 MB RAM. Now they simplified a few interface setting for the installation process, this post will explain to you how to set up an Amazon micro instance with Ubuntu operating system and XAMPP server. Try this for your first web project.

Amazon EC2 Setup with Ubuntu and XAMPP Installation

Getting started with Amazon Web Services EC2(Elastic Compute Cloud)
Very first you have to create an account on with a valid credit card and then activate micro free tie. Click here to access Amazon console dashboard.

Video Tutorial

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

Step 2
Click Launch Instance button.
Launch instance

Step 3
Now choose operating system for your web server, I suggest use Ubuntu for more package advantages. Make sure, that should be listed in free tier.
Select Amazon Operating System

Step 4
You find the following screen, now click Launch button.
Amazon Ubuntu OS

Step 5
Here you can modify your server type, but initially explore things with free tier.
Select Amazon Free tier

Creating Amazon Key File - Authentication
Most important part in this installation process.

Step 6
Here choose Create a new pair key
Create key .pem file

Step 7
Give valid name and click to Download Key Pair. You will get an .pem file.
Download key pair .pem

Step 8
Instance has been created successfully.
instance created successfully

Firewall Security Settings

Step 9
You will find the instance status here.
Running Instance

Step 10
Select the instance box and scroll down the page, you will find inbound rules for firewall security
Instance Amazon Inbound rules

Step 11
Add HTTP rule for web server access.
Add HTTP Rule

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
Launch instance

Step 13
Amazon will provide you a random IP address.
Launch instance

Step 14
Now associate IP address with instance box.
Launch instance

Step 15
Choose instance box here.
Launch instance

Step 16
Click Associate address.
Launch instance

Step 17
Associated IP address with instance.
Launch instance

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
You have to download Putty and PuttyGen softwares. Click this Amazon Windows Connectivity link, follow steps under Windows connect using Putty

ubuntu@ip-172-31-19-204:~$ sudo su

This will update Ubuntu OS Packages
sudo apt-get update

Stop Default Apache
sudo /etc/inid.d/apache stop

XAMPP Installation Commands for Ubuntu

Download XAMPP for 64 bit

Make Execute Installation
sudo chmod +x

Run Installation
sudo ./

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

sudo /opt/lampp/lampp start

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

XAMPP Configurations
Edit XAMPP configurations.
vi /opt/lampp/etc/extra/httpd-xampp.conf

Replace following line Require all granted
<Directory "/opt/lampp/phpmyadmin">
    AllowOverride AuthConfig Limit
    Require all granted
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var

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.

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

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

You can also convert the key using putty for MAC or Linux
sudo port install putty
This will also install puttygen. To get puttygen to output a .PEM file:
puttygen keyname.ppk -O private-openssh -o keyname.pem

File Uploads
Download here and install into your PC. Click this Amazon FileZilla Connectivity link, follow steps under FileZilla - File Uploads

Copy your project folder from /home/ubuntu/ directory to XAMPP htdocs folder.
sudo cp  -R WebProjectFolder /opt/lampp/htdocs/

SSL Certificate
Find more information about Custom SSL Certificate Installation for Amazon EC2 serve. If you want to activate free SSL certificate for your website

Domain Redirection using .htaccess
Create a .htaccess file and copy into /opt/lampp/htdocs/ directory.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^
RewriteRule (.*)$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$
RewriteCond %{REQUEST_URI} !^/WebProjectFolder/
RewriteRule (.*) /WebProjectFolder/$1

Now access your domain
web notification


  1. Thanks a lot for this great tutorial. It is very useful.

  2. Though am not into it now but someday sometime will find it useful..Big thanks

  3. Thank you sir for sharing this article. This is very good article. Actually sir you write very well. So please sir write more article like this for us.

    Thank you.
    Balram Paul.

  4. Thanks. Will give it a try. Cheers!!!

  5. Good tutorial, I am not upload .htaccess in opt/lampp/htdocs/.htaccess in ftp, error
    cannot create remote file 'opt/lampp/htdocs/.htaccess'. So that i can redirect to my domain. Please write us.

  6. Actually the free tier program offers instance of 1GB RAM.. You might wanna correct it in the intro.

  7. Your posts are always nice. The above post is worth reading. Thanks for sharing.

  8. Hi , i did what you said , and now amazon is charging me 25 $ for linux running on demand , and my website is not public yet , is that normal ?!

  9. Thanks a lot. very help ful.
    is it possible to install cpanel for manage all files, database

  10. by using this amazon EC2 my XAMPP local server will turn in to Live server right?

  11. Thanks for great help. i ma facing issue, after this commoand "sudo ./" its not working. i was expecting to see XAMPP instructions but terminal gos idle for long. nothing happens further.

    Am i missing anything?

  12. hi, I am unable to access phpmyadmin as it says Access forbidden. I have done everything in this article. please guide

  13. An easier way to setup Amazon EC2 instance and host an application on is using a managed hosting platform, like Cloudways. If you are using this platform you won't have to use command line.

  14. I installed 7.0.13 and there httpd-xampp.conf looks different :/

    After changing this file to be able to access it from my browser, i was shocked that there is no password set. I tried to set it by using the phpmyadmin but there i kindof broke the whole thing. After a fresh xampp installation I only granted access for my IP at home. If there was a small note that says "we are going to set a password for the phpmyadmin later" i would have been less worried ^^

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

      AllowOverride AuthConfig Limit
      Require all granted
      ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var

  15. Hi,
    That was a wonderful article. I need your help here to clarify some doubts.
    1. If I am using phpmyadmin, then do I need Amazon database services.
    2. Is it necessary to have Amazon S3 storage to save my code for EC2
    3. Whenever I make a change to a code file and update it by uploading via FileZilla, do I have to pay data In or Out charges for AWS.

    1. 1. If I am using phpmyadmin, then do I need Amazon database services.

      No, you can use localhost database

      2. Is it necessary to have Amazon S3 storage to save my code for EC2

      Amazon S3 for uploading your website media files like images, video and docs etc.

      3. Whenever I make a change to a code file and update it by uploading via FileZilla, do I have to pay data In or Out charges for AWS.


  16. Great article mat thank you very much

  17. after one year how to deactive aws account

    1. Terminate your instance and remove your payment CARD details

  18. hi ,

    am crated crated instance and everything , but it will take so much of loading time .
    how can resolve ?

  19. hi ,
    I need to article for dockers . please help me

  20. Dear Sir,
    I am short of money and can't afford expensive hosting at this moment. However, I had an idea which I thought might work. Your walkthrough has helped me immensely in testing out my concept for the first year. Please accept my heartfelt gratitude. Thanks

  21. Very Thanks Dear......Salute to You...!

    Can you please guide How to connect php with mysql to retrive or insert data in phpmyadmin mysql Database after complete above sptep given by you

  22. Hello Srinivas
    Can you please share a latest video or tutorial for creating cPanel on AWS and how to connect the my godaddy domain to AWS for my wordpress website?

    Thank you in advance

  23. Please tell me how to install ssl here.

    1. Check this link

  24. i am new to aws.i am using jsp with mysql. how to deploy jsp with mysql in aws. first i install the xampp webserver for the above document. while changing the xampp configuration (location match) the error will occur.plz reply as soon as possible

  25. Hi Srinivas,

    Even after changing the httpd-xampp.conf phpmyadmin is not accessible. Can you help me with that.

  26. Thank you a lot for this great article.

    But Is it safe to use LAMP stack in production server?

  27. Hello,

    Thank you very much for your detailed tutorial in Youtube ( . It helped me to create my first AWS Free Tier with in few minutes. Now I have few doubts as listed below :

    Is it possible to use one Instance to run multiple website hostings ? As per your tutorial, we can map one domain name from Godaddy to this one instance's xampp htdocs folder, but what if I have another domain in godaddy ? Should I create more instance per domain names ( websites ) ?

    1. Use the same instance IP for all the Godaddy website and redirect using .htaccess

  28. > XAMPP Configurations
    > Edit XAMPP configurations.
    In this section, though I set as your guide, I could not connect to phpMyAdmin because Access forbidden

  29. how to configure for multiple domain

  30. my site is working properly thanks.
    i want to ask you a question i want to add (wordpress) blog in ec2 along with this abc project what should i do because wordpress in not working

  31. I have followed the steps, but noticed MariaDB is installed on EC2.
    Though I could login Phpmyadmin through XAMPP dashboard with no password associated with 'root' user.
    I have changed the default password by executing below command -
    /opt/lampp/bin/mysqladmin --user=root password "my-passwd"
    ... Then, simply I have lost phpmyadmin access to installed DB.
    I have tried tweaking with -
    But, still it isnt working.
    I have as well edited security group enabling access to 3306 port.
    So, what I will try next is creating separate RDS MySql instance & try connecting Mysql from my WAMP phpmyadmin.
    Do you have any blog available, which could let me connect my windows based phpmyadmin remotely connect to MySql DB ?

  32. Thanks for the tutorial.. It helped me a lot.. Can I get how to upload existing localhost project to this instance?? Plz plz

  33. Hi, i have created the .htaccess and placed inside the htdocs folder and restarted xampp but still is showing dashboard page only not redirecting to my sub folder. Please help me

  34. sir i really had a big problem in this can you please help me out?
    the httpd-xampp.config file when im trying to change its like you cannot override the file.
    im hanging with this problem from seven days..can you help me with this for 5 minutes please....

  35. hi how to setup ssl wtih this lamp?
    amazon ec2 ubuntu

  36. Hi, Sometimes my site stops working with Error 503, I am using m5 instance with Classic loadbalancer

    Is it because my instance needs to be updated or do I need to take my database from phpmyadmin to somewhere else?


mailxengine Youtueb channel
Make in India