SlideShare uma empresa Scribd logo
1 de 18
PHP, MYSQL, APACHE, PHPMYADMIN on AWS EC2
Setting up AWS EC2 Instance:-
Signup for amazon AWS ec2 account. You can start with free tier account. Free tier account
permits usage of 750 hours per month for free if you do not select any paid option.
Login to ec2 console https://console.aws.amazon.com/ec2. Goto launch instance. You will get a
list of machine images to choose from, you can select any from the free tier eligible depending
onto your need. But lets go ahead with first image amazon ami 64 bit.
Next step is to choose instance type. We can go with first one as it is free tier eligible.
Click Next configure instance details.
You can choose number of instances network settings etc. Do not edit anything unless you are
familiar with these configurations. Just one thing to note here, check the check box protect
against accidental termination. This is useful to prevent data loss.
Click add storage to choose volume to store data. You can configure size and type according to
your requirements. Max 30 gb is permitted for free tier usage. You can add multiple volumes to
your instance.
Next step is to tag instance through a key - value pair. For ease of use put key as Name and
value as Webserver.
Next step is to configure security group. Here you can set rules for ssh, tcp and other protocols.
You can set permissions for ip ranges. You can create your own or can go with default security
group. if after setting everything your site is not running on browser then check if http protocol is
allowed here or not.
Now Click on review and launch. It will open a popup for volume type. Choose any that suits
your needs or you can go ahead with default selected one. Click Next and the launch.
It will now ask for creating keys or choosing existing keys. Go with choosing new keys if you are
setting first instance. Create the key and download it. This is just one time key save it else you
may need to create new instance. This is in pem format public key.
Now we may need to set elastic IP because public dns will change once you terminate or reboot
your instance. Don;t create more than one elastic ip for now and as soon as you create
associate it with instance. You won’t be charged if you associate it with instance else you will
get charged.
Thanks it is done now. Now you can go ahead with connecting it through ssh or ftp and
installing php, mysql, apache envrionments.
Connecting to AWS through SSH/FTP:-
Open the puttygen load the pem file downloaded from aws while creating keys. Load the key
and and save private key.
To connect through ftp. oepn filezilla click edit then settings under edit. Now click sftp and add
ppk key. It may ask you for conversion do the conversion.
Click ok then add hostname as public dns/publicip/elastic ip, username as ec2-user port as 22.
Click connect you will be connected. Now go to /var/www/html to view files.
To connect to server open putty click session on left. Type in hostname, incase of aws it will be
public dns or public ip or the elastic ip associated with the instance. Put some name to identify
the connection under saved session and save it.
Now click on SSH is left and then click Auth under SSH. Browse the ppk file you have
generated through puttygen from pem file. Then click session on and save it again.
Then click open to connect to the instance. Login with ec2-user
Once you press enter, you will get logged in successfully.
If you get any error like connection time out or other. Login to your amazon aws on browser.
Select your instance and on go to security group. Now edit inbound connection to check if TCP
is open for your ip address or not. Incase if TCP or ssh not on make them available for your ip.
Installations:-
● Inorder to install php, mysql, phpmyadmin and apache, login as root.
○ [root@localhost ~]# sudo su -
● To Install PHP and Apache
○ [root@localhost ~]# sudo yum install php-mysql php php-xml php-mcrypt
php-mbstring php-cli mysql httpd
● To start apache automatically while booting
○ [root@localhost ~]# chkconfig --levels 235 httpd on
● Open the file /etc/httpd/conf/httpd.conf
Find “#ServerName www.example.com:80″ (line no : 276 ) .
and add this line below . “ServerName youripaddress:80″
#
#ServerName www.example.com:80
ServerName 192.168.141.22:80
● Now restart apache service
○ [root@localhost ~]# service httpd restart
● Now you have successfully configured apache web server . open your browser and type
the ip address in the address bar and hit enter . you can see the test page of your web
server .
● To install Mysql server
○ [root@localhost ~]# sudo yum install mysql-server
○ [root@localhost ~]# sudo /etc/init.d/mysqld start
● To start apache automatically while booting
○ [root@localhost ~]# chkconfig --levels 235 mysqld on
● To secure mysql using username and password
○ [root@localhost ~]# mysqladmin -u root password '[PASSWORD]'
where PASSWORD is the password you want to choose, don’t include square
brackets. Simply use like example below:-
[root@localhost ~]# mysqladmin -u root password ‘root@123’
● To install phpmyadmin
○ [root@localhost ~]# sudo yum install phpmyadmin
○ Might be you will get no package find message. This means you may need to
add repository to install phpmyadmin. Choose the repository according to OS you
have.
CentOS/RHEL 6:
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
CentOS/RHEL 5:
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
Fedora 20:
# rpm -Uvh http://rpms.famillecollet.com/remi-release-20.rpm
Fedora 19:
# rpm -Uvh http://rpms.famillecollet.com/remi-release-19.rpm
Fedora 18:
# rpm -Uvh http://rpms.famillecollet.com/remi-release-18.rpm
○ Enable the repository through
[root@localhost ~]# yum --enablerepo=remi install phpMyAdmin
○ phpMyAdmin by default allowed to access from localhost only. If you want to
make it accessible from remote computers edit
/etc/httpd/conf.d/phpMyAdmin.conf and update all 127.0.0.1 with your network
like below or enable phpMyAdmin access for everyone.
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
## Comment below section to allow everyone
<Directory /usr/share/phpMyAdmin/>
<IfModule !mod_authz_core.c>
Order Deny,Allow
Deny from All
Allow from 192.168.1.0/24
Allow from ::1
</IfModule>
</Directory>
<Directory /usr/share/phpMyAdmin/libraries/>
Order Deny,Allow
Deny from All
Allow from None
</Directory>
<Directory /usr/share/phpMyAdmin/setup/lib/>
Order Deny,Allow
Deny from All
Allow from None
</Directory>
<Directory /usr/share/phpMyAdmin/setup/frames/>
Order Deny,Allow
Deny from All
Allow from None
</Directory>
● Could not connect: Can’t connect to local MySQL server through socket
‘/var/lib/mysql/mysql.sock’ (2)
This means your mysql server service is stopped , you must start the service
[root@localhost ~]# service mysqld start
● Inorder for your domain to point the aws ec2 hosting you can use elastic ip address and
add this address as A record into DNS Zone file on domain registrar. The other way will
be through route 53 service. Fow now lets go ahead with elastic ip as A record.
● Connect to amazon ec2 through putty. sudo as root through sudo su - .
Open up /etc/hosts file down to localhost entry you can create new entry as
○ 54.78.90.21 xyz.com
where 54.78.90.21 is the elastic ip address and domain name is xyz.com
● Now open /etc/httpd/conf/httpd.conf file here we will be adding up virtual host to serve
domain xyz.com. We can put multiple virtual host entries inorder to host multiple
websites.
Uncomment NameVirtualHost *:80, Uncomment <VirtualHost *:80> and further lines till
</VirtualHost>
Add your domain name in front of ServerName , Change path of DocumentRoot to
/var/www/html/yourdomainname.com/
Save the file and run service httpd restart
Upload your files to /var/www/html/yourdomainname.com
Its done now. You can now run your website on browser.
● How to do using route 53. Activate route 53 service through aws console. Open the
Amazon Route 53 console at https://console.aws.amazon.com/route53/. In the Route 53:
Hosted Zones window, click Create Hosted Zone.
In the Domain Name box, type your custom domain name.
● Click the Create Hosted Zone button at the bottom of the pane.
● When the hosted zone is successfully created, in the list of domain names, select the
check box that corresponds to your domain name. In the details pane, under Delegation
Set, Amazon Route 53 displays the set of name servers that have been allocated for
your domain. You can use this nameservers to put on domain registrar’s DNS zone file.
Now inorder for connecting the DNS Hosting Route 53 to Files hosting EC2. We may need to
configure A record entry on Route 53 with the elastic ip of EC2.
● Go to Record sets, click create record set. Under Create Record Set, do the following:
○ In the Name box, accept the default. The root domain is already entered for you.
○ In the Type box, select A — IPv4 address to create an A record for your domain.
○ Choose aliasing as No and enter your elastic ip address as target.
○ In the Routing Policy box, select Simple.
○ Leave Evaluate Target Health set to No.
○ DNS propogataion may take from 2 hrs to 48 hrs. After DNS propogation there
may be case where your site may not work on www. So inorder to make it run on
www. Use the same process and create new record set as A record. The only
difference is put www into the name box and you are done.
Thanks:-
Thankyou all for reading this with patience. I expect by reading this you may be able
setup your own server and hosting environments. Excuse me for typo mistakes if any.
Though I have tried to cover almost every aspect but might be the case you may face
some issues while doing this. Don’t worry feel free to drop me any queries on
prasoon.sharma1983@gmail.com

