Multisite is an installation option of G2 to save diskspace and administrative work when installing and upgrading multiple independent G2 installs on the same webserver. Independent means that the multisite G2 installs don't share albums, photos, users, or anything else. They all use their own database and their own storage directory.
codebase - The codebase is the directory with the gallery2 installation files which is several megabytes in size. Only a single codebase is required for an arbitrary number of multisite installations. The codebase must be accessible from the internet. The codebase serves as the central place to install all the multisite installations. If you want to install a new multisite G2, browse to the codebase, run the installer, and choose multisite in the multisite step of the installer.
multisite - A multisite installation is a lightweight G2 installation which depends on the single codebase. A multisite has only 6(7) files (main.php, index.php, embed.php, upgrade/index.php, lib/support/index.php + config.php (, .htaccess)).
A G2 multisite setup has a single codebase installation and an unlimited number of multisites.
Also, compare multisite to the multiroot module.
Before an arbitrary number of multisite G2 installations can be installed, you need to get the gallery2 application and put it on the webserver. This will be the codebase.
The codebase folder ("gallery2" by default) needs to be accessible from the web. The codebase serves all static content (theme.css files, the small icons, the gallery logo, ...) for all multisites. Therefore, it's not sufficient if the codebase is only accessible from the local network, it must be accessible from the web.
Example: You extract the gallery2 application in a folder such that it, the installer is accessible with the URL http://www.example.com/gallery2/install/. The corresponding filesystem path could be something like /var/www/example.com/public_html/gallery2/
Once the codebase is on the webserver and accessible from the web, one can install an unlimited number of multisite installations. The codebase installer serves as the central installation utility for all new multisites.
You want to install a new multisite, whose URL will be http://www.example.com/gallery2/
To start the install process for a new multisite, browse to the codebase installation with a web browser and enter the installer, e.g. browse to http://www.example.com/gallery2/install/.
Pay attention to any settings recommended by the installer, particular the first time using the installer. These settings should apply to the codebase and all multisites. If you make the changes (such as increasing the PHP memory limit) in a .htaccess file in the codebase directory then the installer will report "Pass" even though the setting may not apply to the multisite you are about to install.
In the step for installation type, select the multisite option and enter the filesystem path of the new G2 multisite installation. e.g. /var/www/www.example.com/public_html/ .
The installer needs to create four files (index.php, main.php, embed.php, upgrade/index.php) in this multisite directory. Thus you have two options:
There is also an optional fifth file, lib/support/index.php. The installer will write this file only if possible (if dir is 777 it is always possible; creating files yourself you can choose whether or not to add this one).
Once the installer knows the multisite directory and has write permissions for the files, you can click "Select Directory" to continue. The installer will then generate some code and paste it in the the files such that the multisite knows where the codebase files are.
If you're finished with this step, you can change the filesystem permissions of the files and the multisite directory back to 755 (user has read, write, execute, group and world have read and execute permissions).
WARNING: The files (index.php, main.php, embed.php, upgrade/index.php, lib/support/index.php) in the multisite directory are not the same as the ones with the same name in your codebase. They are much smaller and if you exchange the files with the ones from the codebase, it won't work.
WARNING: Do NOT enter your codebase directory as multisite directory. It would replace the files in the codebase with the much smaller multisite versions of those files and thus, G2 won't work anymore. If you accidentally made that mistake, just replace those files in your codebase again with the ones from the gallery2 application files that you have downloaded.
In the storage setup step, choose a new g2data directory for each multisite. Each multisite needs its own storage directory. In our example, it could be /var/www/e-photos.com/g2data/ .
WARNING: Do NOT choose a storage directory of an existing and running G2 (multisite) installation. If you choose the same storage directory for multiple (multisite) installations, it will destroy the existing other installation.
In the database setup step, choose a new database (or a new table prefix) for each multisite. Each multisite installation needs its own database tables.
WARNING: Do NOT choose the same database configuration for multiple G2 installs. If you choose the same database + table prefix for multiple (multisite) installations, it will destroy the existing installation.
If you have shell access to mysql, log into mysql as the database root user, and then you can probably create a new mysql database with the following command(s):
CREATE DATABASE dbname; GRANT ALL ON dbname.* TO username@'localhost' IDENTIFIED BY 'password'; FLUSH PRIVILEGES;
Obviously replace dbname, username, and password with the appropriate values.
Finish the installation process by completing the remaining installation steps.
Backup early and backup often. And certainly backup before you upgrade.
Follow the normal upgrade instructions to upgrade your codebase (the gallery2/ folder) files.
Note: You don't need to run the upgrade wizard for the codebase. You just need to replace the application files (the gallery2/ folder) with the latest release.
In short: Get the latest code, upload it to the webserver, and unpack it over your existing codebase (or use svn instead to update the code).
Changing Codebase Directory For some it might be desirable to upgrade multisite instances one-by-one against a second codebase. This upgrade approach reduces downtime for other multisite instances. To upgrade against a separate codebase you must edit the galleryBaseUrl value in the multisite's config.php and the edit require paths in embed.php, index.php, main.php, and upgrade/index.php to point to the newer codebase.
WARNING: If you use a PHP accelerator / cache (e.g. Turk mmCache, Ioncube PHPA, eaccelerator, Zend Studio, etc.), flush (clear) the cache of the accelerator. Omitting this step can sometimes lead to errors during and after the upgrade process.
Once the codebase was replaced with the new application files, the upgrade process will start automatically when you browse to one of the multisite installations. You will need to run through the upgrade process for each multisite separately.
An ISP offers G2 to its customers. Each customer has their own domain / home:
URL | Filesystem Path | Storage Directory | Database Connection | |
---|---|---|---|---|
Codebase | www.isp.com/gallery2/ | /home/isp/public_html/gallery2/[complete set of gallery2 application files] | none | no G2 running in the codebase, only used as central installation tool |
Customer / Multisite A | www.foo.com/ | /home/foo/public_html/[index.php, embed.php, main.php, config.php, upgrade/index.php] | /home/foo/g2data/ | database foo_db1 |
Customer / Multisite B | www.bar.com/ | /home/bar/public_html/g2/[index.php, embed.php, main.php, config.php, upgrade/index.php] | /home/bar/gallerydata/ | database bar_gallery2 |
Customer / Multisite C | www.isp.com/~/johndoe/ | /home/johndoe/public_html/[index.php, embed.php, main.php, config.php, upgrade/index.php] | /home/johndoe/public_html/g2data/ | database johndoe |
... | ... | ... | ... | ... |
Note: The codebase does not have to run a live gallery2 application. In this case, it only serves as a central repository for the application files, as the central installation tool, and it serves the static content for the multisites.
You decide to host G2 installations for your friends on your domain:
URL | Filesystem Path | Storage Directory | Database Connection | |
---|---|---|---|---|
Codebase | www.example.com/gallery2/ | /var/www/localhost/htdocs/photos/[complete set of gallery2 application files] | /var/www/localhost/g2data/ | database g2, table prefix g2_ |
Michael's multisite G2 | michael.example.com/ | /var/www/michael/htdocs/[index.php, embed.php, main.php, config.php, upgrade/index.php] | /var/www/michael/mydata/ | database g2mike |
Linda's multisite G2 | www.example.com/~linda/gallery/ | /home/linda/public_html/gallery/[index.php, embed.php, main.php, config.php, upgrade/index.php] | /home/linda/g2data/ | database g2, table prefix lin_ |
... | ... | ... | ... | ... |
Note: Either use different databases for each multisite or use different table prefix. In the end, each multisite needs their own database tables.
Note: In this case, the codebase is also used as a G2 installation. Unlike the multisites, the codebase is an ordinary G2 installation, which just happens to also serve as the installation tool for multisite installations on the same webserver.
Original source of these instructions: http://galleryproject.org/node/35733#comment-130428
Only if you really want to separate your existing g2 from the codebase, i.e. either move the codebase to another directory or move the existing installation to a new directory, only then you need to follow the next steps.
A) Keep installation in the folder where it is, but move the gallery2 files away to a more general directory:
B) Keep the codebase in the folder where it is, but move the existing installation into a new directory:
This is pretty straight forward.
If you have an existing Gallery 1 photo album the first thing to do is to make sure your existing Gallery site has been updated to the last G1 version. http://sourceforge.net/project/showfiles.php?group_id=7130&package_id=7239&release_id=358363
Next thing to do is to setup a Gallery 2 "Standard installation" to act as the main code base for all of your galleries. The instructions are simple and straight forward as the installer does it for you in Gallery 2.
Note that if this installation isn't going to be used for a gallery itself do not install any of the modules. See step 9 below for reason. Once you have a main code base installed be sure to test it by at least creating a single album containing at least 1 photo viewable online. If all is well continue.
Once this is done return the the G2 installer page and rerun it.
IE: your_domain/html/gallery2/install/
At step 3 choose Multisite type and then:
1.) Insert the path to your new gallery. This can be anywhere publicly viewable on the same server.
IE: another_domain/html/gallery
2.) Before you hit next make sure this gallery folder exist and the its permissons are set to 777.
mkdir another_domain/html/gallery chmod 777 another_domain/html/gallery
3.) Go ahead and create the "g2data" folder outside the publicly viewable html folder. in this case it would be 'another_domain/g2data'. Make sure to chmod this to 777 also.
mkdir another_domain/g2data chmod 777 another_domain/g2data
4.) Hit next on the Installer and input the path to the g2data folder you just created and hit next.
5.) In this 5th step of the installer you will input your database connection info.
A note on this. If you're upgrading from Gallery 1.5.1 you will need to create a database for Gallery 2 to use. So do this now if needed. If you're using Gallery 2 already BACK IT UP!
Note: You can have more than one gallery use the same DB. If you do this, you must change the table prefix to avoid conflict.
IE for 'your_domain' you could put "Table Prefix: g2_your_domain_ and then for 'another_domain' you would put "Table Prefix: g2_another_domain_
6-8.) These are simple so just read the on screen instructions.
9.) Select the modules you want installed.
Note that these are independent of the main installation so must be reinstalled for this new "sub" installation. These can be installed, uninstalled, activated, and deactivated later from the gallery admin pages.
10-11.) Are simple so follow and you're finished.
To finish the UPGRADE portion.
Go to your new gallery page.
Log in as admin.
Go to the Import page with link on left hand side. If you do not see this link go to the Modules Control and install and activate this module.
It will ask for the path of your old albums. It will check this path and if AOK will ask you what you want to import from it.
Note that if you have large albums import might fail especially when creating thumbnails due to the memory limits. At least trying to build all my thumbnails in import and through maintainence fails because of this. It's not a big deal because the first time any picture is viewed a thumbnail will be built then.
Import pictures and you're done.
Check to make sure your pictures have uploaded. Once you're satisfied all is well you can remove your old g1 from your server.
Don't sweat it as you already have the albums backed up remember!
Enjoy!
.: Flipc
Certain features are still missing...