Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to host a PHP file with AWS?

After many hours of reading documentation and messing around with Amazon Web Services. I am unable to figure out how to host a PHP page.

Currently I am using the S3 service for a basic website, but I know that this service does not support dynamic pages. I was able to use the Elastic Beanstalk to make the Sample Application running PHP. But i have really no idea how to use it. I read up on some other services but they don't seem to do what I want or they are just way to confusing.

So what I want to be able to do is host a website with amazon that has dynamic PHP pages. Is this possible and what services do you use?

like image 410
Ryan Erb Avatar asked Jan 11 '14 14:01

Ryan Erb


People also ask

Can I host PHP on AWS?

AWS Elastic Beanstalk for PHP makes it easy to deploy, manage, and scale your PHP web applications using Amazon Web Services. Elastic Beanstalk for PHP is available to anyone developing or hosting a web application using PHP.

How do I run a PHP instance in EC2?

Make sure your security group has HTTP and SSH inbound rules. Allow enough time for the instance to launch and execute the script. Copy the EC2 public IP address(or public DNS address). This will open up the php application.

Can PHP run in a S3 bucket?

S3 doesn't run any sort of CGI script (PHP, Perl, Ruby, etc). Think of it as a static html and image repository. If you want to host your PHP application on AWS, consider using AWS Beanstalk. It will launch an environment (server, IP, etc) where you can deploy and run your PHP application easily.


1 Answers

For a PHP app, you really have two choices in AWS.

Elastic Beanstalk is a service that takes your code, and manages the runtime environment for you - once you've set it up, it's very easy to deploy, and you don't have to worry about managing servers - AWS does pretty much everything for you. You have less control over the environment, but if your server will run in EB then this is a pretty easy path.

EC2 is closer to conventional hosting. You need to decide how your servers are configured & deployed (what packages get installed, what version of linux, instance size, etc), your system architecture (do you have separate instances for cache or database, whether or not you need a load balancer, etc) and how you manage availability and scalability (multiple zones, multiple data centers, auto scaling rules, etc).

Now, those are all things that you can use - you dont have to. If you're just trying to learn about php in AWS, you can start with a single EC2 instance, deploy your code, and get it running in a few minutes without worring about any of the stuff in the previous paragraph. Just create an instance from the Amazon Linux AMI, install apache & php, open the appropriate ports in the firewall (AKA the EC2 security group), deploy your code, and you should be up & running.

like image 143
chris Avatar answered Sep 23 '22 21:09

chris