├── .gitmodules ├── README.md ├── app.yaml ├── appengine-php-wordpress-starter-project_build_linux_mac.zip ├── appengine-php-wordpress-starter-project_windows.zip ├── cron.yaml ├── databasesetup.sql ├── move_files_after_editing.bat ├── move_files_after_editing.sh ├── php.ini └── wp-config.php /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "appengine-wordpress-plugin"] 2 | path = appengine-wordpress-plugin 3 | url = https://github.com/GoogleCloudPlatform/appengine-wordpress-plugin.git 4 | [submodule "batcache"] 5 | path = batcache 6 | url = https://github.com/Automattic/batcache.git 7 | [submodule "wp-memcache"] 8 | path = wp-memcache 9 | url = https://github.com/jeremyfelt/Memcached-Object-Cache.git 10 | [submodule "wordpress"] 11 | path = wordpress 12 | url = https://github.com/WordPress/WordPress.git 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![status: inactive](https://img.shields.io/badge/status-inactive-red.svg) 2 | 3 | This project is no longer actively developed or maintained. 4 | 5 | For new work on this check out [A helper command for running WordPress on Google Cloud Platform](https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/appengine/wordpress) 6 | 7 | # WordPress on App Engine Starter Project 8 | 9 | ***Note: This repo is essentially the "source" of the starter projects, allowing you to browse our code, suggest changes, etc. We provide already-built-and-zipped WordPress projects for Windows, Mac, and Linux at [Quick Start WordPress for Google App Engine](http://googlecloudplatform.github.io/appengine-php-wordpress-starter-project/).*** 10 | 11 | ## Prerequisites 12 | 13 | 1. Install the [PHP SDK for Google App Engine](https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_PHP) 14 | 2. Install [MySQL](http://dev.mysql.com/downloads/) 15 | 3. [Sign up](http://cloud.google.com/console) for a Google Cloud Platform project, and 16 | set up a Cloud SQL instance, as described [here](https://cloud.google.com/sql/docs/getting-started#create), and a 17 | Cloud Storage bucket, as described [here](https://developers.google.com/storage/docs/signup). You'll want to name 18 | 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. 19 | 4. Visit your project in the 20 | [Google Cloud Console](http://cloud.google.com/console), going to the App Engine section's **Application Settings** 21 | area, and make a note of the **Service Account Name** for your application, which has an e-mail address 22 | (e.g. `@appspot.gserviceaccount.com`). Then, visit the Cloud Storage section of your project, 23 | select the checkbox next to the bucket you created in step 3, click 24 | **Bucket Permissions**, and add your Service Account Name as a **User** account that has **Writer** permission. 25 | 26 | ## Cloning and setup 27 | 28 | ### Step 1: Clone 29 | 30 | Clone this git repo and its submodules by running the following commands: 31 | 32 | git clone --recursive https://github.com/GoogleCloudPlatform/appengine-php-wordpress-starter-project.git 33 | cd appengine-php-wordpress-starter-project/ 34 | 35 | You now have a copy of [WordPress](http://wordpress.org/), the 36 | [App Engine plugin for WordPress](http://wordpress.org/plugins/google-app-engine/), 37 | [Batcache](http://wordpress.org/plugins/batcache/), and 38 | [Memcached Object Cache](http://wordpress.org/plugins/memcached/). 39 | 40 | ### Step 2: Edit the config files 41 | 42 | Edit `wp-config.php` and `app.yaml`, replacing `your-project-id` 43 | to match the Project ID (not the name) that was assigned to your 44 | Google Cloud Platform project. 45 | 46 | ### Step 3: Move files into place: 47 | 48 | Because of GitHub and licensing limitations, we can't put these files in the right places for you. 49 | 50 | Run this script to move all the files into place: 51 | 52 | move_files_after_editing.sh 53 | 54 | This script: 55 | 56 | 1. Moves `wp-config.php` from root into `wordpress/`, replacing the file there. 57 | 2. Moves `batcache/advanced-cache.php` to `wordpress/wp-content/` 58 | 3. Moves `batcache/batcache.php` to `wordpress/wp-content/plugins/` 59 | 4. Moves `wp-memcache/object-cache.php` to `wordpress/wp-content/` 60 | 5. Moves the contents of `appengine-wordpress-plugin/` to `wordpress/wp-content/plugins/` 61 | 62 | ## Running WordPress locally 63 | 64 | >First, edit [wp-config.php](https://github.com/GoogleCloudPlatform/appengine-php-wordpress-starter-project/edit/master/wp-config.php) 65 | so that the local environment password for root is not literally the string "password" -- unless that's what you used 66 | when setting up MySQL locally. 67 | 68 | Using MySQL's command line version, run `databasesetup.sql` to set up your local database. For a default installation (no root password) 69 | this would be: 70 | 71 | mysql -u root < databasesetup.sql 72 | 73 | But really, all it's doing is running this line -- the WordPress installation script will do the heavy lifting 74 | when it comes to setting up your database. 75 | 76 | CREATE DATABASE IF NOT EXISTS wordpress_db; 77 | 78 | To run WordPress locally on Windows and OS X, you can use the 79 | [Launcher](https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_PHP) 80 | by going to **File > Add Existing Project** or you can run one of the commands below. 81 | 82 | On Mac and Windows, the default is to use the PHP binaries bundled with the SDK: 83 | 84 | $ APP_ENGINE_SDK_PATH/dev_appserver.py path_to_this_directory 85 | 86 | On Linux, or to use your own PHP binaries, use: 87 | 88 | $ APP_ENGINE_SDK_PATH/dev_appserver.py --php_executable_path=PHP_CGI_EXECUTABLE_PATH path_to_this_directory 89 | 90 | Now, with App Engine running locally, visit `http://localhost:8080/wp-admin/install.php` in your browser and run 91 | the setup process, changing the port number from 8080 if you aren't using the default. 92 | Or, to install directly from the local root URL, define `WP_SITEURL` in your `wp-config.php`, e.g.: 93 | 94 | define( 'WP_SITEURL', 'http://localhost:8080/'); 95 | 96 | You should be able to log in, and confirm that your app is ready to deploy. 97 | 98 | ### Deploy! 99 | 100 | If all looks good, you can upload your application using the Launcher or by using this command: 101 | 102 | $ APP_ENGINE_SDK_PATH/appcfg.py update APPLICATION_DIRECTORY 103 | 104 | Just like you had to do with the local database, you'll need to set up the Cloud SQL instance. The SDK includes 105 | a tool for doing just that: 106 | 107 | google_sql.py :wordpress 108 | 109 | This launches a browser window that authorizes the `google_sql.py` tool to connect to your Cloud SQL instance. 110 | After clicking **Accept**, you can return to the command prompt, which has entered into the SQL command tool 111 | and is now connected to your instance. Next to `sql>`, enter this command: 112 | 113 | CREATE DATABASE IF NOT EXISTS wordpress_db; 114 | 115 | You should see that it inserted 1 row of data creating the database. You can now type `exit` -- we're done here. 116 | 117 | Now, just like you did when WordPress was running locally, you'll need to run the install script by visiting: 118 | 119 | http://.appspot.com/wp-admin/install.php 120 | 121 | Or, to install directly from the root URL, you can define WP_SITEURL in your `wp-config.php`, e.g.: 122 | 123 | define( 'WP_SITEURL', 'http://.appspot.com/'); 124 | 125 | ### Activating the plugins, configuring email, and hooking up WordPress to your Cloud Storage 126 | 127 | **The following steps should be performed on your hosted copy of WordPress on App Engine** 128 | 129 | #### Activating the plugins 130 | 131 | Now, we just need to activate the plugins that were packaged with your app. Log into the WordPress 132 | administration section of your blog at `http://.appspot.com/wp-admin`, and visit the 133 | Plugins section. Click the links to activate **Batcache Manager** and **Google App Engine for WordPress**. 134 | 135 | #### Configuring email and hooking WordPress up to your Cloud Storage 136 | 137 | Now visit **Settings > App Engine**. Enable the App Engine mail service - this will use the App Engine Mail 138 | API to send notifications from WordPress. Optionally, enter a valid e-mail address that mail should be sent 139 | from (if you leave this blank, the plugin will determine a default address to use). The address of the account 140 | you used to the create the Cloud Console project should work. 141 | 142 | Stay on this page, because in order to be able to embed images and other multimedia in your WordPress content, 143 | you need to enter the name of the Cloud Storage bucket you created when going through all the Prequisites earlier 144 | under **Upload Settings**. 145 | 146 | Hit **Save Changes** to commit everything. 147 | 148 | ## That's all! (PHEW) 149 | 150 | Congratulations! You should now have a blog that loads rapidly, caches elegantly, 151 | sends email properly, and can support adding images and other media to blog posts! Most importantly, 152 | it will take advantage of Google's incredibly powerful infrastructure and scale gracefully to 153 | accomodate traffic that is hitting your blog. 154 | 155 | ### Maintaining 156 | 157 | You'll want to keep your local copy of the application handy because that's how you install other plugins and update 158 | the ones that are packaged with this project. Due to the tight security of the 159 | App Engine sandbox, you can't directly write to files in the application area -- they're static. That's 160 | also why we hooked your uploads up to Cloud Storage. So, to install plugins, you log into the admin area 161 | of your local WordPress instance, install or update any plugins you want there, and 162 | redeploy. Then go into the admin area for your hosted WordPress instance to activate the plugins. 163 | -------------------------------------------------------------------------------- /app.yaml: -------------------------------------------------------------------------------- 1 | application: your-project-id 2 | version: wpfromstarterproject 3 | runtime: php55 4 | api_version: 1 5 | 6 | handlers: 7 | - url: /(.*\.(htm|html|css|js))$ 8 | static_files: wordpress/\1 9 | upload: wordpress/.*\.(htm|html|css|js)$ 10 | application_readable: true 11 | 12 | - url: /wp-content/(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$ 13 | static_files: wordpress/wp-content/\1 14 | upload: wordpress/wp-content/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$ 15 | application_readable: true 16 | 17 | - url: /(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$ 18 | static_files: wordpress/\1 19 | upload: wordpress/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$ 20 | application_readable: true 21 | 22 | - url: /wp-includes/images/media/(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$ 23 | static_files: wordpress/wp-includes/images/media/\1 24 | upload: wordpress/wp-includes/images/media/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$ 25 | application_readable: true 26 | 27 | - url: /wp-admin/(.+) 28 | script: wordpress/wp-admin/\1 29 | secure: always 30 | 31 | - url: /wp-admin/ 32 | script: wordpress/wp-admin/index.php 33 | secure: always 34 | 35 | - url: /wp-login.php 36 | script: wordpress/wp-login.php 37 | secure: always 38 | 39 | - url: /wp-cron.php 40 | script: wordpress/wp-cron.php 41 | login: admin 42 | 43 | - url: /xmlrpc.php 44 | script: wordpress/xmlrpc.php 45 | 46 | - url: /wp-(.+).php 47 | script: wordpress/wp-\1.php 48 | 49 | - url: /(.+)?/? 50 | script: wordpress/index.php 51 | 52 | skip_files: 53 | - ^(.*/)?\.zip$ 54 | - ^(.*/)?\.bat$ 55 | - ^(.*/)?\.sh$ 56 | - ^(.*/)?\.md$ 57 | -------------------------------------------------------------------------------- /appengine-php-wordpress-starter-project_build_linux_mac.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/appengine-php-wordpress-starter-project/8314ade7ac6b2f616eec36b5420eb850cb561ac8/appengine-php-wordpress-starter-project_build_linux_mac.zip -------------------------------------------------------------------------------- /appengine-php-wordpress-starter-project_windows.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/appengine-php-wordpress-starter-project/8314ade7ac6b2f616eec36b5420eb850cb561ac8/appengine-php-wordpress-starter-project_windows.zip -------------------------------------------------------------------------------- /cron.yaml: -------------------------------------------------------------------------------- 1 | cron: 2 | - description: wordpress cron tasks 3 | url: /wp-cron.php 4 | schedule: every 15 minutes -------------------------------------------------------------------------------- /databasesetup.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS wordpress_db; 2 | -------------------------------------------------------------------------------- /move_files_after_editing.bat: -------------------------------------------------------------------------------- 1 | move wp-config.php wordpress\ 2 | move batcache\advanced-cache.php wordpress\wp-content\ 3 | move batcache\batcache.php wordpress\wp-content\plugins\ 4 | move wp-memcache\object-cache.php wordpress\wp-content\ 5 | xcopy /s/Y appengine-wordpress-plugin wordpress\wp-content\plugins\ 6 | rmdir /s/q batcache\ 7 | rmdir /s/q wp-memcache\ 8 | rmdir /s/q appengine-wordpress-plugin\ 9 | -------------------------------------------------------------------------------- /move_files_after_editing.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # move_files_after_editing.sh 4 | # 5 | # 6 | # Created by John Mulhausen on 10/17/13. 7 | # 8 | cp -fr wp-config.php wordpress/ 9 | cp -fr batcache/advanced-cache.php wordpress/wp-content/ 10 | cp -fr batcache/batcache.php wordpress/wp-content/plugins/ 11 | cp -fr wp-memcache/object-cache.php wordpress/wp-content/ 12 | cp -fr appengine-wordpress-plugin/. wordpress/wp-content/plugins/ 13 | rm -rf batcache/ 14 | rm -rf wp-memcache/ 15 | rm -rf appengine-wordpress-plugin/ 16 | -------------------------------------------------------------------------------- /php.ini: -------------------------------------------------------------------------------- 1 | google_app_engine.enable_functions = "php_sapi_name, gc_enabled" 2 | allow_url_include = "1" 3 | upload_max_filesize = 8M 4 | 5 | ; enable downloading files for localhost 6 | google_app_engine.disable_readonly_filesystem = 1 7 | -------------------------------------------------------------------------------- /wp-config.php: -------------------------------------------------------------------------------- 1 | 0, 110 | 'max_age'=>30*60, // 30 minutes 111 | 'debug'=>false 112 | ]; 113 | /* That's all, stop editing! Happy blogging. */ 114 | 115 | /** Absolute path to the WordPress directory. */ 116 | if ( !defined('ABSPATH') ) 117 | define('ABSPATH', dirname(__FILE__) . '/wordpress/'); 118 | 119 | /** Sets up WordPress vars and included files. */ 120 | require_once(ABSPATH . 'wp-settings.php'); 121 | 122 | 123 | --------------------------------------------------------------------------------