PHP files on Amazon S3 Not Working - php

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.

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

GCloud App needs FTP - do I need a VM or can I create an FTP app?

I'm running a PHP app on GCloud (Google App Engine). This app will require users to submit files for processing via FTP. A python cron job with process them.
Given that dev to prod is via the GAE deployment, I'm assuming there is no FTP access to the app folder structure.
How would I go about providing simple one-way FTP to my users? Can I deploy a Python project that will be a server? Or do I need to run a VM?
I've done some searching which suggests the VM option, but surely there are other options?
App Engine projects are not based on server virtual machines. App Engine is a platform as a service, not infrastructure as a service. Your code is packaged up and served on Google App Engine in a manner that can scale easily. App Engine is not a drop-in replacement for your old school web hosting, its quite a bit different.
That said, FTP is just a mechanism to move files. If your files just need to be processed by a job, you can look at providing an upload for your users where the files end up residing on Google Cloud Storage and then your cron job reads from that location and does any processing that is needed. What results from that processing might result in further considerations. Don't look at FTP being a requirement, but rather a means to moving files and you'll probably have plenty of options.

How to deploy code in AWS webserver when code repo is NOT in git?

Recently I have been involved in a project where I have set up a LAMP stack in AWS and also helping out the team for building other infrastructure. As per company policy, we need to create a new instance in every 60 days taking the latest ami and kill the previous one. For this reason, I requested the development team to move the php code to git repo. This would help me automate the build so that I can directly pull the code from git. But, they are saying they don't want to move the code in git for some licensing reason as the code they are using have been purchased from phpgrid (vendor). This is little strange to me...anyways, if the code is NOT in git, how can we automate the code deployment in webserver? Any thoughts on the best practices? Don't want to ftp the code from someone's machine :(
AWS Code Deploy service is purpose-built for code deployments like this.
AWS CodeDeploy is part of a family of AWS deployment services that
includes AWS Elastic Beanstalk, AWS CodePipeline, AWS CloudFormation,
and AWS OpsWorks. AWS CodeDeploy coordinates application deployments
to Amazon EC2 instances, on-premises instances, or both. (On-premises
instances are physical devices that are not Amazon EC2 instances.)
An application can contain deployable content like code, web, and
configuration files, executables, packages, scripts, and so on. AWS
CodeDeploy deploys applications from Amazon S3 buckets and GitHub
repositories.
You can use any repository really. You just need a process to move the code from its repo to an designated S3 bucket. The code can be anywhere: SVN, on-premise, etc. Just zip it up, move to S3 and register the revision and deploy as needed. A GIT repository is not required, but it is directly supported by CodeDeploy.
We integrate the process with Jenkins our Continuous Integration server so all builds are sent to S3 as a CodeDeploy-ready revision.
There is no cost for using this feature when deploying to AWS instances - its free!

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/

Web Service creation AWS

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.

Categories