Web Hosting on Amazon AWS PHP MySQL

+1 vote

I am totally confused on how to host a Dynamic website created using PHP and MySQL in Amazon Cloud.

I went through Amazon S3 and I hosted a static website there!

Then I tried Amazon EC2 and I learned some aspects about the concept of VPC. I thought that the dynamic websites are hosting in Amazon Cloud using EC2. I followed some steps and they taught me how to launch a website using Drupal (But, I didn't want that !! )

No other tutorials on EC2 to deploy my web application was not found.

Then I found AWS Elastic Beanstalk, I uploaded a simple PHP document and I can see that deployed successfully.

But Still, I am not satisfied. Because, I don't know which is the correct way to deploy my PHP application.

So can anyone direct me on Deploying a PHP MySQL Application in AWS ?

Dec 28, 2018 in AWS by Sushmita
• 6,900 points
3,836 views

For hosting a dynamic website on AWS, you need to use EC2 product. S3 is only used for storage and static website hosting. Other than EC2, you can also use Lightsail, which is basically a VPS. For hosting on EC2, you will need to launch an empty and install LAMP or any PHP based stack you have on the server. If you have already launched a Drupal on it, then you can simply uninstall the Drupal files or remove them. You will then have the PHP based stack on the server only. So, that is how it can be done as well.

Hi @Oliver, thanks for the answer! Can you please give me some more information about Lightsail? I have some experience working with EC2, S3. But never worked on Laighsail.

Thanks :)

1 answer to this question.

+1 vote

You can do this using AWS RDS

Follow these steps

  • Search for RDS in console, Select MySQL engine, enter the details (DB name, User, Password) and keep the rest categories as default.
  • Mention retention period of 1-7 days, and launch the instance.
  • After launching change the inbound security to "Any where".
  • Copy the endpoint url and port number.
  • Install wamp server 64 and mention its path in command prompt.
  • To connect to your database enter the following credentials- endpoint, port, user name and password: To connect to your database enter the following credentials- endpoint, port, user name and password

  • To see all the databases available enter following command: show databases;(you can run all your SQL Commands)
  • Go to wamp64 and create a folder www.directory, Install AWS SDK for PHP (  https://amzn.to/2LNUuxd ) and visual studio code
  • create  program file in Visual Studio-
  • mention these configuration lines in your php code

{

$servername = "mydbinstance.cg0pjwazvghg.us-west-1.rds.amazonaws.com";

$username = "admin";

$password = "edureka123";

$dbname = "edureka24db";

$usertable= "sample";

$fname = $_POST['firstname'];

$lname=$_POST['lastname'];

// Create connection

$conn=mysqli_connect($servername,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');

echo "<p>Connected to MySQL!</p>";

mysqli_select_db($conn,$dbname);

echo "<p>Connected to DB!</p>";

// Check connection

$sql = "INSERT INTO ".$usertable." values('".$fname."','".$lname."');";

  • To debug the code click on “Start Debugging”

 

 

answered Dec 28, 2018 by ArchanaNagur
• 2,360 points

Related Questions In AWS

0 votes
1 answer

Web Hosting on Amazon AWS (PHP + MySQL)

You can simply refer the following link, ...READ MORE

answered Aug 7, 2018 in AWS by Priyaj
• 58,080 points
629 views
0 votes
1 answer

How do you pass custom environment variable on Amazon Elastic Beanstalk (AWS EBS)?

Old way  - use .ebextensions/*.config in AWS ...READ MORE

answered Sep 11, 2018 in AWS by Archana
• 4,150 points
650 views
+2 votes
1 answer

How PCF (Pivotal Cloud Foundry) is different from AWS (Amazon Web Services)

PCF is a commercial cloud platform (product) ...READ MORE

answered Sep 11, 2018 in AWS by Priyaj
• 58,080 points
18,974 views
0 votes
1 answer

Amazon Web Services: Delete item on DynamoDB Database from Lambda Function

Omitting the Lambda boilerplate      var tablename= "Users" dynamodb.deleteItem({ "TableName": tableName "Key": ...READ MORE

answered Feb 16 in AWS by anonymous
199 views
0 votes
1 answer

how to get aws account number /id based on EC2 instance which is hosted in amazon

You can obtain account number from an ...READ MORE

answered Feb 21 in AWS by Korak
• 5,820 points
509 views
+3 votes
4 answers

How to host a website on AWS?

Certainly, it can be used to do ...READ MORE

answered Mar 30, 2018 in AWS by brat_1
• 7,200 points
1,585 views
+1 vote
2 answers

How do I run python script on aws EC2 instance(ubuntu)?

I believe that you are using the ...READ MORE

answered Apr 17, 2018 in AWS by Cloud gunner
• 4,660 points
9,071 views
0 votes
1 answer

AWS EFS vs EBS vs S3 (differences & when to use?)

Parameters S3 EBS EFS Access Can be accessed publicly  Accessed only through given ...READ MORE

answered Aug 9, 2018 in AWS by ArchanaNagur
• 2,360 points
592 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP