Skip to content

Commit a64e03c

Browse files
committed
W00t, easier appengine
0 parents  commit a64e03c

File tree

12 files changed

+2153
-0
lines changed

12 files changed

+2153
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
public.built/
2+
vendor/

README.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Simple WordPress on App Engine Starter Project
2+
3+
***Note: This repo is a fork of the Google WordPress for AppEngine starter project that is way too painful for them to maintian. This project ensures you always have the lastest versions of plugins, and makes the entire process of updating and installing plugins for AppEngine painless. From your pals at Redux. ;)
4+
5+
## Prerequisites
6+
7+
1. Install [PHP Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx)
8+
2. Install [Google's Cloud SDK (gcloud)](https://cloud.google.com/sdk/) command prompt utility.
9+
3. Install the [PHP SDK for Google App Engine](https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_PHP)
10+
```
11+
$ gcloud components list
12+
# Find the gcloud app PHP Extensions in the list
13+
$ gcloud components install app-engine-php-*
14+
```
15+
4. Install [MySQL](http://dev.mysql.com/downloads/)
16+
17+
5. [Sign up](http://cloud.google.com/console) for a Google Cloud Platform project, and
18+
set up a Cloud SQL instance, as described [here](https://cloud.google.com/sql/docs/getting-started#create), and a
19+
Cloud Storage bucket, as described [here](https://developers.google.com/storage/docs/signup). You'll want to name
20+
your Cloud SQL instance "wordpress" to match the config files provided here. To keep costs down, we suggest signing up for a D0 instance with package billing.
21+
6. Visit your project in the
22+
[Google Cloud Console](http://cloud.google.com/console), going to the App Engine section's **Application Settings**
23+
area, and make a note of the **Service Account Name** for your application, which has an e-mail address
24+
(e.g. `<PROJECT_ID>@appspot.gserviceaccount.com`). Then, visit the Cloud Storage section of your project,
25+
select the checkbox next to the bucket you created in step 3, click
26+
**Bucket Permissions**, and add your Service Account Name as a **User** account that has **Writer** permission.
27+
28+
## Getting Started
29+
30+
### Step 1: Clone
31+
32+
Clone this git repo:
33+
```
34+
$ git clone https://github.com/reduxframework/appengine-wordpress
35+
```
36+
37+
### Step 2: Run composer install
38+
39+
40+
```
41+
$ php composer install
42+
```
43+
44+
This will grab all of the plugins/repos defined install them properly. It will also build your `public.built` directory.
45+
46+
**Note, if you are a PC/Windows user, you MUST use the following command, and only edit `composer.windows.json` to your needs.**
47+
48+
```
49+
$ php composer require composer.win.json
50+
```
51+
52+
### Step 2: Edit public/wp-config.php
53+
54+
Edit `public/wp-config.php` primarily the `DB_HOST` declaration for cloud-sql. Also be sure to update the section labeled `Authentication Unique Keys and Salts`.
55+
56+
## Running WordPress locally
57+
58+
>First, edit `public/wp-config.php` to have all the correct database login information.
59+
60+
**If you're using MAMP locally on MacOS, there are instructions in `public/wp-config.php`. Search for MAMP (two places).**
61+
62+
On Mac and Windows, the default is to use the PHP binaries bundled with the SDK:
63+
64+
$ APP_ENGINE_SDK_PATH/dev_appserver.py path_to_this_directory
65+
66+
On Linux, or to use your own PHP binaries, use:
67+
68+
$ APP_ENGINE_SDK_PATH/dev_appserver.py --php_executable_path=PHP_CGI_EXECUTABLE_PATH path_to_this_directory
69+
70+
Now, with App Engine running locally, visit `http://localhost:8080/wp-admin/install.php` in your browser and run
71+
the setup process, changing the port number from 8080 if you aren't using the default.
72+
Or, to install directly from the local root URL, define `WP_SITEURL` in your `wp-config.php`, e.g.:
73+
74+
define( 'WP_SITEURL', 'http://localhost:8080/');
75+
76+
You should be able to log in, and confirm that your app is ready to deploy.
77+
78+
### Deploy!
79+
80+
If all looks good, you can upload your application using the Launcher or by using this command:
81+
82+
$ APP_ENGINE_SDK_PATH/appcfg.py update APPLICATION_DIRECTORY
83+
84+
Just like you had to do with the local database, you'll need to set up the Cloud SQL instance. The SDK includes
85+
a tool for doing just that:
86+
87+
google_sql.py <PROJECT_ID>:wordpress
88+
89+
This launches a browser window that authorizes the `google_sql.py` tool to connect to your Cloud SQL instance.
90+
After clicking **Accept**, you can return to the command prompt, which has entered into the SQL command tool
91+
and is now connected to your instance. Next to `sql>`, enter this command:
92+
93+
CREATE DATABASE IF NOT EXISTS wordpress_db;
94+
95+
You should see that it inserted 1 row of data creating the database. You can now type `exit` -- we're done here.
96+
97+
Now, just like you did when WordPress was running locally, you'll need to run the install script by visiting:
98+
99+
http://<PROJECT_ID>.appspot.com/wp-admin/install.php
100+
101+
Or, to install directly from the root URL, you can define WP_SITEURL in your `wp-config.php`, e.g.:
102+
103+
define( 'WP_SITEURL', 'http://<YOUR_PROJECT_ID>.appspot.com/');
104+
105+
### Activating the plugins, configuring email, and hooking up WordPress to your Cloud Storage
106+
107+
**The following steps should be performed on your hosted copy of WordPress on App Engine**
108+
109+
#### Activating the plugins
110+
111+
Now, we just need to activate the plugins that were packaged with your app. Log into the WordPress
112+
administration section of your blog at `http://<PROJECT_ID>.appspot.com/wp-admin`, and visit the
113+
Plugins section. Click the links to activate **Batcache Manager** and **Google App Engine for WordPress**.
114+
115+
#### Configuring email and hooking WordPress up to your Cloud Storage
116+
117+
Now visit **Settings > App Engine**. Enable the App Engine mail service - this will use the App Engine Mail
118+
API to send notifications from WordPress. Optionally, enter a valid e-mail address that mail should be sent
119+
from (if you leave this blank, the plugin will determine a default address to use). The address of the account
120+
you used to the create the Cloud Console project should work.
121+
122+
Stay on this page, because in order to be able to embed images and other multimedia in your WordPress content,
123+
you need to enter the name of the Cloud Storage bucket you created when going through all the Prequisites earlier
124+
under **Upload Settings**.
125+
126+
Hit **Save Changes** to commit everything.
127+
128+
## That's all! (PHEW)
129+
130+
Congratulations! You should now have a blog that loads rapidly, caches elegantly,
131+
sends email properly, and can support adding images and other media to blog posts! Most importantly,
132+
it will take advantage of Google's incredibly powerful infrastructure and scale gracefully to
133+
accomodate traffic that is hitting your blog.
134+
135+
### Maintaining
136+
137+
You'll want to keep your local copy of the application handy because that's how you install other plugins and update
138+
the ones that are packaged with this project. Due to the tight security of the
139+
App Engine sandbox, you can't directly write to files in the application area -- they're static. That's
140+
also why we hooked your uploads up to Cloud Storage. So, to install plugins, you log into the admin area
141+
of your local WordPress instance, install or update any plugins you want there, and
142+
redeploy. Then go into the admin area for your hosted WordPress instance to activate the plugins.
143+

app.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
runtime: php55
2+
api_version: 1
3+
4+
handlers:
5+
- url: /(.*\.(htm|html|css|js))$
6+
static_files: public.built/\1
7+
upload: public.built/.*\.(htm|html|css|js)$
8+
application_readable: true
9+
10+
- url: /wp-content/(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$
11+
static_files: public.built/wp-content/\1
12+
upload: public.built/wp-content/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$
13+
application_readable: true
14+
15+
- url: /(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$
16+
static_files: public.built/\1
17+
upload: public.built/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$
18+
application_readable: true
19+
20+
- url: /wp-includes/images/media/(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$
21+
static_files: public.built/wp-includes/images/media/\1
22+
upload: public.built/wp-includes/images/media/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$
23+
application_readable: true
24+
25+
- url: /wp-admin/(.+)
26+
script: public.built/wp-admin/\1
27+
secure: always
28+
29+
- url: /wp-admin/
30+
script: public.built/wp-admin/index.php
31+
secure: always
32+
33+
- url: /wp-login.php
34+
script: public.built/wp-login.php
35+
secure: always
36+
37+
- url: /wp-cron.php
38+
script: public.built/wp-cron.php
39+
login: admin
40+
41+
- url: /xmlrpc.php
42+
script: public.built/xmlrpc.php
43+
44+
- url: /wp-(.+).php
45+
script: public.built/wp-\1.php
46+
47+
- url: /(.+)?/?
48+
script: public.built/index.php
49+
50+
skip_files:
51+
- ^(.*/)?\.zip$
52+
- ^(.*/)?\.bat$
53+
- ^(.*/)?\.sh$
54+
- ^(.*/)?\.md$

composer.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"require": {
3+
"johnpbloch/wordpress": "*",
4+
"wpackagist-plugin/batcache": "*",
5+
"wpackagist-plugin/memcached": "*",
6+
"wpackagist-plugin/google-app-engine":"*"
7+
},
8+
"require-dev": {
9+
"wp-cli/wp-cli": "^0.24.1"
10+
},
11+
"repositories": [
12+
{
13+
"type":"composer",
14+
"url":"https://wpackagist.org"
15+
}
16+
],
17+
"extra": {
18+
"installer-paths": {
19+
"public.built/wp-content/mu-plugins/{$name}/": ["type:wordpress-muplugins"],
20+
"public.built/wp-content/plugins/{$name}/": ["type:wordpress-plugin"],
21+
"public.built/wp-content/themes/{$name}/": ["type:wordpress-theme"]
22+
}
23+
},
24+
"scripts": {
25+
"post-install-cmd": [
26+
"cp -R wordpress/* public.built/ && rm -fr wordpress",
27+
"cp -R public/* public.built/",
28+
"mv public.built/wp-content/plugins/batcache/advanced-cache.php public.built/wp-content/"
29+
],
30+
"post-update-cmd": [
31+
"cp -R wordpress/* public.built/ && rm -fr wordpress",
32+
"cp -R public/* public.built/"
33+
]
34+
}
35+
}

0 commit comments

Comments
 (0)