3

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?

1
  • 1
    First of all this is not a programming question. However, your question is a bit incomplete, too. If you have a tunnel established and running, what does WordPress (or any other application for that matter) have to care about? Commented May 17, 2011 at 0:56

2 Answers 2

4

You should create a ssh tunnel between the 2 serves. Then you can connect from the WP with only the mysql server ip.

ssh -f [email protected] -L 2000:personal-server.com:25 -N

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

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.