Web Hosting on Amazon AWS (PHP + MySQL)

0 votes

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,880 points
347 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.

0 votes

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,270 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
• 56,900 points
88 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,090 points
61 views
0 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
• 56,900 points
1,138 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,280 points
2,214 views
0 votes
1 answer
0 votes
1 answer

How do I create folder under an Amazon S3 bucket through PHP API?

Of Course, it is possible to create ...READ MORE

answered Apr 24, 2018 in AWS by anonymous
2,614 views
+1 vote
3 answers

Unable to login to parse dashboard on AWS

I had the same issue, which I ...READ MORE

answered Aug 28, 2018 in AWS by eatcodesleeprepeat
• 4,670 points
633 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 8, 2018 in AWS by ArchanaNagur
• 2,270 points
186 views