如何在Google App Engine上安装MyBB?指定路径部署PHP论坛
/forums Path Hey there! I’ve helped a few folks set up MyBB on GAE before, so let’s walk through getting yours deployed to https://plains.cc/forums/index.php step by step—no jargon, just actionable steps.
1. Pre-Requisites First
- Make sure your local GAE PHP project is already set up and manageable (whether you’re using the
gcloudCLI or Cloud Shell, either works) - Grab the latest MyBB zip package, unzip it to your local working directory
- Double-check that your GAE project has the PHP runtime enabled (PHP 7.4+ is recommended—MyBB plays nice with newer versions)
2. Tweak Your Project Directory Structure
Since you want the forum at /forums, you’ll need to nest all MyBB files inside a forums folder in your GAE project root. Your structure should look like this:
your-gae-project-root/ ├── app.yaml ├── forums/ │ ├── uploads/ │ ├── inc/ │ ├── index.php │ └── all other MyBB files/folders...
Heads up: MyBB’s
uploadsandcachefolders need write access, but GAE’s local filesystem is read-only. We’ll fix this later with Cloud Storage.
3. Configure app.yaml (Critical Step!)
This file tells GAE how to handle requests. Update it to route /forums traffic to your MyBB files, and set up the PHP runtime. Here’s a working example:
runtime: php74 service: default handlers: # Handle PHP/HTML/TXT files in /forums - url: /forums/(.*\.(php|html|htm|txt))$ script: forums/\1 # Serve static assets (images, CSS, JS) from /forums with caching - url: /forums/(.*\.(gif|png|jpg|css|js|ico))$ static_files: forums/\1 upload: forums/(.*\.(gif|png|jpg|css|js|ico))$ expiration: "30d" # If you have an existing app at the root, keep this handler; if not, you can remove it - url: /.* script: index.php
4. Fix MyBB’s Read-Write Directories
GAE doesn’t let apps write to the local filesystem, so we’ll map uploads and cache to Google Cloud Storage:
- Head to the Google Cloud Console and create a Cloud Storage bucket (something like
plains-cc-mybb-storageworks) - After installing MyBB (we’ll do that next), edit
forums/inc/config.php:- Update
$config['uploadspath']to your bucket’s upload path:gs://plains-cc-mybb-storage/uploads/ - Set up cloud storage for caching:
$config['cache_store'] = 'cloudstorage'; $config['cloudstorage_bucket'] = 'plains-cc-mybb-storage'; $config['cloudstorage_cache_path'] = 'cache/';
- Update
- Make sure your GAE service account has Storage Object Admin permissions (add this role in the IAM section of Cloud Console)
5. Run the MyBB Installation Wizard
- Start the local GAE dev server with
gcloud app run - Navigate to
http://localhost:8080/forums/install/index.phpand follow the wizard:- For the database, use Google Cloud SQL (MySQL is best) — plug in your Cloud SQL connection details (host, username, password, database name)
- Set the Board URL to
https://plains.cc/forums/ - Create your admin account as prompted
- Important: After installation finishes, delete the
forums/installfolder immediately—this locks down your forum and prevents re-install attempts.
6. Deploy to Production
- Double-check all local configs work as expected
- Run
gcloud app deployto push your project to GAE - Once deployment completes, hit
https://plains.cc/forums/index.php—your MyBB forum should be live!
7. Quick Post-Deployment Tips
- Enable MyBB’s built-in caching to pair with Cloud Storage for faster load times
- Turn on GAE’s CDN to speed up static asset delivery
- Set up regular backups for your Cloud SQL database and Cloud Storage bucket
- Install MyBB’s security plugins to keep your forum safe from common threats
内容的提问来源于stack exchange,提问作者PLAINS

