Drupal: best practice to switch site domain after the project is over
Im running a Drupal Multisite environment on a lamp (debian, apache, php, mysql) server.
My current workflow for a new project is:
- Activate a subdomain on my company site (let's say the project will be foo.com, i activate foo.example.com)
- Becose of plesk (that's a bit drupal unfriendly) my step are:
- Create the new subdomain in plesk, php running in fastcgi mode
- Create the database
- Delete h开发者_如何学Cttpdocs folder, recreate it and make the sites folder
- Make a simbolic link to every file into
/var/www/vhosts/drupal
folder (drupal code base) excapt of sites and tmp folders, robots.txt and .htacces files (that usually will be customized per domain) - Make the folder
foo.example.com
insidesites
, symbolic link to/var/www/vhosts/drupal/sites/all
folder, and then back a symbolic link fromsites/foo.com
to/var/www/vhosts/drupal/sites/foo.example.com
(in order to make drush see all the domains to some multisite tasks, like crontab)
- Install, configure drupal in the subdomain, doing everythings needed to complete the project
At this point, i need to switch the project from the subdomain to the final domain, foo.com, that will reside o my server too.
I dont like much some kind of other hacks like domain redirects, i want the final project to be a 'clean' (for what clean mean in a multisite environment).
Actually i do those steps:
- Creating the domain (via plesk) and database;
- Copy the subdomain httpdocs to the full domain httpdocs (
cp -a /var/www/vhosts/example.com/subdomains/foo/httpdocs /var/www/vhosts/foo.com/httpdocs
) - Change owner and group of httpdocs to match the domain's owner and group
- Login into drupal, change webiste info, and filesystem paths.
This let me do what i want, but i have some trouble with node's html contents; espacially for those that contain links, images, and files, that (even if IMCE is configurated to use relative path), will point to /sites/foo.example.com/files/[...]
instead of /sites/foo.com/files/[...]
.. this happen for cck filefields too.
As i said, i need a clean solution, i know i could make a symbolic link from /sites/foo.example.com
to /sites/foo.com
but i really dont like this way.
So far, i tryed to search/replace all the occourrence into the database sql dump:
sed 's/foo.example.com/foo.com/g' dump.sql > foo.com.sql
But this seem to brake somethings; I get many errors in boostrap file (in the cache unserialize step, even if i cleared all the cache before and after the db export/import) and looks like some utf-8 encoding get broken.
I know the best deal will be to set the development area on a local server, but i need my customer to reach it from outside.. and our adsl situation (static IP and so on) is a bit wired.
Any idea?
p.s: sorry for my bad english, if my question is not clear enought let me know and i'll provide more details)
Your steps are basically what I do, but I am not using Plesk or doing a multisite installation. I just create a new vhost in a VPS instance, and cp -a the docroot, and reconfigure for a new database DSN.
Regarding the SQL problems, I typically edit the SQL dump in a UTF-8 clean editor to prevent that problem. On Windows, I use Notepad++.
I then restore the database, clean all caches, edit settings, and run cron. I will also typically rebuild the search index.
This sequence normally works.
The bootstrap problem likely has to do with the variables table. When you serialize a string (or something with an string), the length gets stored, too. I will do the search and replace, then open up MySQL Query Browser, and search for rows in variable table with the domain name, and fix the lengths by hand. The other option is to determine which option is being stored, and then recreate the setting.
精彩评论