Welcome to Geeklog, Anonymous Wednesday, June 19 2024 @ 08:40 am EDT

Geeklog Forums

2 Different Sites...


Status: offline

ola_one

Forum User
Full Member
Registered: 06/28/03
Posts: 186
Okay guys, Just need to know if it is possible to run two different sites with one geeklog installation. I am trying to add virtual hosts to my Apache Configuration, add a new database or so to mysql, but can one control more than one website with one geeklog? Thanks again in advance Ola
 Quote

Status: offline

Euan

Forum User
Full Member
Registered: 04/22/02
Posts: 292
indescribable
You might want to read this. There have been discussions about how it might be done - try searching the forum for \"multiple\" etc.
-- Heather Engineering
-- No job too small
 Quote

Status: offline

gHack

Forum User
Junior
Registered: 12/20/02
Posts: 15
Location:Boulder, CO
I've been running several different sites off of a single geeklog installation for a few months now. There are still a few problems to be worked out, but it basically works pretty well.

Here's the general concept, and I can post more concrete examples if you want.

First of all, you have to separate out the following file and folders for each site:

config.php
backups/
logs/

I keep all these files in a separate folder for each site, which is outside of the folder containing the core files.

You can do it with a single lib-common if you hack it to check which domain you're coming in on and then point it to the appropriate config.php.

I use a different database for each site, but others have posted that you can run several sites from one database by using different table prefixes.

The RDF file for each site needs to have a unique name, or they will overwrite each other. You set this in config.php. You can't separate these files out because they are inside public_html. If you do want to store each of them with the site-specific files, you will have to create a symbolic link to each one inside your backend/ folder.

I limit my users to one theme per site. This lets me create a separate theme for each site and keep them all in the layout/ folder. Again, if you want to store your themes with your other site-specific files, you'll have to create a symbolic link to each one in the layout folder.

In order to further customize each site, I developed a hack that lets me override any function in geeklog through the theme. If I want to override a function for all sites, I do it in lib-custom.

I think that's everything. The only major problem I'm having is that sometimes, a cookie from one site will cause the wrong theme to show up on another site, but I have a feeling somebody here will have a fix for that.

This was all done with 1.3.7. I'm only just starting to experiment with 1.3.8 so I can't say yet what the differences are. Let me know if you want a more detailed explanation.

Cheers,

Chris
 Quote

Status: offline

rawdata

Forum User
Full Member
Registered: 02/17/03
Posts: 236
I think that\'s everything. The only major problem I\'m having is that sometimes, a cookie from one site will cause the wrong theme to show up on another site, but I have a feeling somebody here will have a fix for that.
Cookies are handled differently in 1.3.8. They contain all the parameters now. If you adjust the cookie variables in config.php, I think you should be able to limit them to each of these installs.
 Quote

Status: offline

ola_one

Forum User
Full Member
Registered: 06/28/03
Posts: 186
Thanks guys, But ghack (Chris), I am still a novice, and some of your terminolgies are beyond my comprehension. What is the RDF file, and in looking at the config.php, there is only one database that I can name there. The previous message by Euan says that I should use multiple installations of Geeklog. Yours is saying that you only used one in administering different ones, is that correct, or do you mean that you have multiple installations? If you do not mind, can you tell me exactly where and what I need to do with the config.php file and what else I need to do to get myself set for say 2 or 3 sites. Thanks and I am getting too excited with this program. Ola
 Quote

Status: offline

gHack

Forum User
Junior
Registered: 12/20/02
Posts: 15
Location:Boulder, CO
I have one core geeklog directory, running several sites. A few files have been separated out for each site so that they can be uniquely customized, but on the whole the sites all read the same set of core files in the one folder.

The main advantage of this is that when you make a change to a core file, the change applies to all of your sites, rather than you having to make the same change in each and every instance of geeklog. Much easier to upgrade that way. I'm considering changing this by using CVS and having multiple core geeklog folders instead, but for now I'll show you this way.

I'm going to be setting up a new installation of 1.3.8 as I write this, rather than trying to tell you in detail how I did it with 1.3.7 from memory. I need to upgrade to 1.3.8 anyway so this is the perfect opportunity to document what I'm doing and pass the information on to you at the same time.

----------------------------------

First thing to do is unpack the tarball. I'll call the resulting directory geeklog-1.3.

At the same level as that directory, create dirs for each site, like site1/ site2/ site3/ etc. I'll use these names as examples.

Into each one of these site directories, copy config.php from the geeklog-1.3 directory. Then, in each site directory, create the following subdirectories:

backups/
layout/
logs/

Now, in geeklog-1.3/public_html/layout/ do the following:
ln -s ../../../site1/layout site1
ln -s ../../../site2/layout site2

