Love is the best guide to chose right from wrong
Advertise on this site  
Read and enjoy hundreds of helpful earlier posts by categories:
My Love Love Secrets of Love Help Internet SEO Linux admin Funny jokes Fun Kriya Yoga Christmas Editors pick
Philippines Cambodia Business solutions Alternate lifestyle Life and death Politics and God Chat
Deutschsprachige Posts zu folgenden Kategorien:
Liebe Weihnachten Reisen
Anteriores artículos de blog en español:
Dios y amor
Google
 

[Linux admin]Received Sun, 28 Dec 2008 04:54:42 PHT

Gallery2 howto move to new server: A quick and easy method to move entire gallery2 install from server to server - gallery2 move the easy way using rsync !

How can you move a complete gallery2 installation from old server to new server?

  • First the full good news: Its easy and simple.
  • The bad news: There are none at all - if you are root on new server and webMASTER
  • The details: My method has been tested and proven perfect during my recent gallery2 move.
  • The requirements: You have a dedicated server at least at the new location and SSH access on old location and new location.

Next move I do, I most likely will skip the IP test-run of gallery2 mentioned below and just move all as outlined below and restart all on new server. That way an entire website move including gallery2 can be made in just a few minutes for a few GB site size. Without interruption on old server nor on new server.

The historical background of this gallery2 server move howto

Sometimes summer 2006 I had to move my gallery2 without time to prepare backup, etc as outlined in details on gallery2 forum and FAQ pages. That was far more than just a nightmare. It was the by very far greatest software nightmare I experienced in my entire old life!

Half a year later my previous host move my entire site 3 times to different machines. My resource usage was too high, thanks to gallery2 mainly - too much traffic :). Yet, however they did it, the server move happened without my knowledge and without breaking the gallery ! Hence I knew that there must be a method totally different from the ones posted on gallery2 forum!

I moved to new own dedicated server late 2006 and again it took a long while to have all working again because I did it the official way, with backup, etc.

These past Christmas days I expanded from my original dedicated server to my new setup of dedicated servers. I had already more than a months time to think about, search Google and test the move. My new servers are already ready to play and learn since a month or more. I just wanted to learn and understand a full server move under full HIGH traffic - HIGH being around a million hits per day or more. I planned NO downtime of any kind for any cause! Now the server move is successfully finished and you can see the gallery install and enjoy some of the most beautiful photos from the Philippine islands on my new server.

Preparations I made before gallery2 server move

First and above all, to make a really easy server move without ANY - and I mean zero - additional configurations on new or old location before or after server move:

  1. I created the exactly same file structure on new location. ALL server paths are identical, all users for apache, etc are identical, all permissions and group / users or all files and folders are absolutely identical on new server!
  2. I had SuSE Linux 10.1 on old server, LAMP of that time, including PHP 5, MySQL, apache2.2.
  3. I installed openSUSE Linux 11.0 on new server, full LAMP and all additional software I had to run gallery2 as well. Software like ImageMagick, etc depending on your modules and requirements. Just ALL software in the newest updated versions have been ready and tested on new server before moving.

Now some of the truly magic Linux admin stuff - Howto move MySQL completely to a new server

Moving a complete server - if you are owner of old as well as new dedicated server is even more easy because:

I use rsync !. rsync is default in typical Linux distributions and on default LAMP servers. man rsync will show you comprehensive examples how to use if you are new to rsync.

My rsync command line with all options I need / use therefore is:

rsync -axv --progress --stats

I shut down old server for just a minute or 2 to rsync ALL - I mean the entire
/var/lib/mysql
from old to new in a single command line. That magic rsync moves / copies ALL your MySQL databases, including the actual server admin db, postfix db, etc - including ALL passwords for all MySQL stuff you have on old server!

To do all that without rsync, you would have to recreate all db and then import the data. That may take a while and may result in errors.

Using rsync -axv --progress --stats to move ALL

/var/lib/mysql

May be done in 1 minute or 2 if both servers are on the same server farm and you have full speed between the 2 servers.

To stop MySQL on BOTH sides is essential to fully assure integrity of all data copied between the 2 servers. It takes but shortest time but completely avoids any and every risk of having damaged data when copying all /var/lib/mysql on running system with ever changing data.

That entire /var/lib/mysql move can be done hours before the actual server move and seconds before server move you make a full backup of active MySQL db to restore on new server after server move done.

Now we have the gallery2 db and the rest is as simple. rsync -axv --progress --stats ALL website, including all folders, preserving all paths and folders/sub/folders from old to new server.

  • There is NO need to deactivate your gallery2!
  • You can do that part on fully runing site!
  • There is NO need to go in maintenance mode with your gallery!

