Using php with angular application hosted on AWS - php

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

Related

How can i to deploy my PWA on remote server?

I developed a Progressive Web App (PHP and JavaScript based) and i upload it on remote server LEMP (Debian/Nginx based) through FileZilla.
How can i deploy in future the updates without to use FTP?
What tools exists for to manager the next versions of my web app?
If it is of utility i use VSCode for coding.
Thanks guys!
You can't update your web app without FTP. In order to update a new service worker, it needs to have at least one byte different than the previous version.
And the only way to update the service worker file is via FTP.
If you can't use FileZilla for whatever reason, you can try alternatives like editing files through Cpanel File Editor.
Or you can use free hosting like Github Pages, Netlify or Firebase. And automate the deployment of your front each time you commit something on a git repository.
This solution only works for your static files. not for your backend using PHP.
Thanks guys for your replies.
I found the right solution for me following this article: https://amifactory.team/blog/how-to-deploy-a-website/#simplewayscprsyncftp
In pratice i use lftp utility to sync my local website with my website on remote server.
The good notice is that "lftp" copy changed files only, reducing the uploading time and copying / overwriting the new files only at the end of the "lftp" process.

How to setup EC2 as simple website with php support?

I'm an AWS newbie and I can't seem to find a good example. There are plenty of static website examples for S3, but my site needs to run a fairly simple PHP script which then means I need to be on EC2.
I used Elastic Beanstalk to create an EC2 instance and it added a simple PHP example, so when I go to the public DNS address in a browser, I see the example PHP script run. So far, so good.
But, where are those files and how to I access/modify them? They don't seem to be in the S3 bucket that Elastic Beanstalk created.
If I try to Connect to my EC2 instance, it says there's a problem with port 22 and a key pair is needed. Not sure what to do here.
So, how do I upload an html website to run on this instance and still get a PHP script to run?
Sorry if I have some of the terminology or methodology wrong.
Thank you.
But, where are those files and how to I access/modify them? They don't seem to be in the S3 bucket that Elastic Beanstalk created.
They probably are but in a ZIP package. You don't modify anything on the fly. You're supposed to modify your source code on a local machine, "bundle" it in a ZIP file and then either
Upload with AWS Console.
Upload it to S3, create an application version with AWS CLI and then deploy (also with AWS CLI).
Docs are here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_PHP_eb.html
It is possible to change your application by connecting to an EC2 instance, but your changes will be lost during redeployment, scaling etc.
If I try to Connect to my EC2 instance, it says there's a problem with port 22 and a key pair is needed. Not sure what to do here.
When you created your Elastic Beanstalk environment you were asked for 'EC2 key pair'. You should use that exact SSH key to connect to your instance. This step is optional, so it is possible that you skipped it and created an environment without a key. In this case there is no way to connect to your EC2 instance (almost). You'll have to upload an SSH key (EC2 dashboard -> NETWORK & SECURITY -> Key Pairs) and create a new environment.

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.

Are there any steps on how to set up an Apache Multi-AZ Amazon RDS database instance and using S3?

I am trying to set up a Linux/Apache Drupal Website using a Multi-AZ Amazon RDS database instance found in this link:
https://aws.amazon.com/cloudformation/aws-cloudformation-templates/
So far, I have launched the Drupal "Highly Available Web Server with Multi-AZ Amazon RDS database instance and using S3 for storing file content" stack using the link below and it has created my two instances, a Load Balancer and a DB.
I have followed all the steps up until the "Installing and Configuring Drupal" section in the following link thinking that I would just have to run through all the steps for each instance and it would then allow me to view my website on a browser:
http://www.imamuseum.org/cc-mcn09.pdf
My conf file is set up in the ect/httpd/conf.d folder in its own file.
Does anyone have any experience on this?
Please let me know if you have any questions.
Thanks,

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