Mais conteúdo relacionado

Destaque

RailsAdmin - Overview and Best practices
RailsAdmin - Overview and Best practicesRailsAdmin - Overview and Best practices
RailsAdmin - Overview and Best practicesBenoit Bénézech
 
How To Create RDS Database for WordPress in AWS on RHEL 7 or CentOS 7
How To Create RDS Database for WordPress in AWS on RHEL 7 or CentOS 7How To Create RDS Database for WordPress in AWS on RHEL 7 or CentOS 7
How To Create RDS Database for WordPress in AWS on RHEL 7 or CentOS 7VCP Muthukrishna
 
Formulario HTML-PHP dirigido a una Base de datos
Formulario HTML-PHP dirigido a una Base de datosFormulario HTML-PHP dirigido a una Base de datos
Formulario HTML-PHP dirigido a una Base de datosCursando Desarrollo Web
 
RIP Alan Rickman.
 RIP Alan Rickman. RIP Alan Rickman.
RIP Alan Rickman.Makala D.
 
Getting Started with Amazon EC2 and AWS Compute Services
Getting Started with Amazon EC2 and AWS Compute ServicesGetting Started with Amazon EC2 and AWS Compute Services
Getting Started with Amazon EC2 and AWS Compute ServicesAmazon Web Services
 
