forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: shiftsrl on November 07, 2010, 09:21:27 pm

Title: Moving the 'Album' directory on another server
Post by: shiftsrl on November 07, 2010, 09:21:27 pm
I've seen something around the forum but heve not fully understood what's the point. I would like to move all the albums directory on another server to offload the main server and save bandwidth.

In my gallery I'm the only user and I'm the only manager of the gallery. I create album and upload pictures. The other users can only see them but registration of new users is disabled. Also I don't use any plugin.

Is it possible to modify som configurations or some files to make this possible? In substance I would like that all the images displayed in the http://www.maindomain.xxx/gallery comes from http://www.imageserver.xxx.

If someone can explain me what to do, supposing it's not too difficult since I'm not a programmer, I can try it...

Thank you very much
Title: Re: Moving the 'Album' directory on another server
Post by: Αndré on November 08, 2010, 04:40:56 pm
I've seen something around the forum but heve not fully understood what's the point
Please post the link. Afaik that's not possible, at least not out of the box. It may be possible with some automatic synchronization (mirroring) and some code adjustments. But that's no pretty solution imo.
Title: Re: Moving the 'Album' directory on another server
Post by: shiftsrl on November 08, 2010, 04:54:49 pm
The link I've seen are about a GSOC version or something like that but I think it's a proposal.

