|
1 | | -# Deploying WordPress on Elastic Beanstalk |
2 | | -These instructions were tested with WordPress 4.6.1 |
3 | | - |
4 | | -## Install the EB CLI |
5 | | - |
6 | | -The EB CLI integrates with Git and simplifies the process of creating environments, deploying code changes, and connecting to the instances in your environment with SSH. You will perform all of these activites when installing and configuring WordPress. |
7 | | - |
8 | | -If you have pip, use it to install the EB CLI. |
9 | | - |
10 | | -```Shell |
11 | | -$ pip install --user --upgrade awsebcli |
12 | | -``` |
13 | | - |
14 | | -Add the local install location to your OS's path variable. |
15 | | - |
16 | | -###### Linux |
17 | | -```Shell |
18 | | -$ export PATH=~/.local/bin:$PATH |
19 | | -``` |
20 | | -###### OS-X |
21 | | -```Shell |
22 | | -$ export PATH=~/Library/Python/3.4/bin:$PATH |
23 | | -``` |
24 | | -###### Windows |
25 | | -Add `%USERPROFILE%\AppData\Roaming\Python\Scripts` to your PATH variable. Search for **Edit environment variables for your account** in the Start menu. |
26 | | - |
27 | | -If you don't have pip, follow the instructions [here](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html). |
28 | | - |
29 | | -## Set up your project directory |
30 | | - |
31 | | -1. Download WordPress. |
32 | | - |
33 | | - ~$ curl https://wordpress.org/wordpress-4.6.1.tar.gz -o wordpress.tar.gz |
34 | | - |
35 | | -2. Download the configuration files in this repository |
36 | | - |
37 | | - ~$ curl https://github.com/awslabs/eb-php-wordpress/releases/download/v1.0/eb-php-wordpress-v1.zip -o eb-php-wordpress.zip |
38 | | - |
39 | | -3. Extract WordPress and change the name of the folder |
40 | | - |
41 | | - ~$ tar -xvf wordpress.tar.gz |
42 | | - ~$ mv wordpress wordpress-beanstalk |
43 | | - ~$ cd wordpress-beanstalk |
44 | | - |
45 | | -4. Extract the configuration files over the WordPress installation |
46 | | - |
47 | | - ~/wordpress-beanstalk$ unzip ~/eb-php-wordpress-v1.0.zip |
48 | | - creating: .ebextensions/ |
49 | | - inflating: .ebextensions/dev.config |
50 | | - inflating: .ebextensions/efs-create.config |
51 | | - inflating: .ebextensions/efs-mount.config |
52 | | - inflating: .ebextensions/loadbalancer-sg.config |
53 | | - inflating: .ebextensions/wordpress.config |
54 | | - inflating: LICENSE |
55 | | - inflating: README.md |
56 | | - inflating: wp-config.php |
57 | | - |
58 | | -## Create an Elastic Beanstalk environment |
59 | | - |
60 | | -1. Configure a local EB CLI repository with the PHP platform. Choose a [supported region](http://docs.aws.amazon.com/general/latest/gr/rande.html#elasticbeanstalk_region) that is close to you. |
61 | | - |
62 | | - ~/wordpress-beanstalk$ eb init --platform php7.0 --region us-west- |
63 | | - Application wordpress-beanstalk has been created. |
64 | | - |
65 | | -2. Configure SSH. Create a key that Elastic Beanstalk will assign to the EC2 instances in your environment to allow you to connect to them later. You can also choose an existing key pair if you have the private key locally. |
66 | | - |
67 | | - ~/wordpress-beanstalk$ eb init |
68 | | - Do you want to set up SSH for your instances? |
69 | | - (y/n): y |
70 | | - |
71 | | - Select a keypair. |
72 | | - 1) [ Create new KeyPair ] |
73 | | - (default is 1): 1 |
74 | | - |
75 | | - Type a keypair name. |
76 | | - (Default is aws-eb): beanstalk-wordpress |
77 | | - |
78 | | -3. Create an Elastic Beanstalk environment with a MySQL database. |
79 | | - |
80 | | - ~/wordpress-beanstalk$ eb create wordpress-beanstalk --sample --database |
81 | | - Enter an RDS DB username (default is "ebroot"): |
82 | | - Enter an RDS DB master password: |
83 | | - Retype password to confirm: |
84 | | - Environment details for: wordpress-beanstalk |
85 | | - Application name: wordpress-beanstalk |
86 | | - Region: us-west-2 |
87 | | - Deployed Version: Sample Application |
88 | | - Environment ID: e-nrx24yzgmw |
89 | | - Platform: 64bit Amazon Linux 2016.09 v2.2.0 running PHP 7.0 |
90 | | - Tier: WebServer-Standard |
91 | | - CNAME: UNKNOWN |
92 | | - Updated: 2016-11-01 12:20:27.730000+00:00 |
93 | | - Printing Status: |
94 | | - INFO: createEnvironment is starting. |
95 | | - |
96 | | -## Networking configuration |
97 | | -Modify the configuration files in the .ebextensions folder with the IDs of your [default VPC and subnets](https://console.aws.amazon.com/vpc/home#subnets:filter=default), and [your public IP address](https://www.google.com/search?q=what+is+my+ip). |
98 | | - |
99 | | - - `.ebextensions/efs-create.config` creates an EFS file system and mount points in each Availability Zone / subnet in your VPC. |
100 | | - - `.ebextensions/ssh.config` restricts access to your environment to your IP address to protect it during the WordPress installation process. |
101 | | - |
102 | | -## Deploy WordPress to your environment |
103 | | -Deploy the project code to your Elastic Beanstalk environment. |
104 | | - |
105 | | -First, confirm that your environment is `Ready` with `eb status`. Environment creation takes about 15 minutes due to the RDS DB instance provisioning time. |
106 | | - |
107 | | -```Shell |
108 | | -~/wordpress-beanstalk$ eb status |
109 | | -~/wordpress-beanstalk$ eb deploy |
110 | | -``` |
111 | | - |
112 | | -### NOTE: security configuration |
113 | | - |
114 | | -This project includes a configuration file (`loadbalancer-sg.config`) that creates a security group and assigns it to the environment's load balancer, using the IP address that you configured in `ssh.config` to restrict HTTP access on port 80 to connections from your network. Otherwise, an outside party could potentially connect to your site before you have installed WordPress and configured your admin account. |
115 | | - |
116 | | -You can [view the related SGs in the EC2 console](https://console.aws.amazon.com/ec2/v2/home#SecurityGroups:search=wordpress-beanstalk). In the top right corner, choose the region in which you created your environment. |
117 | | - |
118 | | -## Install WordPress |
119 | | - |
120 | | -Open your site in a browser. |
121 | | - |
122 | | -```Shell |
123 | | -~/wordpress-beanstalk$ eb open |
124 | | -``` |
125 | | - |
126 | | -You are redirected to the WordPress installation wizard because the site has not been configured yet. |
127 | | - |
128 | | -Perform a standard installation. The `wp-config.php` file is already present in the source code and configured to read database connection information from the environment, so you shouldn't be prompted to configure the connection. |
129 | | - |
130 | | -Installation takes about a minute to complete. |
131 | | - |
132 | | -# Updating keys and salts |
133 | | - |
134 | | -The WordPress configuration file `wp-config.php` also reads values for keys and salts from environment properties. Currently, these properties are all set to `test` by the `wordpress.config` configuration file in the `.ebextensions` folder |
135 | | - |
136 | | -The hash salt can be any value but shouldn't be stored in source control. Use `eb setenv` to set these properties directly on the environment. |
137 | | - |
138 | | - AUTH_KEY, SECURE_AUTH_KEY, LOGGED_IN_KEY, NONCE_KEY, AUTH_SALT, SECURE_AUTH_SALT, NONCE_SALT |
139 | | - |
140 | | -```Shell |
141 | | -~/wordpress-beanstalk$ eb setenv AUTH_KEY=randomnumbersandletters89237492374 |
142 | | -~/wordpress-beanstalk$ eb setenv SECURE_AUTH_KEY=ah24h3drfh97623ljkhsdf293t5fghks |
143 | | -... |
144 | | -``` |
145 | | - |
146 | | -Setting the properties on the environment directly by using the EB CLI or console overrides the values in `wordpress.config`. |
147 | | - |
148 | | -Remove the custom load balancer configuration to open the site to the Internet. |
149 | | - |
150 | | -```Shell |
151 | | -~/wordpress-beanstalk$ rm .ebextensions/loadbalancer-sg.config |
152 | | -~/wordpress-beanstalk$ eb deploy |
153 | | -``` |
154 | | - |
155 | | -Scale up to run the site on multiple instances for high availability. |
156 | | -```Shell |
157 | | -~/wordpress-beanstalk$ eb scale 3 |
158 | | -``` |
159 | | - |
160 | | -When the update completes, open the site. |
161 | | - |
162 | | -```Shell |
163 | | -~/wordpress-beanstalk$ eb open |
164 | | -``` |
165 | | - |
166 | | -Refresh the site several times to verify that all instances are reading from the EFS file system. Create posts and upload files to confirm functionality. |
167 | | - |
168 | | -# Backup |
169 | | - |
170 | | -Now that you've gone through all the trouble of installing your site, you will want to back up the data in RDS and EFS that your site depends on. See the following topics for instructions. |
171 | | - |
172 | | - - [DB Instance Backups](http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.BackingUpAndRestoringAmazonRDSInstances.html) |
| 1 | +# Deploying WordPress on Elastic Beanstalk |
| 2 | +These instructions were tested with WordPress 4.6.1 |
| 3 | + |
| 4 | +## Install the EB CLI |
| 5 | + |
| 6 | +The EB CLI integrates with Git and simplifies the process of creating environments, deploying code changes, and connecting to the instances in your environment with SSH. You will perform all of these activites when installing and configuring WordPress. |
| 7 | + |
| 8 | +If you have pip, use it to install the EB CLI. |
| 9 | + |
| 10 | +```Shell |
| 11 | +$ pip install --user --upgrade awsebcli |
| 12 | +``` |
| 13 | + |
| 14 | +Add the local install location to your OS's path variable. |
| 15 | + |
| 16 | +###### Linux |
| 17 | +```Shell |
| 18 | +$ export PATH=~/.local/bin:$PATH |
| 19 | +``` |
| 20 | +###### OS-X |
| 21 | +```Shell |
| 22 | +$ export PATH=~/Library/Python/3.4/bin:$PATH |
| 23 | +``` |
| 24 | +###### Windows |
| 25 | +Add `%USERPROFILE%\AppData\Roaming\Python\Scripts` to your PATH variable. Search for **Edit environment variables for your account** in the Start menu. |
| 26 | + |
| 27 | +If you don't have pip, follow the instructions [here](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html). |
| 28 | + |
| 29 | +## Set up your project directory |
| 30 | + |
| 31 | +1. Download WordPress. |
| 32 | + |
| 33 | + ~$ curl https://wordpress.org/wordpress-4.6.1.tar.gz -o wordpress.tar.gz |
| 34 | + |
| 35 | +2. Download the configuration files in this repository |
| 36 | + |
| 37 | + ~$ curl https://github.com/awslabs/eb-php-wordpress/releases/download/v1.0/eb-php-wordpress-v1.zip -o eb-php-wordpress.zip |
| 38 | + |
| 39 | +3. Extract WordPress and change the name of the folder |
| 40 | + |
| 41 | + ~$ tar -xvf wordpress.tar.gz |
| 42 | + ~$ mv wordpress wordpress-beanstalk |
| 43 | + ~$ cd wordpress-beanstalk |
| 44 | + |
| 45 | +4. Extract the configuration files over the WordPress installation |
| 46 | + |
| 47 | + ~/wordpress-beanstalk$ unzip ~/eb-php-wordpress-v1.0.zip |
| 48 | + creating: .ebextensions/ |
| 49 | + inflating: .ebextensions/dev.config |
| 50 | + inflating: .ebextensions/efs-create.config |
| 51 | + inflating: .ebextensions/efs-mount.config |
| 52 | + inflating: .ebextensions/loadbalancer-sg.config |
| 53 | + inflating: .ebextensions/wordpress.config |
| 54 | + inflating: LICENSE |
| 55 | + inflating: README.md |
| 56 | + inflating: wp-config.php |
| 57 | + |
| 58 | +## Create an Elastic Beanstalk environment |
| 59 | + |
| 60 | +1. Configure a local EB CLI repository with the PHP platform. Choose a [supported region](http://docs.aws.amazon.com/general/latest/gr/rande.html#elasticbeanstalk_region) that is close to you. |
| 61 | + |
| 62 | + ~/wordpress-beanstalk$ eb init --platform php7.0 --region us-west- |
| 63 | + Application wordpress-beanstalk has been created. |
| 64 | + |
| 65 | +2. Configure SSH. Create a key that Elastic Beanstalk will assign to the EC2 instances in your environment to allow you to connect to them later. You can also choose an existing key pair if you have the private key locally. |
| 66 | + |
| 67 | + ~/wordpress-beanstalk$ eb init |
| 68 | + Do you want to set up SSH for your instances? |
| 69 | + (y/n): y |
| 70 | + |
| 71 | + Select a keypair. |
| 72 | + 1) [ Create new KeyPair ] |
| 73 | + (default is 1): 1 |
| 74 | + |
| 75 | + Type a keypair name. |
| 76 | + (Default is aws-eb): beanstalk-wordpress |
| 77 | + |
| 78 | +3. Create an Elastic Beanstalk environment with a MySQL database. |
| 79 | + |
| 80 | + ~/wordpress-beanstalk$ eb create wordpress-beanstalk --sample --database |
| 81 | + Enter an RDS DB username (default is "ebroot"): |
| 82 | + Enter an RDS DB master password: |
| 83 | + Retype password to confirm: |
| 84 | + Environment details for: wordpress-beanstalk |
| 85 | + Application name: wordpress-beanstalk |
| 86 | + Region: us-west-2 |
| 87 | + Deployed Version: Sample Application |
| 88 | + Environment ID: e-nrx24yzgmw |
| 89 | + Platform: 64bit Amazon Linux 2016.09 v2.2.0 running PHP 7.0 |
| 90 | + Tier: WebServer-Standard |
| 91 | + CNAME: UNKNOWN |
| 92 | + Updated: 2016-11-01 12:20:27.730000+00:00 |
| 93 | + Printing Status: |
| 94 | + INFO: createEnvironment is starting. |
| 95 | + |
| 96 | +## Networking configuration |
| 97 | +Modify the configuration files in the .ebextensions folder with the IDs of your [default VPC and subnets](https://console.aws.amazon.com/vpc/home#subnets:filter=default), and [your public IP address](https://www.google.com/search?q=what+is+my+ip). |
| 98 | + |
| 99 | + - `.ebextensions/efs-create.config` creates an EFS file system and mount points in each Availability Zone / subnet in your VPC. Identify your default VPC and subnet IDs in the [VPC console](https://console.aws.amazon.com/vpc/home#subnets:filter=default). If you have not used the console before, use the region selector to select the same region that you chose for your environment. |
| 100 | + - `.ebextensions/ssh.config` restricts access to your environment to your IP address to protect it during the WordPress installation process. Replace the placeholder IP address near the top of the file with your public IP address. |
| 101 | + |
| 102 | +## Deploy WordPress to your environment |
| 103 | +Deploy the project code to your Elastic Beanstalk environment. |
| 104 | + |
| 105 | +First, confirm that your environment is `Ready` with `eb status`. Environment creation takes about 15 minutes due to the RDS DB instance provisioning time. |
| 106 | + |
| 107 | +```Shell |
| 108 | +~/wordpress-beanstalk$ eb status |
| 109 | +~/wordpress-beanstalk$ eb deploy |
| 110 | +``` |
| 111 | + |
| 112 | +### NOTE: security configuration |
| 113 | + |
| 114 | +This project includes a configuration file (`loadbalancer-sg.config`) that creates a security group and assigns it to the environment's load balancer, using the IP address that you configured in `ssh.config` to restrict HTTP access on port 80 to connections from your network. Otherwise, an outside party could potentially connect to your site before you have installed WordPress and configured your admin account. |
| 115 | + |
| 116 | +You can [view the related SGs in the EC2 console](https://console.aws.amazon.com/ec2/v2/home#SecurityGroups:search=wordpress-beanstalk). |
| 117 | + |
| 118 | +## Install WordPress |
| 119 | + |
| 120 | +Open your site in a browser. |
| 121 | + |
| 122 | +```Shell |
| 123 | +~/wordpress-beanstalk$ eb open |
| 124 | +``` |
| 125 | + |
| 126 | +You are redirected to the WordPress installation wizard because the site has not been configured yet. |
| 127 | + |
| 128 | +Perform a standard installation. The `wp-config.php` file is already present in the source code and configured to read database connection information from the environment, so you shouldn't be prompted to configure the connection. |
| 129 | + |
| 130 | +Installation takes about a minute to complete. |
| 131 | + |
| 132 | +# Updating keys and salts |
| 133 | + |
| 134 | +The WordPress configuration file `wp-config.php` also reads values for keys and salts from environment properties. Currently, these properties are all set to `test` by the `wordpress.config` configuration file in the `.ebextensions` folder |
| 135 | + |
| 136 | +The hash salt can be any value but shouldn't be stored in source control. Use `eb setenv` to set these properties directly on the environment. |
| 137 | + |
| 138 | + AUTH_KEY, SECURE_AUTH_KEY, LOGGED_IN_KEY, NONCE_KEY, AUTH_SALT, SECURE_AUTH_SALT, NONCE_SALT |
| 139 | + |
| 140 | +```Shell |
| 141 | +~/wordpress-beanstalk$ eb setenv AUTH_KEY=29dl39gksao SECURE_AUTH_KEY=ah24h3drfh LOGGED_IN_KEY=xmf7v0k27d5fj3 ... |
| 142 | +... |
| 143 | +``` |
| 144 | + |
| 145 | +Setting the properties on the environment directly by using the EB CLI or console overrides the values in `wordpress.config`. |
| 146 | + |
| 147 | +Remove the custom load balancer configuration to open the site to the Internet. |
| 148 | + |
| 149 | +```Shell |
| 150 | +~/wordpress-beanstalk$ rm .ebextensions/loadbalancer-sg.config |
| 151 | +~/wordpress-beanstalk$ eb deploy |
| 152 | +``` |
| 153 | + |
| 154 | +Scale up to run the site on multiple instances for high availability. |
| 155 | +```Shell |
| 156 | +~/wordpress-beanstalk$ eb scale 3 |
| 157 | +``` |
| 158 | + |
| 159 | +When the update completes, open the site. |
| 160 | + |
| 161 | +```Shell |
| 162 | +~/wordpress-beanstalk$ eb open |
| 163 | +``` |
| 164 | + |
| 165 | +Refresh the site several times to verify that all instances are reading from the EFS file system. Create posts and upload files to confirm functionality. |
| 166 | + |
| 167 | +# Backup |
| 168 | + |
| 169 | +Now that you've gone through all the trouble of installing your site, you will want to back up the data in RDS and EFS that your site depends on. See the following topics for instructions. |
| 170 | + |
| 171 | + - [DB Instance Backups](http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.BackingUpAndRestoringAmazonRDSInstances.html) |
173 | 172 | - [Back Up an EFS File System](http://docs.aws.amazon.com/efs/latest/ug/efs-backup.html) |
0 commit comments