如何通过另一GCP实例的cPanel管控独立Bitnami WordPress后端?
Hey there, let's walk through exactly how to link your Bitnami WordPress instance and cPanel instance on GCP so you can manage every part of WordPress—files, database, emails, you name it—right from cPanel. I've broken this down into actionable, step-by-step sections to make it easy to follow:
Before diving in, make sure you have these bases covered:
- Both instances are in the same GCP VPC network (or VPC peering is configured) so they can communicate privately (way safer than using public IPs).
- Jot down key details:
- Bitnami WordPress instance's internal IP, database credentials (find these in
/home/bitnami/bitnami_credentials), and core file path (usually/opt/bitnami/wordpress). - cPanel instance's internal IP and primary user account name.
- Bitnami WordPress instance's internal IP, database credentials (find these in
- Install basic tools on both instances:
rsync, MySQL client, and (for file mounting)nfs-utils(CentOS/RHEL) ornfs-common(Ubuntu/Debian).
You have two solid options here—pick the one that fits your workflow:
Option A: NFS Mount (Real-Time Access)
This lets you edit WordPress files directly from cPanel's File Manager with no sync delays.
- On your Bitnami instance:
- Install the NFS server:
sudo apt update && sudo apt install nfs-kernel-server - Edit
/etc/exportsto share the WordPress directory, replacing[CPANEL-INTERNAL-IP]with your cPanel instance's internal IP:/opt/bitnami/wordpress [CPANEL-INTERNAL-IP]/24(rw,sync,no_subtree_check,no_root_squash) - Restart the NFS service to apply changes:
sudo systemctl restart nfs-kernel-server
- Install the NFS server:
- On your cPanel instance:
- Create a mount point in your cPanel user's directory (replace
[CPANEL-USER]with your actual user):sudo mkdir /home/[CPANEL-USER]/public_html/wp-managed - Mount the remote Bitnami directory:
sudo mount [BITNAMI-INTERNAL-IP]:/opt/bitnami/wordpress /home/[CPANEL-USER]/public_html/wp-managed - To make the mount permanent (survives reboots), add this line to
/etc/fstab:[BITNAMI-INTERNAL-IP]:/opt/bitnami/wordpress /home/[CPANEL-USER]/public_html/wp-managed nfs defaults 0 0
- Create a mount point in your cPanel user's directory (replace
Option B: Rsync Sync (Scheduled Updates)
If real-time access isn't critical, use scheduled syncs to mirror WordPress files to cPanel:
- Set up SSH key-based authentication between cPanel and Bitnami so syncs run automatically:
- Generate keys on cPanel, then add the public key to Bitnami's
~/.ssh/authorized_keysfile.
- Generate keys on cPanel, then add the public key to Bitnami's
- Create a cron job in cPanel (under Cron Jobs) to sync files on your preferred schedule (this example runs daily at 2 AM):
0 2 * * * rsync -avz bitnami@[BITNAMI-INTERNAL-IP]:/opt/bitnami/wordpress/ /home/[CPANEL-USER]/public_html/wp-synced/
To manage your WordPress database from cPanel's phpMyAdmin:
- On your Bitnami instance:
- Edit
/opt/bitnami/mysql/my.cnfand changebind-addressto0.0.0.0(or restrict it to your cPanel internal IP for extra security). - Restart MySQL:
sudo /opt/bitnami/ctlscript.sh restart mysql - Log into MySQL and grant cPanel access to your WordPress database (replace placeholders with your details):
mysql -u root -p # Enter your Bitnami root DB password from bitnami_credentials GRANT ALL PRIVILEGES ON wordpress.* TO 'wp-admin'@'[CPANEL-INTERNAL-IP]' IDENTIFIED BY '[YOUR-STRONG-PASSWORD]'; FLUSH PRIVILEGES; EXIT;
- Edit
- On your cPanel instance:
- Open phpMyAdmin and click Add Server.
- Enter your Bitnami instance's internal IP, the
wp-adminusername, and the password you set. You'll now have full access to manage the WordPress database directly from cPanel.
To handle WordPress emails through cPanel:
- Option 1: Route WordPress emails through cPanel's mail server
Edit your Bitnami WordPresswp-config.php(in/opt/bitnami/wordpress) to add SMTP settings pointing to cPanel:
Now all WordPress-generated emails will go through your cPanel mail server, and you can manage inboxes/forwarding from cPanel's Email Accounts.define( 'WP_MAIL_FROM', 'your-name@yourdomain.com' ); define( 'WP_MAIL_FROM_NAME', 'Your Brand Name' ); define( 'SMTP_HOST', '[CPANEL-INTERNAL-IP]' ); define( 'SMTP_PORT', 587 ); define( 'SMTP_USER', 'your-name@yourdomain.com' ); define( 'SMTP_PASS', '[YOUR-CPANEL-EMAIL-PASSWORD]' ); define( 'SMTP_SECURE', 'tls' ); - Option 2: Migrate existing Bitnami emails to cPanel
Usersyncto copy Bitnami's mail directory (usually/opt/bitnami/mail) to your cPanel user's mail directory (/home/[CPANEL-USER]/mail), then create matching email accounts in cPanel to access them.
- Test file edits: Modify a theme file from cPanel's File Manager and refresh your WordPress site to confirm changes show up.
- Test database edits: Update your site title via cPanel's phpMyAdmin and verify the change on your site.
- Lock down security:
- Only use internal IPs for NFS and database access (avoid public IP exposure).
- Set strong passwords for all database and email accounts.
- Enable automatic updates for both instances and cPanel.
- Regularly back up both instances using GCP snapshots or cPanel's backup tool.
内容的提问来源于stack exchange,提问作者Ernest M.

