We have an interest in setting up a test site where we can play with the setup of a new site creating dummy data and the like without contaminating the real site. For this purpose I have created a subdomain for the site domain and pointed it to its own directory. Now, presumably I need a database to go with it. It has been quite a while since I set up a new database, but the instructions I find all seem to relate to starting from scratch. Is it possible to copy the existing site database to use for this test? Ideally, I would make fresh copies as we progressed with the setup to give us a fresh base. The DBs are MySQL.

Comments

WorldFallz’s picture

You basically have to export/dump your prod db then import it for use with your test site. This is a very common scenario, for some more detailed documentation see:

tamhas’s picture

Great sources, thanks!

tamhas’s picture

Closer, but not there. A bit of background. From this account we are running both D6 and D7 sites. The D6 sites are not easily moved to D7 because they depend on tablemanager, which is not supported in D7. So, I have a D6 Drupal installation at bin/Drupal-6.37 and a D7 installation at bin/Drupal-7.41. In the directory where the site directories are located, one up from this, each site direction is linked to the appropriate Drupal installation. E.g., the site crimefiction.org (the new one we are just starting) is mapped to the crimefiction directory and than is a symbolic link to bin/Drupal-7.41. So, created a subdomain cftest, published than in the DNS, and in the WestHost setup pointed it to a cftest directory which is also a symbolic link to bin/Drupal-7.41. Then, I created a new mysql database cftest and used the commands here https://www.drupal.org/creating-drupal-test-sites to replicated the crimefiction database into cftest. So far, so good.

Now, if I go to cftest.crimefiction.org I get the same page I do at crimefiction.org saying that the site is undergoing maintenance and providing a login. Looks good. But, if I enter the administrator user name and password, I get:

Not Found

The requested URL /user/1 was not found on this server.

So, obviously, I am missing something.

Sam Moore’s picture

Maybe Clean URLs is broken.
Did you install .htaccess in the docroot of crimefiction.org?

Try crimefiction.org/?q=/user/1

tamhas’s picture

Assuming that you meant http://cftest.crimefiction.org/?q=/user/1 ... yes, that works.

The .htaccess for both crimefiction.org and cftest.crimefiction.org is the one in bin/drupal-7.41, i.e., the default that comes with the Drupal release since crimefiction.org points at www/crimefiction and cftest.crimefiction.org points at www/cftest and both of those are symbolic links to www/bin/drupal-7.41.

I see that there is a section on Rewrite Rules which relates to things like www.crimefiction.org vs plain crimefiction.org which is suggestive, but I don't see any clear direction there on what changes one might have to support a subdomain.

Sam Moore’s picture

Assuming that you meant http://cftest.crimefiction.org/?q=/user/1 ... yes, that works.

So if http://cftest.crimefiction.org/?q=/user/1 works but http://cftest.crimefiction.org/user/1 doesn't, this is indicative of a problem with Clean URLs (not to say that there aren't other problems).
For Clean URLs to work, you need mod_rewrite to be functioning properly. There's a long thread about various issues around this here: https://www.drupal.org/getting-started/clean-urls

Also make sure you have FollowSymLinks or SymLinksIfOwnerMatch turned on in your .htaccess.

As for subdomains - there are a couple of ways to do this. Are you wanting the various domains to be on one codebase? If so you'll want to look at multisite configuration.
If not, then just tell your web server where the docroot is for each domain (in Apache this is done via Virtual Hosts)

tamhas’s picture

Yes, the goal is one codebase for all D7 sites, just like we have one codebase for all D6 sites. In D6, the sites are unrelated so they have different themes and modules turned on, but still one codebase. But, we need a separate DB since one of the goals of the test site is to experiment with dummy data that would not have to be then deleted from the real site.

tamhas’s picture

I will check out your link, but note that the short form works on all sites *except* cftest.crimefiction.org, so the issue is something specific to subdomains. And, since there is one codebase for all D7 sites, I need to solve it in the context of that common code, not by something separate, unless it is under sites (see below).

tamhas’s picture

I have just noticed that bin/drupal-7.41/sites has no subdirectories specific to either crimefiction.org or cftest.crimefiction.org in the way that bin/drupal-6.37/sites has a subdirectory for each site running on Drupal 6. I am guessing that I need to figure out how to do some setup there so that it will point to the right databases and such.

drm’s picture

The settings.php file for each site controls which database it uses. You can edit this file on the server to change or update the name of the database, and the database user/password (not site login user/password) if they are different.

tamhas’s picture

OK, I now have the multi-site files structure under sites. Is there any easy way to verify that, when I go to the subdomain that I am actually using the alternate database?

tamhas’s picture

Well, I have spent a few days at this ... including a couple where my internet was gone altogether, which limits one's actions ... and the hosting site seems unwilling to help with the .htaccess setup and much of what I have found is very old, and thus suspect for current configurations and/or does not deal with the setup I have here, i.e., common codebase, domain and subdomain, and two separate directories at the same level.

Does anyone have a current believable reference on this?