Make Gallery look the same on your lan and the internet

JoeyJoeJo

Joined: 2005-07-29
Posts: 9
Posted: Tue, 2005-12-20 03:38

Having Gallery look the same on both the internet and on my lan is something that I've been having trouble with for some time now. It would look great outside of my lan, but inside it would look crappy. But I finally figured out how to fix that. It's kind of a hack, but heck, it works. So here it is in all it's goodness for anyone else having the same problem. If this has been covered before and I'm just now figuring it out, feel free to call me a moron. BTW, I'm not sure if this is the right forum for this post, so I'm sorry if it's not.

Gallery Installer Portion
Step 1. Make sure your Gallery is set up correctly and can be viewed online.

Step 2. Make a new dir in the same dir where your current Gallery multisite is installed (I only have a multisite, so I don't know if it'll work on a regular one)

Step 3. Start an installation of a new Gallery that will be stored in this dir.

Step 4. When you get to the step that asks you about where your data will be stored, just make the empty dir like it says, and continue on.

Step 5. Use the same Database name and prefixes as your working one. Don't click on save yet. (I don't think this will cause problems with DB inconsistancy, but I'd like someone with more knowledge to confirm or deny that)

Step 6. Go to the g2data folder you created in this how-to's step 4. Delete it (it should be empty) and do a symbolic link to the g2data folder of the working site. (ln -s /path/to/g2data)

Step 7. I forget exactly what the Gallery installer will say, but a link will come up and say that it found a database that isn't empty and some data to go along with it. There is a link to delete the data and start over, and one to use the existing data. Make sure to use existing data!

Step 8. Finish the installer

Apache Portion
Step 9. Now edit your apache vhosts file. Make a new vhost with a servername of your server's lan IP address and a document root pointing to the install you just made.

Step 10. Restart apache and in your browser, go to your webserver's local IP address. It should look the same as if you were browsing it online.

 
JoeyJoeJo

Joined: 2005-07-29
Posts: 9
Posted: Tue, 2005-12-20 03:42

I forgot to add a step. After step 8 of the gallery portion, go to the dir you just installed your new multisite to. Symbolic link to the gallery codebase folder here (ln -s /path/to/gallery/codebase). Sorry about that.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-12-20 09:18

i guess i know where you're coming from. your problem was the url generation.

G2 uses php's $_SERVER[HTTP_HOST] to get the domain name which it uses for all URLs.
and php gets HTTP_HOST from the webserver, in apache that's the HostName.
and without vHosts, you can't set the HostName to 2 different values (private LAN address, internet domain) at the same time.

but you could have hacked a .htaccess together and changed modules/core/classes/GalleryUrlGenerator.class function getCurrentDomain() to return the appropriate value.

vHosts are a solution, true, but probably, you could have achieved it with less work.

on a last note:
please add this as a link in codex.gallery2.org -> howto

 
JoeyJoeJo

Joined: 2005-07-29
Posts: 9
Posted: Tue, 2005-12-20 12:09

Yeah, I'd have done the htaccess method, but honestly I don't know much about how it works.

 
no0dle

Joined: 2005-10-08
Posts: 4
Posted: Sat, 2005-12-24 11:25

I don't really see the problem, or why it doesn't work for you. I'm using Gallery2 on my server too, and it looks the same from inside and outside the LAN. Maybe you have to turn off the canonical hostname feature in Apache, in order for the server and Gallery to always use the address you typed in your browser's address field. Another possibility is to edit your hosts file, insert the internet name of your server and map it to the IP address in your local network.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-12-24 13:19

good ideas :)
maybe add a how to links in codex.gallery2.org -> how to. thanks!