If you are new to rsync - here some very basics. Rsync runs/works on file system and NOT across apache, hence mod_rewrite has NO affect on your folders, files, file names or paths what so ever !!! Your rsync'd files are exactly identical on new location. Your mod_rewrite file on new server works like a charm from very beginning. No need to deactivate or recreate.

Provided

Your domain name also remains identical. Else there is ONE line in your .htaccess to modify before running gallery2 properly on new server.

Now your gallery2 is rsync'd on new server. But of course your new server runs in IP and NOT YET on your domain name. Immediately after moving all files to new server, you can surf all pages but see NO images, yet if you have module eCards installed you already can send eCards, hence images are there - hidden - because your new gallery2 is on IP ...

Now we change that for a real test run to fully enjoy and savor our gallery22 server move! I did - looking back at the nightmare years ago, looking at the MANY gallery2 I saw broken / down even months after move.

I simply assume you know where your gallery install has its own root folder on your site. The folder apache serves as root for all gallery2 folders. Lets assume yoursite.com/gallery2/

Let's assume your entire site is at server path

/srv/www/myhome/

Hence your gallery2 would be at

/srv/www/myhome/gallery2/

That is the place where you find your gallery2 .htaccess, created BY gallery2 when installing mod_rewrite module for your gallery, with the miracle of mod_rewrite code that looks like a huge secret to me. But it works!

I use SSH to access my servers, and vi as editor to do minor server configs - hence you open your gallery22 .htaccess at your path adapted according to below example:

vi /srv/www/myhome/gallery2/.htaccess

There you see among many others, a group of lines relevant to your won site-name. These are the only mod_rewrite lines that contain your site-name. At least on my gallery2 install.

RewriteCond %{QUERY_STRING} view=core.DownloadItem
RewriteCond %{HTTP_REFERER} !://www.yoursite.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule . /gallery2/index.php? [F,L]

To run gallery2 on new server while new server is on IP, you replace your above line:

RewriteCond %{HTTP_REFERER} !://www.yoursite.com/ [NC]

and replace above www.yoursite.com by your IP

Hence it looks like:

RewriteCond %{QUERY_STRING} view=core.DownloadItem
RewriteCond %{HTTP_REFERER} !://111.222.333.444/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule . /gallery2/index.php? [F,L]

With 111.222.333.444 being your IP!!

That's all. Now you firefox your gallery2 on your new server's IP and all URLs and other functions work - they instantly did on my new server. Nothing else needed. All passwords are there, all admin stuff works, all modules work, all images and thumbnails are there.

Surf a while, then replace above ONE line of .htaccess again back to yoursite.com !

A word of caution surfing your site on IP

If you completed all your apache2 and PHP install on new server, and an attempt to surf ANY page results in forbidden or similar error . normally 403 = forbidden. Then you have some apache server security features active. Like mod_rewrite or snort, etc. Or an automatic rewrite of yoursite.com to www.rewrite.com in your server root level .htaccess.

Such are standard security features that may need to be temporarily deactivated before surfing ANY part of your site on your new server. If however you have ALL URLs as absolute URL - i.e. http://www.yoursite.com/myfiles.html - then you can NOT click any link, else you automatically move to your REAL ( old site ). If however you have some flat files / HTML-files like I have, OR any gallery2 files - they all have relative paths and can be surfed / moved on any site, including IP based as long as you deactivate your security features that prevent IP based surfing.

Example if you have mod_rewrite installed, then you have to rename / change file extension of your mod_rewrite module to deactivate, then restart apache to activate the new server configuration. If you have snort installed, simple shut down snort daemon.

After all above successfully done and tested on IP, you' reconfigured your above .htaccess - reactivate all temporarily modified security deactivation. Then it's time to test all else and make the final NS entry changes on your parent nameservers to welcome all your traffic on your new server.

A last point about server move using rsync

I use rsync -axv --progress --stats to move ALL my files, all backups and the entire restore or server moves. Hence all my 5 perl based forum, eCards ( also perl ) etc. All moved with rsync, all apparently working fine without any problems. Provided: All paths identical, all filesystem identical, Operating system identical, major software versions identical, etc. As root on a dedicated server you simply CREATE the environment you need and want to make your life easy.

As a general rule: If it worked before move and done correctly to the point, then it also will work after move.

Love and Bliss

hans

Home

Kriya Yoga, God and Love = Cyberspace Ashram

Internet Blogs - Blog Top Sites Religion blogs Internet Blogs Blog Submission Blog Top List Love