WordPress.org

Ready to get started?Download WordPress

Plugin Directory

SitePush

Easily move content and code between WordPress sites. Pull your site's DB to a dev site, push new code to a staging site, etc.

Server Setup

How to setup SitePush in a multiple vhost environment

You can run your separate versions of a site in a single vhost, or in separate vhosts. While running them all in a single vhost can be little easier to set up on some web hosts, it does not work well if different sites need any different configuration in your .htaccess file - for example if you are using a caching plugin.

If you are able to set up separate vhosts (or subdomains as some hosts call them) I recommend you do it that way.

Let's say you want to have three versions of your site - live, test, and dev.

Set up a vhost for each site. Where they all sit on your server will depend on your hosting setup, but let's say they are at:-

/var/www/vhosts/live/httpdocs
/var/www/vhosts/test/httpdocs
/var/www/vhosts/dev/httpdocs

You will need to create a directory to hold all the config files. If at all possible, this directory should not be web accessible. For example, it might be at:-

/var/www/sitepush/config

You will also probably want to create a directory for any backups SitePush makes, such as:-

/var/www/sitepush/backups

Finally, you will need to create a database for each of your sites. Consult the WordPress installation instructions and your web host for how to do this.

Download WordPress and unzip it into one of your sites. I normally keep WordPress in its own subdirectory, for example:-

/var/www/vhosts/live/httpdocs/wordpress

That way, the root directory stays clean, and if I install anything else outside of WordPress, there won't be any confusion of which files belong where. You need to make a couple of changes for this setup to work - see WordPress documentation for more details. Note that for multisite installs, though, you will need to install WordPress in the root directory.

I do, however, put my wp-config.php file in the root directory (WordPress is smart enough to find it).

Next you will need to create the SitePush config files and put them in the config directory you created above. See the SitePush installation instructions for what needs to go in your sites config file and your database config file (I usually call them sites.ini.php and dbs.ini.php).

Now, copy the files from the site you just set up to your other sites, for example:-

cd /var/www/vhosts
cp -r live/httpdocs dev/httpdocs

To save a bit of disk space (at the expense of possibly messing things up between sites), you can also symlink the uploads directory between sites so there is only one copy of any media files uploaded. For example:-

cd /var/www/vhosts/dev/httpdocs/wordpress/wp-content
rmdir uploads
ln -s ../../../../live/httpdocs/wordpress/wp-content/uploads uploads

The exact paths will depend on your setup.

Finally, log into your live site, install, activate and configure SitePush, and now you are set up to easily move files and content between 3 versions of your site!

How to setup SitePush in a single vhost

You can run your separate versions of a site in a single vhost, or in separate vhosts. Depending on your web host, running them all in a single vhost can be bit easier to set up, though it does mean you need to share one .htaccess file across all versions of your site, and won't work for WordPress Multisite setups.

If you are able to set up separate vhosts (or subdomains as some hosts call them) I recommend you do it that way, but if not, these instructions show how you can have multiple version so of your site on one vhost.

Let's say you want to have three versions of your site - live, test, and dev.

First make sure that you can set up domain aliases on your host - so that multiple domains point to the same files. For example, you might set up:-

live.example.com
test.example.com
dev.example.com

If your host allows wildcard domain setups, so for example anything.example.com would point to your files, that would also work

Set up a subdirectory for each site. Where they all sit on your server will depend on your hosting setup, but let's say they are at:-

/var/www/httpdocs/live
/var/www/httpdocs/test
/var/www/httpdocs/dev

You will need to create a directory to hold all the config files. If at all possible, this directory should not be web accessible. For example, it might be at:-

/var/www/sitepush/config

You will also probably want to create a directory for any backups SitePush makes, such as:-

/var/www/sitepush/backups

Download WordPress and unzip it into one of the directories for your sites. For example:-

/var/www/httpdocs/live

Follow the instructions for more installing WordPress in a subdirectory.

You should also now create a database for each of your sites. Consult the WordPress installation instructions and your web host for how to do this.

Complete any other required configuration (WordPress setup, plugin installs etc) and make sure that your site is now working properly. Don't forget to install SitePush!

Next you need to create the SitePush config files and put them in the config directory you created above. See here readme.txt or the SitePush installation instructions for what needs to go in your sites config file and your database config file (I usually call them sites.ini.php and dbs.ini.php).

Now, copy the files from the site you just set up to your other sites, for example:-

cd /var/www/httpdocs
cp -r live dev
cp -r live test

To save a bit of disk space (at the expense of possibly messing things up between sites), you can also symlink the uploads directory between sites so there is only one copy of any media files uploaded. For example:-

cd /var/www/httpdocs/dev/wp-content
rmdir uploads
ln -s ../../live/wp-content/uploads uploads

The exact paths will depend on your setup.

Next you need to make some changes to your wp-config.php file so that it will point to the correct site files and database depending on what domain name was used. The exact details will vary depending on your setup, but you will want something like this, which should be inserted immediately above the line /* That's all, stop editing! Happy blogging. */:-

switch ( $_SERVER['SERVER_NAME'] ) {
    case 'test.example.com':
        $site_dir='test';
        define('DB_NAME', 'database_name_here');
        define('DB_USER', 'username_here');
        define('DB_PASSWORD', 'password_here');
        break;

    case 'dev.example.com':
        define('DB_NAME', 'database_name_here');
        define('DB_USER', 'username_here');
        define('DB_PASSWORD', 'password_here');
        $site_dir='dev';
        break;

    case 'www.example.com':
    case 'live.example.com':
    default:
        define('DB_NAME', 'database_name_here');
        define('DB_USER', 'username_here');
        define('DB_PASSWORD', 'password_here');
        $site_dir='live';
        break;
}

Insert whatever constant definitions are specific to a site in that section, and delete or comment them out from their original location in wp-config.

Lastly, you need to edit the last line of wp-config so it reads:-

require("./{$site_dir}/wp-blog-header.php");

You can now log into your live site, activate and configure SitePush. Once that is done, you can push everything to your other sites and you should now be able to access all three versions of your site. You are now set up to easily move files and content between 3 versions of your site!

Requires: 3.3.1 or higher
Compatible up to: 3.6.1
Last Updated: 2013-9-9
Downloads: 5,342

Ratings

5 stars
5 out of 5 stars

Support

1 of 3 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 100,1,1
100,1,1 100,1,1
100,1,1 100,1,1
100,1,1
100,1,1
100,1,1
100,1,1