Repeat for each site. (Whenever I say 'site1', assume that you're supposed to do that step for each site and substitute an appropriate string to designate each site.)

While you're in this directory, copy whichever themes you're going to use for each site into the layout/ directories that you just linked to, i.e. 'cp -rf XSilver site1' and so forth.

Now, in the config.php for each site, you will have to set your db settings, your paths, and your site settings. There are two ways to set up the database(s): if you are using multiple databases, one for each site, set $_DB_name to a different database for each site. If you only have access to or only want to use one database for all of your sites, then set $_DB_table_prefix to a unique string for each site, such as 'site1_gl_', 'site2_gl_', etc.

When you set $_CONF['path'], make sure it points to your geeklog-1.3 directory and not to the separate dirs where the site-specific config.php files reside.

Down in the settings that you don't normally change until after the site is up and running, there are a few you'll want to change:

$_CONF['path_log'] and $_CONF['backup_path'] should point to the locations of your logs/ and backups/ directories for each site, which should be in the same folders as your config.php files.

Set the filename in $_CONF['rdf_file'] to something unique for each site, but make sure it starts with 'backend/'. The RDF is an XML news feed that other sites can read. If you don't set this to a unique name for each site, all your sites will write to the same file.

Set $_CONF['layout_url'] to:
$_CONF['site_url'] . '/layout/site1/' . $_CONF['theme']

and $_CONF['path_themes'] to:
$_CONF['path_html'] . 'layout/site1/'

Further down, you'll need to set $_CONF['cookiedomain'] in order for gl 1.3.8 cookies to work properly. If your site's url is http://www.site1.com:8080/main, for example, you'll want to put '.site1.com' here.

You shouldn't have to change any more settings than this in config.php to get your sites running.


Next, you'll want to edit lib-common.php. Assuming that each of your sites is at www.site1.com, www.site2.com, etc., Edit the line where it says:

require_once( '/path/to/geeklog/config.php' );

to the following:

$config_require_path = '';

switch ($_SERVER['SERVER_NAME']) {
case 'www.site1.com':
$config_require_path = '/path/to/site1/config.php';
break;
case 'www.site2.com':
$config_require_path = '/path/to/site2/config.php';
break;
}

require_once( $config_require_path );


Next, set the permissions on the following folders like so:

chmod -R 775 /path/to/geeklog-1.3/public_html/backend/
chmod -R 775 /path/to/geeklog-1.3/public_html/images/articles/
chmod -R 775 /path/to/geeklog-1.3/public_html/images/userphotos/

chmod -R 775 /path/to/site1/logs/
chmod -R 775 /path/to/site1/backups/

As in the documentation, if your site still gives you errors associated with these folders after you have completed the installation, you can try setting them to 777. Use 775 first, though. And even though backups/ is not mentioned in this part of the documentation, I always find I have to set its permissions in order to use the backup feature.

Finally, you'll want to direct each of your virtual hosts in your apache configuration to your geeklog installation, by setting DocumentRoot to /path/to/geeklog-1.3/public_html and restart Apache.


Now you're ready to start installing. In your geeklog-1.3 directory, do the following:

ln -s ../site1/config.php

Now go to http://www.site1.com/admin/install/install.php and follow the directions. Where it says 'path to geeklog,' use the path to your geeklog-1.3 folder and not the path to where your actual config.php file resides. When you are done with the installation, go back and delete the link to config.php in your geeklog-1.3 folder and create a new one for your next site, then do the next installation, etc. until you have done all of them.

----------------------------

That should be all you need to get several sites up and running using a single core set of files. By following this process since starting this post, I've now got five new sites working using a single database and a single core GL directory.

I won't guarantee that this is bug-free, but it's a good start. This process could also be extended, so you could have separate sets of language files for each site, for example. I only wanted to give you the essentials here so as to avoid confusion.

Other variations include running several sites on a single domain with subdirectories, like www.example.com/site1, www.example.com/site2 etc. If anyone is interested I'll post that variation here as well.

Note that in my earlier post I said that users had to be limited to one theme per site -- while writing this, that problem was worked out, so never mind. Themes are no longer limited to one. The cookie problem also seems to be better with 1.3.8, but I haven't tested it thoroughly yet.

Good luck, and let me know if this works for you.

Chris
 Quote

Status: offline

gHack

Forum User
Junior
Registered: 12/20/02
Posts: 15
Location:Boulder, CO
sleepy
One thing I noticed since doing these installs is that when a user logs in to one of the sites, the images stop working. So I looked through lib-common and config.php and came up with a solution for the problem.

In config.php, the following are set:

$_CONF['theme']
$_CONF['layout_url']
$_CONF['path_layout']

But these get overridden when a user is logged in.

In my previous post, I said to set $CONF['layout_url'] to something like:

$_CONF['site_url'] . '/layout/site1/' . $_CONF['theme']

However, when you have a logged-in user, $_CONF['layout_url'] gets reset in lib-common to:

$_CONF['site_url'] . '/layout/' . $_CONF['theme']

So, what I did was create a new $_CONF variable in config.php and modify lib-common to use the new variable. Like so:

In config.php, right above where $_CONF['layout_url'] is set, add the line:

$_CONF['themes_url'] = $_CONF['site_url'] . '/layout/site1/';

and then change the layout_url line in config.php and the two places where it gets reset in lib-common to:

$_CONF['layout_url'] = $_CONF['themes_url'] . $_CONF['theme'];

And that fixes it. This won't come up in a normal installation unless you've changed the location of your layout folder, but this way makes sure that you can do that without problems.

Chris
 Quote

All times are EDT. The time is now 08:40 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content