How to deploy a PHP application from ec2 instance? - php

I have created an ec2 instance and I need to deploy my php-yii application on it. I have uploaded the entire code base to the server and I have connected it with my RDS instance holding my MYSQL database. I have setup a LAMP stack for the server. I have also configured the Network Interfaces and Security Groups and I'm able to access my files in the server from outside.
How will I deploy my yii application in this setup? Should I use beanstalk for this?

Move the application to the /var/www/html folder and it launches automatically. Also remove the index.html already present in that folder.

Related

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 application in elastic beanstalk AWS

I created multiple REST api's for my website on a local server(wamp) and now i am trying to move it to a online server(aws elastic beanstalk). My question is where do i build my database with the tables and rows etc just like in phpmyadmin? I figured that "upload and deploy" means upload the php file i made but when i do i get an error saying "health degraded". So what i want to do is basically move my local server to an online one with aws EB. I watched a bunch of videos and did a lot of research but can't seem to find the way to go about this problem.
My question is where do i build my database with the tables and rows
etc just like in phpmyadmin?
You can connect to the RDS instance created by beanstalk using a Database Management Client Tool like MySQL Workbench, Heidi SQL & etc using the DNS name, created for RDS instance. However one challenge you will face is to access the RDS instance from your client machine, since its not a good practice to make the Database publicly accessible. You can create a EC2 instance (Windows or Linux with GUI) inside the same VPC, connect to it (Remote Desktop or SSH) and install the tools so that you can use the tools inside the server, to connect to the RDS instance.
I figured that "upload and deploy" means upload the php file i made
but when i do i get an error saying "health degraded"
To understand the structure in code inside the Zip file, I would recommend to create a Beanstalk environment with a sample project available in Beanstalk and download the sample project artifact (Zip file) from S3 so that you can compare the project structure requirements.
If you prefer to go through the documentation, you can refer this. If nothing goes well, connect to the ElasticBeanstalk provisioned EC2 instance (Either using Remote Desktop for Windows or SSH to linux) and investigate the deployed artifacts.

updating the files that are deployed on ec2-instance

I am new to laravel and AWS. I have created a website in laravel and deployed it in ec2-instance. I want to make some bug fixes in the files. How can I make those changes on the existing EC2 instance??
Rather than SSH into your instance, do you have something like WinSCP which is an FTP app I use for my AWS instances. If not, install WinSCP (or equivalent), add your ppk file for authentication, and you should be good to go.
Also - just ensure you have the correct folder permissions in your code folder. If not - you'll need to SSH in and fix that, as you'll get a permissions error when you try to upload your new files.
You should be able to SSH into the EC2 instance.
Here's a link on how to SSH into an EC2 instance:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html

public ip changes randomly AWS ec2-instance

Im using AWS ec2-instance to run my website with a public ip of xxx.xxx.xxx.xx
All php files were stored on this instance. Now for some reason I dont know how, the public ip changed to aaa.xxx.aaa.xx and all the files disappeared and everything got deleted. I never started/stopped the ec2 instance because this changes the public ip. This happened so randomly. Now I dont have recent updates of my php files so I need to rewrite them. I would assume amazon would send me an email saying that they would change our public ip.
An auto-scaling group will launch instances as required to meet the number of instances expected. This can occur when scaling up or when an existing instance becomes unresponsive.
Newly launched instances will be created using the configured image. So if your configuration changes or app source code aren't part of the image they won't be present in the new instance.
If the contents of your instance doesn't change often, you can simple create a new image from an instance running your app and configure the auto-scaling group to use it as the image for new;y launched instances.
Another approach, using Elastic Beanstalk, is to create an application version, either as a bundle or using the EB CLI command eb deploy. The Elastic Beanstalk app can also include instructions on how to configure your instances. The app and its environment configuration will then be applied to any instance launched by Elastic Beanstalk.

Azure Web Apps: FTP-uploaded file permissions

I'm in the process of getting a Laravel 5 app working on Azure Web Apps and am encountering an issue via Laravel's temporary storage.
Any time a template renders, Laravel attempts to cache it to the local filesystem. Unfortunately, for some reason Laravel doesn't have permission to write to its storage directory.
I am deploying my application from my build server via FTP
I am running on the free-tier shared infrastructure (just while I'm getting set up)
My deployment server is running Linux
In this circumstance, it's obvious what the problem is. Unfortunately, what I don't understand is why my web server doesn't have access to write to the directories my FTP user uploads.
Ideally any solution offered will be one that I can automate as part of my deploy process.
According to http://clivern.com/working-with-laravel-caching/, you can change the directory of the cache files using the cache.php configuration file. I'd like to suggest you to use $_SERVER['DOCUMENT_ROOT'] to obtain the root folder of your web app, and then construct a path for the cache files.

Categories