Problem: Configure wordpress to use a remote mysql database only available using and SSH tunneling.
Stage:
I have a wordpress instance over an apache server on machine (called WP_server). WP_server, does not have Mysql server and has blocked port except 80 (http) and 22 (ssh).
In other place is another machine (Mysql_server) which has a MySQL instance. This server can provide a database to WP_server.
These two server have ssh access.
How should I configure wordpress to use ssh tunneling?
You should create a ssh tunnel between the 2 serves. Then you can connect from the WP with only the mysql server ip.
The
-f
tells ssh to go into the background just before it executes the command.This is followed by the username and server you are logging into.
The
-L 2000:personal-server.com:25
is in the form of-L local-port:host:remote-port
.Finally the
-N
instructs OpenSSH to not execute a command on the remote system.via Revsys
You can use a custom DB handler in wordpress. Extend the wpdb class located in
wp-includes/wpdb.php
file, and modify things to fit your needs. Be sure to create an instance called$wpdb
at the very end of it.Then, drop the file in
wp-content/db.php
. It will be used in place of the wpdb class.