Editing
Hosting A PHP Web Application On AWS
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
Editing Hosting A PHP Web Application On AWS == Overview == == Process (rough notes) == From the AWS Management Console home page > '''Build a solution''' group, click on '''Build a web app''', which is a path to creating a new Elastic Beanstalk instance. ''-- OR --'' '''AWS Management Console''' > '''Services''' > '''Compute''' > '''Elastic Beanstalk'''. '''Create New Application''' at the upper right. Once the application is created, navigate to its management page, '''Actions''' dropdown (upper right) > '''Create environment''' === Create a web server environment === '''Select environment tier''': Web server environment. Then click '''Select''' * '''Environment name:''' ''appropriate token for the environment'' * '''Domain:''' ''leave blank'' * '''Platform:''' PHP, Python, Docker, etc. * '''Applciation code''': Upload your code ** ''In the next dialog there is an option to use a Public S3 URL, which might be simpler to maintain with Git, etc.? No, this process only accepts zip files, so using an S3 bucket would mean that there is a zip archive located at the URL. Also, Git is an option, but only after using Git to archive a repo.'' ** '''Version label:''' Include some indication of version in the token, e.g. version number or date. * Click '''Create Environment''' to create and launch the new environment. This will create a new EC2 instance. === More configuration options === Click '''"Configure more options''' button to define additional properties for the web server. For example, to create a database, or to define security properties for the EC2 instance linked to the web server. ==== Security ==== This panel controls key pairs for SSH access. '''Virtual machine permissions''' > '''EC2 key pair''' > choose an existing key pair. (This is created via '''AWS Management Console''' > '''EC2''' > '''Network & Security''' > '''Key Pairs''') When connecting to the EC2 instance via ssh, it's necessary that an inbound rule exists for ssh for the EC2 instance's security group. Under instance details, click on the security group > '''Inbound''' tab > '''Edit''' button. There should be a rule for SSH for the IP address of the machine that is used to ssh to the EC2 instance. ==== Instances (EC2) ==== Control over '''instance type''' and '''security types'''. Once the environment is launched a url will be available that can be used to view the web site. ==== Database ==== Either select an existing snapshot, or create a new database. For example, MariaDB is not available from the list of database types when creating a new database. In order to link the EBS to a MariaDB database, first create the MariaDB instance in the AWS RDS Management Console. Then create a snapshot of the database. Then select that snapshot when selecting a database for the EBS. Security group rules must be configured to allow the EB instance to make connections to the RDS database. * '''AWS Management Console''' > '''RDS''' > '''Instances''' > ''my instance'' > click for details * Scroll down to the '''Connect''' pane to view a list of '''Security groups''' * An inbound rule needs to exist for the VPC that was created for the EB instance. * Scroll farther down on the RDS instance details page for the '''Details''' pane > '''Security and network''' > '''VPC''' > click on the VPC name to view its details, e.g. its IPv4 CIDR. * Click on a '''CIDR/IP - Inbound''' security group to edit its settings. * '''Security Groups listings''' page > Click on the row for the RDS's security group > '''Inbound''' tab > '''Edit''' button ** '''Type:''' e.g. MYSQL/Aurora, or appropriate database type ** '''Protocol:''' TCP ** '''Port range:''' 3306 ** '''Source:''' VPC IPv4 CIDR value === Subdomains === Create subdomains as separate environments under the common EB application. == Configuration == From the EB on the the EB instance to view its properties. '''Notifications''' - Enter an email address to receive notifications. == Updating app code == Source files are located at `/var/app/current/` === AWS Management Console === Zip the entire contents of the project (not including the parent folder). * '''EBS Management Console''' > ''application'' > '''application versions''' * '''Upload''' button ** '''Version label:''' ''name consistent with previous uploads'' ** '''Upload application:''' ''choose the zip file'' * After upload completes select the application version > '''Deploy''' button. ** Select the environment that the code should be deployed to. === EB CLI === ==== Installing eb cli on Mac OS ==== Use pip and not homebrew. ==== Updating app source without Git ==== First initialize the eb environment with <syntaxhighlight lang="sh"> $ eb init </syntaxhighlight> This will prompt for properties of the EB application and environment, and then store the configuration in `./.elasticbeanstalk/config.yml` Edit the config file with the path of the zip file to use for updating the app: <syntaxhighlight lang="yaml"> deploy: path/to/app-source.zip </syntaxhighlight> Zip the project with <syntaxhighlight lang="sh"> $ zip ../app-source.zip -r * .[^.]* </syntaxhighlight> Then from the directory where `.elasticbeanstalk/` is located, deploy with: <syntaxhighlight lang="sh"> $ eb deploy </syntaxhighlight> === PHPStorm === It's possible to create a remote host for the EBS, but it is read-only. * '''Type:''' SFTP * '''SFTP hose:''' ''AWS EC2 Management console > EC2 instnace > IPv4 Public IP'' * '''Root path:''' /var/app/current/ * '''User name:''' ec2-user * '''Auth type:''' Key pair * '''Private key file:''' ''path to .pem file'' == Importing data == Any MariaDB (or MySQL) client can be used to connect to the MariaDB database if it is publicly accessible, e.g. MySQLWorkbench. <ref>[https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToMariaDBInstance.html Connecting to a DB Instance] - AWS documentation</ref> Retrieve the Endpoint from the AWS Management Console after loading the details of the MariaDB RDS instance. This is the host for the purposes of connecting to the database. * Connect to the database with MySQLWorkbench. * '''Management''' > '''Data Import/Restore''' * '''Import from Self-Contained File''' > ''Select a dump of the source database'' * ''''Default Target Schema''' > ''Select database'' * '''Dump Structure and Data''' * '''Start Import''' button == Viewing server logs == ''TK'' == Pricing == See [[Amazon_Web_Services_Website_Hosting_Fundamentals#Pricing|AWS Web Hosting Fundamentals]] == Notes == <references/> [[Category:AWS]][[Category:Web Development]]
Summary:
Please note that all contributions to Littledamien Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Littledamien Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information