I currently have a website with DocumentRoot set to /var/www (running Apache2.24 on Ubuntu 6). I just downloaded and set up Drupal 6.9 on /var/www/mynewsite. I'd like to get that configured, migrate old content, and test the site, before going live (and deactivate the old site on /var/www).

Could someone outline for me how I should go about doing that? I saw I could/should create a new virtual site in Apache, but how do I do that so that I can easily make the new site go live when it's ready? (And just turn off the old site). Should I set up a virtual website on another port, say 8080? And later switch it to the default port 80?

One possible problem is that when you first set up Drupal, you access an installation page. I think whatever URL you use at the time gets hardcoded into the site. So, if I just use mydomain.com/mynewsite, Drupal will always remember that as my site's URL. Is that correct? Is there a way to modify that later?

Thanks.

Comments

cog.rusty’s picture

You can add a virtual host in Apache's httpd.conf with ServerName newsite.example.com and DocumentRoot /var/www/newsite for the new site. After restarting Apache, that should be accessible at http://newsite.example.com. No need to use a different port, that would be awkward because you would always have to type it in your browser for no good reason.

Then you can
- copy all Drupal files from www to www/newsite. Make sure that the .htaccess file has been copied (on some systems cp -R doesn't copy files with a front dot).
- create a database and a database user for the new site and load a backup of the existing database in it
- enter the new database info in the new site's settings.php file, in the $db_url line.

That should be all. It is a good idea to clear all cache tables and the sessions, watchdog, and search tables in the database before taking the backup.

It is not generally true that the old site's URL is hardcoded, but watch out for the following:
- If you have specified a $base_url in the settings.php file, you can easily change it in the new site, or even better comment it out to disable it.
- In the admin/settings/file-system page, if you have set your uploads directory to sites/example.com/files, which contains a domain name, then you have a problem and you will need to change it, for example to sites/default/files or files/a-common-site-alias, and then to fix the existing file path entries in the database. If the files path doesn't contain a domain name, then it is fine.
- If you have explicitly entered full URLs in the content, which contain the old domain, you may need to edit them or to fix them in the database (in the node_revisions table).

If you need to fix the database, you can either use phpmyadmin to search and replace the old domain name everywhere, or you can open the database backup with a text editor and search/replace the old domain name everywhere before uploading the database.

drupal92037’s picture

Thanks!!!

drupal92037’s picture

I'm having trouble setting up a virtual host for my draft website (because the machine I'm working on is a virtual machine which itself is actually a subdomain of a regular domain, and I'm having trouble configuring a new subdomain on it).

Anyhow -- if I just keep drupal running in a sub-directory, like this:
http://example.com/newsite
will that pose any problems when I'm ready to make it 'live'?

Thx.

cog.rusty’s picture

There is only one possible problem. If you are using clean URLs (without ?q=) then the directory path "/newsite" will need to be included in any file/image links that you insert in the content, and then it will be difficult to move the site to a domain which doesn't have that directory path. It may take some "search and replace".

Other than that, a subdirectory is fine.

drupal92037’s picture

Thanks again.

Can I enable clean URL's after the newsite goes live, and retroactively switch over some of the URL's into clean URLs? Or do clean URL's have to be made in when content is created?

I just read up about clean URL's and I think I'm confusing them with URL aliases. It looks enabling clean URL's just means I get rid of the '?q=' query string. I would still get long URL's with meaningless words in them, like:
mysite.com/node/540234

What I wanted was the ability to organize my website using URL's that make sense to human readers, like:
mysite.com/aboutus/history

Do I understand this correctly?

Thanks.

cog.rusty’s picture

You can enable/disable clean URLs any time you want. Nothing is stored differently in the database when you use clean URLs, except whatever you have entered differently in the content yourself.

There is no other problem except the way you must refer to file links which you enter in the content: File links which are domain-relative, absolute URL paths (with a front slash) work in both cases.

Actually, if clean URL support is configured correctly, you can use either kind of URLs manually if you want. "Enabling" clean URLs in Drupal means simply that Drupal will be using them in all menu links.