How I learned to stop worrying and love the cloud
How I learned to stop worrying and love the cloudHow I learned to stop worrying and love the cloud
How I learned to stop worrying and love the cloudShlomo Swidler
 
Cuaderno de-ejercicios-y-practicas-php
Cuaderno de-ejercicios-y-practicas-phpCuaderno de-ejercicios-y-practicas-php
Cuaderno de-ejercicios-y-practicas-phplgcj1989
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP TutorialLorna Mitchell
 
Unit Testng with PHP Unit - A Step by Step Training
Unit Testng with PHP Unit - A Step by Step TrainingUnit Testng with PHP Unit - A Step by Step Training
Unit Testng with PHP Unit - A Step by Step TrainingRam Awadh Prasad, PMP
 
On-demand Transport Technology Companies around the World - Top 30 Players
On-demand Transport Technology Companies around the World - Top 30 PlayersOn-demand Transport Technology Companies around the World - Top 30 Players
On-demand Transport Technology Companies around the World - Top 30 PlayersValoriser Consultants
 
TEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of WorkTEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of WorkVolker Hirsch
 

Destaque (12)

RailsAdmin - Overview and Best practices
RailsAdmin - Overview and Best practicesRailsAdmin - Overview and Best practices
RailsAdmin - Overview and Best practices
 
Tema4[php]
Tema4[php]Tema4[php]
Tema4[php]
 
How To Create RDS Database for WordPress in AWS on RHEL 7 or CentOS 7
How To Create RDS Database for WordPress in AWS on RHEL 7 or CentOS 7How To Create RDS Database for WordPress in AWS on RHEL 7 or CentOS 7
How To Create RDS Database for WordPress in AWS on RHEL 7 or CentOS 7
 
Formulario HTML-PHP dirigido a una Base de datos
Formulario HTML-PHP dirigido a una Base de datosFormulario HTML-PHP dirigido a una Base de datos
Formulario HTML-PHP dirigido a una Base de datos
 
RIP Alan Rickman.
 RIP Alan Rickman. RIP Alan Rickman.
RIP Alan Rickman.
 
Getting Started with Amazon EC2 and AWS Compute Services
Getting Started with Amazon EC2 and AWS Compute ServicesGetting Started with Amazon EC2 and AWS Compute Services
Getting Started with Amazon EC2 and AWS Compute Services
 
How I learned to stop worrying and love the cloud
How I learned to stop worrying and love the cloudHow I learned to stop worrying and love the cloud
How I learned to stop worrying and love the cloud
 
Cuaderno de-ejercicios-y-practicas-php
Cuaderno de-ejercicios-y-practicas-phpCuaderno de-ejercicios-y-practicas-php
Cuaderno de-ejercicios-y-practicas-php
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP Tutorial
 
Unit Testng with PHP Unit - A Step by Step Training
Unit Testng with PHP Unit - A Step by Step TrainingUnit Testng with PHP Unit - A Step by Step Training
Unit Testng with PHP Unit - A Step by Step Training
 
On-demand Transport Technology Companies around the World - Top 30 Players
On-demand Transport Technology Companies around the World - Top 30 PlayersOn-demand Transport Technology Companies around the World - Top 30 Players
On-demand Transport Technology Companies around the World - Top 30 Players
 
TEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of WorkTEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of Work
 

