Web Service creation AWS - php

So I am trying out AWS (Amazon Web Services) and I figured out how to put my db and its information on their server however I am not sure as to where I will put my php web service which gives a JSON response. Is there a tutorial or can someone tell me how I can accomplish this?

Suppose you are going to use the LAMP stack. I would either install LAMP on your EC2 instance or find a community image that has LAMP already installed and create an instance using that image.

You can start with Amazon Lightsail which is a beginner friendly service to deploy applications.
Or you can put your Application in Elastic Beanstalk and use its build in RDS feature for your database.
Attached you see the documentation for deploying a PHP application.

Related

Using php with angular application hosted on AWS

I'm new to AWS. I created a DB and I am currently hosting the website right now. This is great!
The problem is that I don't know how to integrate my PHP files that I was using before the start of AWS.
My previous stack was: Angular, MyPHP, MySQL, Apache. Everything was running locally. So I was able to use the same IP for the database and to also run php files.
What I tried to do was upload the php files into the S3 bucket. This doesn't work. The website will only download the file and not execute.
So how would I implement the same fluid way of integrating PHP on AWS as I did on my local computer?
If you want to do this on AWS you will need an EC2 instance to run your dynamic queries to the database. S3 will only host static files or programming which works on the client-side (JavaScript).
If it is a basic website, you might want to consider LightSail
My suggestions would be,
use EC2 instead of using s3 for hosting the PHP website as you can have complete control over the server.
For setting up EC2 with PHP please follow the steps in the following article.
Setting up EC2(ubuntu instance) for php

Deploying PHP application using AWS Elastic Beanstalk

I am very new to AWS. I am trying to deploy my php application to AWS. I created an environment and then uploaded and deployed all files (including .sql) in zip format. When I am trying to access my website using URL it doesn't show anything. When I tried viewing page source, it showed database connectivity error?
Any help would be appreciated.
Thank you.
For Database connection,
You need create a new environment either using RDS or on the instance.
You can set up RDS using Beanstalk.
Refer :http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_PHP.rds.html#create_deploy_PHP.rds.newDB
Still you will have much to manually configure to load your existing data to RDS or to the instance.
Hope it Helps.. :)
I had written a blog on a similar use case. I also have a screencast on the same. Can you follow this and see if this helps:
http://www.tothenew.com/blog/aws-elastic-beanstalk-php/
I have deployed a wordpress PHP website. Look what you need is a new RDS or an old RDS instance or Database on an EC2 server and have to give PHP app that endpoint and port.

Deploy Web App on AWS

I'm a beginner on cloud providers, and I have a website to deploy. The website is made with PHP, HTML, CSS and Javascript, and it uses an API developed on NodeJS to access a database.
Is there a way to deploy all of this (Inteface + NodeJS API) on one AWS Elastic Beanstalk application? Or should I deploy only the API on AWS Elastic Beanstalk and deploy the website's interface with other AWS solution, e.g. a static website on Amazon S3.
I'm really lost on so many solutions, can someone give me some tips on this scenario?
One solution is you can deploy PHP application using Elastic Beanstalk and then apply edits to the configuration file of Elastic Beanstalk to Install Nodejs on the EC2 instance.
Or another solution is you can setup you PHP and Node application on a standalone EC2 instance and after everything is set you can create the AMI of that instance and use it in Elastic beanstalk .
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.customenv.html

PHP files on Amazon S3 Not Working

Total newb question I'm sure but I'm new to S3 and trying to open a simple PHP file on my server. Yet it prompts to Save the file each time instead of opening it. Is S3 not able to run PHP files?
I believe Amazon S3 is a storage not a server.
Amazon S3:
Amazon Simple Storage Service (Amazon S3), provides developers and IT teams with secure, durable, highly-scalable object storage. Amazon S3 is easy to use, with a simple web service interface to store and retrieve any amount of data from anywhere on the web. With Amazon S3, you pay only for the storage you actually use. There is no minimum fee and no setup cost.
Link: https://aws.amazon.com/s3/
Amazon EC2:
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers.
Link: https://aws.amazon.com/ec2/
You want to get an instance from EC2 and install php on its linux server.
AWS has a great tutorial to do so here.
Basically AWS EC2 linux servers are the same as any other linux server except lots of features from AWS so you can follow other tutorials on how to install PHP on an Apache2 servers.
Good luck!
EDIT: However, you can host a static website. Static website is a website that shows the same content for all users. Basic informational websites are the example. As opposed to static website, dynamic website is a website that shows different contents for different users. The purpose of php script is to create a dynamic website, so you must look for other options than AWS S3. So EC2 would be great fit for you.

Web Hosting on Amazon AWS (PHP + MySQL)

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 ?
Depends on your needs. Elastic Beanstalk might be a good option for many apps, but I chose EC2 for my app's backend (using PHP, MySQL and S3 for storage).
Quick steps to get you up and running:
Log into the AWS Mangement Console and start a new EC instance (Windows server 2012 R2 Base > t2.micro should be good enough for a start!)
At step "6. Configure Security Group", add Rules for at least HTTP, HTTPS and RDP (so you can connnect via Remote Desktop)
Connect to your new instance via Remote Desktop and install a decent browser (Enable File Downloads in IE's Security Settings and download Chrome or Firefox)
Open the Windows Firewall and add rules for the same ports you opened in the Security Group of your Instance in the AWS Management Console. (Right-click on “Inbound Rules”, then select “New Rule…”)
Download and install XAMPP (I put it in C:\xampp)
Open the XAMPP Control panel and install Apache and MySQL as services (so they will start automatically when your instance launches); make sure everything is started up.
Now put your files in C:\xampp\htdocs\ and you're ready to go!
Bonus Steps:
Set up Filezilla FTP Server (and open the required ports in both the instance's security group and the Windows Firewall) so you can upload/download files without having to go through Remote Desktop.
Get an Elastic IP and assign it to your instance, so it's IP address will never change.
Get an SSL certificate so you can use HTTPS
The answer depends on the load that you are expecting and the resources you have to handle all the administration tasks.
If you expect heavy or variable loads, there are many reasons why not to deploy a production PHP + MySQL application on a EC2.
Here are some of the benefits of deploying to Elastic Beanstalk instead of a manual configured EC2:
You get version control of each deployment.
You can scale up or down automatically if you need more/less instances to handle new load.
You get a load-balancer in front of your EC2s instances with a bunch of out-of-the-box "recommended" configurations.
Regarding MySQL, if you go for an Amazon RDS instance you can handle replication, monitorization and automatic backups with pretty low effort. A lot of the configurations you would need to tweak are now available through parameter-groups.
On the other hand, if you want to have full control of everything that is going on on your server (that means you have time to monitor, backup and do maintenance tasks, which is not my case :), or if you do not plan to have much traffic, or if you want the less expensive option, you should go with a low cost EC2 instance.
In my experience, (after 2 years of working on AWS with 10 production applications, I'm kind of a regular AWS user) pretty much every customization or change I needed on both RDS and EBS I was able to tweak it and get it working, so I'm pretty satisfied with choosing the EBS+RDS option.
Below are two links i found which are helpful to Create and Update an Application with AWS Elastic Beanstalk
https://aws.amazon.com/getting-started/tutorials/launch-an-app/
https://aws.amazon.com/getting-started/tutorials/update-an-app/

Categories