Hosting A PHP Web Application On AWS: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Editing Hosting A PHP Web Application On AWS
== Overview ==
== Overview ==


Line 12: Line 15:


Once the application is created, navigate to its management page, '''Actions''' dropdown (upper right) > '''Create environment'''
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'''
'''Select environment tier''': Web server environment. Then click '''Select'''
Line 21: Line 26:
** '''Version label:''' Include some indication of version in the token, e.g. version number or date.
** '''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.  
* 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.
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.


=== Subdomains ===
=== Subdomains ===
Line 33: Line 62:


'''Notifications''' - Enter an email address to receive notifications.
'''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>
$ 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>
$ zip ../app-source.zip -r * .[^.]*
</syntaxhighlight>
Then from the directory where `.elasticbeanstalk/` is located, deploy with:
<syntaxhighlight>
$ 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 ==
== Pricing ==


''TK''
See [[Amazon_Web_Services_Website_Hosting_Fundamentals#Pricing|AWS Web Hosting Fundamentals]]
 
== Notes ==
<references/>


[[Category:AWS]][[Category:Web Development]]
[[Category:AWS]][[Category:Web Development]]
Summary:
This is a minor edit  Watch this page
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
Video8TalkPreferencesWatchlistContributionsLog outPageDiscussionReadEditView historyUnwatch
More
Search
Search Littledamien Wiki
Main page
Recent changes
Random page
Help
Tools
What links here
Related changes
Upload file
Special pages
Page information
Privacy policyAbout Littledamien WikiDisclaimersPowered by MediaWiki

Revision as of 19:21, 20 July 2018

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.

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

$ eb init

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:

deploy:
  path/to/app-source.zip

Zip the project with

$ zip ../app-source.zip -r * .[^.]*

Then from the directory where .elasticbeanstalk/ is located, deploy with:

$ eb deploy

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. [1]

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 AWS Web Hosting Fundamentals

Notes

  1. Connecting to a DB Instance - AWS documentation

Summary:

This is a minor edit  Watch this page

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 Video8TalkPreferencesWatchlistContributionsLog outPageDiscussionReadEditView historyUnwatch More Search

Search Littledamien Wiki Main page Recent changes Random page Help Tools What links here Related changes Upload file Special pages Page information Privacy policyAbout Littledamien WikiDisclaimersPowered by MediaWiki