Último

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Último (20)

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

SET UP PHP, MYSQL, PHPMYADMIN, APACHE ON AMAZON AWS EC2

  • 1. PHP, MYSQL, APACHE, PHPMYADMIN on AWS EC2 Setting up AWS EC2 Instance:- Signup for amazon AWS ec2 account. You can start with free tier account. Free tier account permits usage of 750 hours per month for free if you do not select any paid option. Login to ec2 console https://console.aws.amazon.com/ec2. Goto launch instance. You will get a list of machine images to choose from, you can select any from the free tier eligible depending onto your need. But lets go ahead with first image amazon ami 64 bit. Next step is to choose instance type. We can go with first one as it is free tier eligible.
  • 2. Click Next configure instance details. You can choose number of instances network settings etc. Do not edit anything unless you are familiar with these configurations. Just one thing to note here, check the check box protect against accidental termination. This is useful to prevent data loss. Click add storage to choose volume to store data. You can configure size and type according to your requirements. Max 30 gb is permitted for free tier usage. You can add multiple volumes to your instance.
  • 3. Next step is to tag instance through a key - value pair. For ease of use put key as Name and value as Webserver. Next step is to configure security group. Here you can set rules for ssh, tcp and other protocols. You can set permissions for ip ranges. You can create your own or can go with default security group. if after setting everything your site is not running on browser then check if http protocol is allowed here or not.
  • 4. Now Click on review and launch. It will open a popup for volume type. Choose any that suits your needs or you can go ahead with default selected one. Click Next and the launch.
  • 5. It will now ask for creating keys or choosing existing keys. Go with choosing new keys if you are setting first instance. Create the key and download it. This is just one time key save it else you may need to create new instance. This is in pem format public key. Now we may need to set elastic IP because public dns will change once you terminate or reboot your instance. Don;t create more than one elastic ip for now and as soon as you create associate it with instance. You won’t be charged if you associate it with instance else you will get charged. Thanks it is done now. Now you can go ahead with connecting it through ssh or ftp and installing php, mysql, apache envrionments. Connecting to AWS through SSH/FTP:-
  • 6. Open the puttygen load the pem file downloaded from aws while creating keys. Load the key and and save private key. To connect through ftp. oepn filezilla click edit then settings under edit. Now click sftp and add ppk key. It may ask you for conversion do the conversion.
  • 7. Click ok then add hostname as public dns/publicip/elastic ip, username as ec2-user port as 22. Click connect you will be connected. Now go to /var/www/html to view files. To connect to server open putty click session on left. Type in hostname, incase of aws it will be public dns or public ip or the elastic ip associated with the instance. Put some name to identify the connection under saved session and save it.
  • 8. Now click on SSH is left and then click Auth under SSH. Browse the ppk file you have generated through puttygen from pem file. Then click session on and save it again.
  • 9. Then click open to connect to the instance. Login with ec2-user Once you press enter, you will get logged in successfully.
  • 10. If you get any error like connection time out or other. Login to your amazon aws on browser. Select your instance and on go to security group. Now edit inbound connection to check if TCP is open for your ip address or not. Incase if TCP or ssh not on make them available for your ip. Installations:-
  • 11. ● Inorder to install php, mysql, phpmyadmin and apache, login as root. ○ [root@localhost ~]# sudo su - ● To Install PHP and Apache ○ [root@localhost ~]# sudo yum install php-mysql php php-xml php-mcrypt php-mbstring php-cli mysql httpd ● To start apache automatically while booting ○ [root@localhost ~]# chkconfig --levels 235 httpd on ● Open the file /etc/httpd/conf/httpd.conf Find “#ServerName www.example.com:80″ (line no : 276 ) . and add this line below . “ServerName youripaddress:80″ # #ServerName www.example.com:80 ServerName 192.168.141.22:80 ● Now restart apache service ○ [root@localhost ~]# service httpd restart ● Now you have successfully configured apache web server . open your browser and type the ip address in the address bar and hit enter . you can see the test page of your web server .
  • 12. ● To install Mysql server ○ [root@localhost ~]# sudo yum install mysql-server ○ [root@localhost ~]# sudo /etc/init.d/mysqld start ● To start apache automatically while booting ○ [root@localhost ~]# chkconfig --levels 235 mysqld on ● To secure mysql using username and password ○ [root@localhost ~]# mysqladmin -u root password '[PASSWORD]' where PASSWORD is the password you want to choose, don’t include square brackets. Simply use like example below:- [root@localhost ~]# mysqladmin -u root password ‘root@123’ ● To install phpmyadmin ○ [root@localhost ~]# sudo yum install phpmyadmin
  • 13. ○ Might be you will get no package find message. This means you may need to add repository to install phpmyadmin. Choose the repository according to OS you have. CentOS/RHEL 6: # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm CentOS/RHEL 5: # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm Fedora 20: # rpm -Uvh http://rpms.famillecollet.com/remi-release-20.rpm Fedora 19: # rpm -Uvh http://rpms.famillecollet.com/remi-release-19.rpm Fedora 18: # rpm -Uvh http://rpms.famillecollet.com/remi-release-18.rpm ○ Enable the repository through [root@localhost ~]# yum --enablerepo=remi install phpMyAdmin ○ phpMyAdmin by default allowed to access from localhost only. If you want to make it accessible from remote computers edit /etc/httpd/conf.d/phpMyAdmin.conf and update all 127.0.0.1 with your network like below or enable phpMyAdmin access for everyone. Alias /phpMyAdmin /usr/share/phpMyAdmin Alias /phpmyadmin /usr/share/phpMyAdmin ## Comment below section to allow everyone <Directory /usr/share/phpMyAdmin/> <IfModule !mod_authz_core.c> Order Deny,Allow Deny from All Allow from 192.168.1.0/24 Allow from ::1
  • 14. </IfModule> </Directory> <Directory /usr/share/phpMyAdmin/libraries/> Order Deny,Allow Deny from All Allow from None </Directory> <Directory /usr/share/phpMyAdmin/setup/lib/> Order Deny,Allow Deny from All Allow from None </Directory> <Directory /usr/share/phpMyAdmin/setup/frames/> Order Deny,Allow Deny from All Allow from None </Directory> ● Could not connect: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2) This means your mysql server service is stopped , you must start the service [root@localhost ~]# service mysqld start ● Inorder for your domain to point the aws ec2 hosting you can use elastic ip address and add this address as A record into DNS Zone file on domain registrar. The other way will be through route 53 service. Fow now lets go ahead with elastic ip as A record. ● Connect to amazon ec2 through putty. sudo as root through sudo su - . Open up /etc/hosts file down to localhost entry you can create new entry as ○ 54.78.90.21 xyz.com where 54.78.90.21 is the elastic ip address and domain name is xyz.com
  • 15. ● Now open /etc/httpd/conf/httpd.conf file here we will be adding up virtual host to serve domain xyz.com. We can put multiple virtual host entries inorder to host multiple websites. Uncomment NameVirtualHost *:80, Uncomment <VirtualHost *:80> and further lines till </VirtualHost> Add your domain name in front of ServerName , Change path of DocumentRoot to /var/www/html/yourdomainname.com/ Save the file and run service httpd restart
  • 16. Upload your files to /var/www/html/yourdomainname.com Its done now. You can now run your website on browser. ● How to do using route 53. Activate route 53 service through aws console. Open the Amazon Route 53 console at https://console.aws.amazon.com/route53/. In the Route 53: Hosted Zones window, click Create Hosted Zone. In the Domain Name box, type your custom domain name. ● Click the Create Hosted Zone button at the bottom of the pane. ● When the hosted zone is successfully created, in the list of domain names, select the check box that corresponds to your domain name. In the details pane, under Delegation Set, Amazon Route 53 displays the set of name servers that have been allocated for your domain. You can use this nameservers to put on domain registrar’s DNS zone file.
  • 17. Now inorder for connecting the DNS Hosting Route 53 to Files hosting EC2. We may need to configure A record entry on Route 53 with the elastic ip of EC2. ● Go to Record sets, click create record set. Under Create Record Set, do the following: ○ In the Name box, accept the default. The root domain is already entered for you. ○ In the Type box, select A — IPv4 address to create an A record for your domain. ○ Choose aliasing as No and enter your elastic ip address as target. ○ In the Routing Policy box, select Simple. ○ Leave Evaluate Target Health set to No. ○ DNS propogataion may take from 2 hrs to 48 hrs. After DNS propogation there may be case where your site may not work on www. So inorder to make it run on www. Use the same process and create new record set as A record. The only difference is put www into the name box and you are done.
  • 18. Thanks:- Thankyou all for reading this with patience. I expect by reading this you may be able setup your own server and hosting environments. Excuse me for typo mistakes if any. Though I have tried to cover almost every aspect but might be the case you may face some issues while doing this. Don’t worry feel free to drop me any queries on prasoon.sharma1983@gmail.com