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.
Getting started with Amazon Web Services EC2(Elastic Compute Cloud)
Very first you have to create an account on Amazon.com 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.
Step 2
Click Launch Instance button.
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.
Step 4
You find the following screen, now click Launch button.
Step 5
Here you can modify your server type, but initially explore things with free tier.
Creating Amazon Key File - Authentication
Most important part in this installation process. Step 6
Here choose Create a new pair key
Step 7
Give valid name and click to Download Key Pair. You will get an .pem file.
Step 8
Instance has been created successfully.
Firewall Security Settings
Step 9
You will find the instance status here.
Step 10
Select the instance box and scroll down the page, you will find inbound rules for firewall security
Step 11
Add HTTP rule for web server access.
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
Step 13
Amazon will provide you a random IP address.
Step 14
Now associate IP address with instance box.
Step 15
Choose instance box here.
Step 16
Click Associate address.
Step 17
Associated IP address with 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).
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
root@ip-172-31-19-204:/home/ubuntu#
root@ip-172-31-19-204:/home/ubuntu#
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
wget https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/8.2.4/xampp-linux-x64-8.2.4-0-installer.run
Make Execute Installation
sudo chmod +x xampp-linux-x64-8.2.4-0-installer.run
Run Installation
sudo ./xampp-linux-x64-8.2.4-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
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.
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
</Directory>
AllowOverride AuthConfig Limit
Require all granted
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
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.
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-AddressYou 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} ^yourdomain.com
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$
RewriteCond %{REQUEST_URI} !^/WebProjectFolder/
RewriteRule (.*) /WebProjectFolder/$1
RewriteCond %{HTTP_HOST} ^yourdomain.com
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$
RewriteCond %{REQUEST_URI} !^/WebProjectFolder/
RewriteRule (.*) /WebProjectFolder/$1
Now access your domain http://YourDomain.com/
Thanks a lot for this great tutorial. It is very useful.
ReplyDeleteThough am not into it now but someday sometime will find it useful..Big thanks
ReplyDeleteThank 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.
ReplyDeleteThank you.
Balram Paul.
Thanks. Will give it a try. Cheers!!!
ReplyDeleteGood tutorial, I am not upload .htaccess in opt/lampp/htdocs/.htaccess in ftp, error
ReplyDeletecannot create remote file 'opt/lampp/htdocs/.htaccess'. So that i can redirect to my domain. Please write us.
Actually the free tier program offers instance of 1GB RAM.. You might wanna correct it in the intro.
ReplyDeleteYour posts are always nice. The above post is worth reading. Thanks for sharing.
ReplyDeleteHi , 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 ?!
ReplyDeleteTry to use Micro instance.
DeleteI am planning to use for demo only. Will they charge?
DeleteThanks a lot. very help ful.
ReplyDeleteis it possible to install cpanel for manage all files, database
by using this amazon EC2 my XAMPP local server will turn in to Live server right?
ReplyDeleteThanks for great help. i ma facing issue, after this commoand "sudo ./xampp-linux-x64-1.8.3-5-installer.run" its not working. i was expecting to see XAMPP instructions but terminal gos idle for long. nothing happens further.
ReplyDeleteAm i missing anything?
hi, I am unable to access phpmyadmin as it says Access forbidden. I have done everything in this article. please guide
ReplyDeleteAn 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.
ReplyDeleteI installed 7.0.13 and there httpd-xampp.conf looks different :/
ReplyDeleteAfter 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 ^^
vi /opt/lampp/etc/extra/httpd-xampp.conf
DeleteAllowOverride AuthConfig Limit
Require all granted
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
thanks
DeleteHi,
ReplyDeleteThat 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. If I am using phpmyadmin, then do I need Amazon database services.
DeleteNo, 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.
No
Great article mat thank you very much
ReplyDeleteafter one year how to deactive aws account
ReplyDeleteTerminate your instance and remove your payment CARD details
Deletehi ,
ReplyDeleteam crated crated instance and everything , but it will take so much of loading time .
how can resolve ?
hi ,
ReplyDeleteI need to article for dockers . please help me
Dear Sir,
ReplyDeleteI 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
Thank you
DeleteVery Thanks Dear......Salute to You...!
ReplyDeleteCan 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
Hello Srinivas
ReplyDeleteCan 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
Ravi
Please tell me how to install ssl here.
ReplyDeleteCheck this link https://www.9lessons.info/2012/07/ssl-certificate-installation.html
Deletei 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
ReplyDeleteHi Srinivas,
ReplyDeleteEven after changing the httpd-xampp.conf phpmyadmin is not accessible. Can you help me with that.
Thank you a lot for this great article.
ReplyDeleteBut Is it safe to use LAMP stack in production server?
Hello,
ReplyDeleteThank you very much for your detailed tutorial in Youtube (https://www.youtube.com/watch?v=h04jIAIcBhg) . 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 ) ?
Use the same instance IP for all the Godaddy website and redirect using .htaccess
Deletehttps://www.9lessons.info/2011/12/amazon-ec2-multi-domain-setup-and.html
https://www.9lessons.info/2011/12/amazon-ec2-multi-domain-setup-and.html
Delete> XAMPP Configurations
ReplyDelete> Edit XAMPP configurations.
In this section, though I set as your guide, I could not connect to phpMyAdmin because Access forbidden
https://imgur.com/9GRRFuk
Check the tutorial https://www.9lessons.info/2016/12/install-xampp-70-on-ubuntu-and-mac-osx.html
Deletehttps://www.9lessons.info/2016/12/install-xampp-70-on-ubuntu-and-mac-osx.html
Deletehow to configure for multiple domain
ReplyDeletemy site is working properly thanks.
ReplyDeletei 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
I have followed the steps, but noticed MariaDB is installed on EC2.
ReplyDeleteThough 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 -
/opt/lampp/phpmyadmin/config.inc.php
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 ?
Thanks for the tutorial.. It helped me a lot.. Can I get how to upload existing localhost project to this instance?? Plz plz
ReplyDeleteHi, 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
ReplyDeletesir i really had a big problem in this can you please help me out?
ReplyDeletethe 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....
hi how to setup ssl wtih this lamp?
ReplyDeleteamazon ec2 ubuntu
Hi, Sometimes my site stops working with Error 503, I am using m5 instance with Classic loadbalancer
ReplyDeleteIs it because my instance needs to be updated or do I need to take my database from phpmyadmin to somewhere else?