In any case why should I need automatic sync? I would like to upload the images on the CDN and letting coppermine take them from there. Are these modifications too difficult to list here?
Title: Re: Moving the 'Album' directory on another server
Post by: Αndré on November 08, 2010, 05:07:54 pm
I don't know if it's possible to upload files directly to a CDN. The workaround a had in mind is the following. You upload the files regularly to your Coppermine gallery. Images are always included with a relative path like 'albums/userpics/10001/sunset.jpg'. Now we just add your CDN url (by changing Coppermine's code accordingly), resulting in an absolute path like 'http://shiftsrl.superdupercdn.com/albums/userpics/10001/sunset.jpg'. Now you have to sync your albums directory with the directory on the CDN and everything should work as expected. Of course it should be possible to let Coppermine upload the files automatically to the CDN, but that's probably harder to code.
Title: Re: Moving the 'Album' directory on another server
Post by: shiftsrl on November 08, 2010, 05:21:59 pm
Wow, sound fantastic. Now the question is: Where I've to modify the CPC code to include the absolute path to the images? That way I can make CPG serve the images directly from the CDN instead of the local folder.

If you can tell me where to put this absolute path I can test and let you know the results. I think this could be interesting for many people.
Title: Re: Moving the 'Album' directory on another server
Post by: Αndré on November 09, 2010, 11:22:25 am
Please install that (http://coppermine.svn.sourceforge.net/viewvc/coppermine/branches/cpg1.5.x/plugins/absolute_url/?view=tar) plugin (http://documentation.coppermine-gallery.net/en/plugins.htm#plugin_manager) and report if it works.
Title: Re: Moving the 'Album' directory on another server
Post by: shiftsrl on November 09, 2010, 11:45:35 am
Wow thanks!!! How can I configure it? Where can I insert the url of the images?
Title: Re: Moving the 'Album' directory on another server
Post by: Αndré on November 09, 2010, 12:39:00 pm
Lol. Just a small error in reasoning :D

Open codebase.php, find
Code: [Select]
$CONFIG['ecards_more_pic_target']and replace with your CDN path.

Keep in mind that $pic_row['url'] can contain something like
Code: [Select]
albums/test2/test.jpg(= files in your album directory) but also default thumbnails that resides in the images directory like
Code: [Select]
images/thumbs/thumb_pdf.png
So you'll have to mirror at least those 2 directories.
Title: Re: Moving the 'Album' directory on another server
Post by: shiftsrl on November 09, 2010, 01:21:32 pm
There's something I've missed. This is the procedure I've followed

1 - I've created a category and an album inside that category
2 - I've batch added some pictures (locally these resides in albums/samples)
3 - I've mirrored the folder (samples) on the cdn (inside http://www.mycdn.com/images/albums/samples)
4 - I've put in codebase.php the url (that is http://www.mycdn.com/images/)

Browsing the gallery show me all the pictures but checking them I've seen that these are local and not loaded from the cdn. All the thumbs are in the same folder as images as thumb_nomeoftheimage.jpg

I've missed something?
Title: Re: Moving the 'Album' directory on another server
Post by: Αndré on November 09, 2010, 01:22:45 pm
Please post a link to your gallery.
Title: Re: Moving the 'Album' directory on another server
Post by: shiftsrl on November 09, 2010, 01:26:29 pm
In any case I'm sure this one is the right direction to do this. If you want I can give you the url where I've uploaded some images on the cdn to test them...
Title: Re: Moving the 'Album' directory on another server
Post by: Αndré on November 09, 2010, 01:30:01 pm
I don't need the CDN url, but the url of your Coppermine gallery. I want to check if the plugin doesn't work as expected or if you've done something wrong.
Title: Re: Moving the 'Album' directory on another server
Post by: shiftsrl on November 09, 2010, 01:30:38 pm
I'm trying on a local copy oc coppermine. Give me 10 minutes to put is on a test server online and I'll give you the link...
Title: Re: Moving the 'Album' directory on another server
Post by: shiftsrl on November 09, 2010, 01:53:29 pm
Ok let's go. Here's the test gallery url

http://test.shift.it/cpg
Title: Re: Moving the 'Album' directory on another server
Post by: Αndré on November 09, 2010, 01:57:29 pm
http://test.shift.it/cpg
I can see relative paths. Do you have the plugin installed (not just uploaded) on that test gallery?
Title: Re: Moving the 'Album' directory on another server
Post by: shiftsrl on November 09, 2010, 02:04:05 pm
plugin api enabled and plugin installed as you can see from the attached screenshot

Title: Re: Moving the 'Album' directory on another server
Post by: Αndré on November 09, 2010, 02:09:11 pm
Please post the content of the codebase.php file.
Title: Re: Moving the 'Album' directory on another server
Post by: shiftsrl on November 09, 2010, 02:14:59 pm
Here it is

Code: [Select]
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

$thisplugin->add_filter('picture_url', 'absolute_url_picture_url');

function absolute_url_picture_url($pic_row) {
    global $CONFIG;

    $pic_row['url'] = $CONFIG['http://www.shiftcdn.it/kog/'].$pic_row['url'];

    return $pic_row;
}

?>
Title: Re: Moving the 'Album' directory on another server
Post by: Αndré on November 09, 2010, 02:18:42 pm
Change
Code: [Select]
    $pic_row['url'] = $CONFIG['http://www.shiftcdn.it/kog/'].$pic_row['url'];to
Code: [Select]
    $pic_row['url'] = 'http://www.shiftcdn.it/kog/'.$pic_row['url'];
Title: Re: Moving the 'Album' directory on another server
Post by: shiftsrl on November 09, 2010, 02:22:53 pm
Wowowowowowow!!! It works!!!!

That way it's fantastic!Let me double check.

I upload all the images on ly local server
Insert them in CPG so that the normal and thumbs are created
I mirror the images folder just inserted in the CDN

That's all!

It's correct?
Title: Re: Moving the 'Album' directory on another server
Post by: Αndré on November 09, 2010, 02:29:31 pm
I upload all the images on ly local server
Insert them in CPG so that the normal and thumbs are created
I mirror the images folder just inserted in the CDN
That's correct. In an ideal world Coppermine would transfer that files directly to your CDN, but that's more coding effort. Maybe someone extends that plugin with a configuration interface (to enter the CDN http address and ftp data or however you can transfer data to your CDN) and the needed backend code to transfer the files.
Title: Re: Moving the 'Album' directory on another server
Post by: shiftsrl on November 09, 2010, 02:32:20 pm
The other interesting thing is that doing so I've a copy of all my images locally and another copy mirrored so I've a sort of backup...  :)
Title: Re: Moving the 'Album' directory on another server
Post by: shiftsrl on November 09, 2010, 02:33:45 pm
I forgot to thank you very very much for this plugin. Maybe You'll have to publish it since I think would be very interesting also for other members that has the same problem...
Title: Re: Moving the 'Album' directory on another server
Post by: Αndré on November 09, 2010, 02:35:23 pm
Maybe You'll have to publish it since I think would be very interesting also for other members that has the same problem...
Will do soon :)
Title: Re: Moving the 'Album' directory on another server
Post by: Αndré on November 09, 2010, 03:26:13 pm
I just updated the plugin at the svn repository (http://coppermine.svn.sourceforge.net/viewvc/coppermine/branches/cpg1.5.x/plugins/absolute_url/?view=tar). It now has a config screen where you can easily enter your CDN's url. If you verify that it still works for you I'll release an official package.
Title: Re: Moving the 'Album' directory on another server
Post by: shiftsrl on November 09, 2010, 03:32:55 pm
As soon as I've clicked apply changes after inputting the url I've got this error
Title: Re: Moving the 'Album' directory on another server
Post by: Αndré on November 09, 2010, 03:38:10 pm
Please try again by replacing the admin.php file with the latest version (revision 8026).
Title: Re: Moving the 'Album' directory on another server
Post by: shiftsrl on November 09, 2010, 03:49:52 pm
Perfect. Now it work!
Title: Re: Moving the 'Album' directory on another server
Post by: Αndré on November 10, 2010, 04:27:55 pm
Just published the plugin here (http://forum.coppermine-gallery.net/index.php/topic,67980.0.html). I recommend to upgrade to that version, as it checks if the picture resides in the albums/ or images/ directory. So you don't have to sync the images/ directory anymore.

Please post all support requests regarding the plugin to the plugin announcement thread (http://forum.coppermine-gallery.net/index.php/topic,67980.0.html). Thanks.