On this page
How To Set Up The Gallery2 Codebase On An ISPConfig Server
Author: <hans [at] bb-hosting [dot] org>
Gallery2 is a web based software product that lets you manage your photos on your own website. With this guide, I show you how to setup the CODEBASE for Gallery2.
How you can setup a multisite for Gallery2 is written in a separate Howto: "Howto setup a Gallery2 multisite on an ISPConfig server".
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.
The primary advantage of multisites over normal G2 installations is saving the disk space that is required for each gallery2 folder (50-100 MB depending on the cluster size of the HDD partition). Only a single real gallery2 folder is required (codebase), multisites only use a few kilobytes per installation (plus the photos that they contain).
You only have to upgrade a single codebase. Once the codebase is replaced with a new G2 version, just visit the multisites and each multisite will automatically start it's upgrade process. Each multisite has to be upgraded independently, but you have to replace the underlying codebase only once.
The multisite installations don't share users, album/photos, or anything else from the user's point of view. Multisites are completely separate and share only the same codebase.
In this how to, I will use just as an example:
- Gallery2 version 2.1.2
- Website for Gallery codebase: http://gallery.hostingcompany.tld/
- Website for Gallery multisite: http://www.mywebsite.tld/gallery/
- Web for Gallery2 codebase: web1
- MySQL database: web1_db1
- MySQL username: web1_u1
- The used Linux distribution is Debian
Create a website for the Gallery2 codebase:
In ISPConfig, create a website via “New site” in the main menu.
On the tab called “Basis” use gallery for the hostname and hostingcompany.tld for the domain name. Enable MySQL and PHP scripts for this website but disable PHP Safe Mode.
Create a Administator user for the website:
In ISPConfig, create an Administrator user, so you can upload/download the website later via FTP:
In the main menu select “ISP Manager”, select your new website called gallery.myhostingcompany.tld in the structure tree and press the tab “User and Email”. Press “new” and define a new user and its email address. Give this user administrator rights and press “Save”.
Create a MySQL database for the website:
Click on the tab called “Options” and create a new database for the website.
ISPConfig will show you:
Database name: web1_db1
Database user: web1_u1
Database password: mypassword
Then you define a password for the database user and press “Save”.
Download/extract the packages and remove the tar.gz files: Logon to your server as root and navigate to the web for gallery:
Download the latest stable version of Gallery2, which is version 2.1.2 at this moment:
(At this point choose your nearest download location at Sourceforge).
Unpack the downloaded files:
tar xvfz gallery-2.1.2-typical.tar.gz
Remove the tar.gz files:
Remove the default index.html page:
Move the gallery2 contents to the web directory and delete the empty directory:
mv * ../
Create a storage directory:
Create a directory for gallery to store photos. This must be writeable by the web server:
chown -R www-data:www-data g2data
The Gallery 2 installer program (codebase):
Next thing to do is to setup a Gallery 2 "Standard installation" to act as the main codebase 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.
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.
Now you can point to your Gallery2 site with your favourite browser. The (example) URL according my how to is: http://gallery.myhostingcompany.tld
If you visit your URL, you’ll be forwarded to http://gallery.myhostingcompany.tld/install/ where you will see the Gallery2 setup screen.
Now, you can easily follow the instructions. Choose your language and click on “Begin Installation>>”.
After clicking “Begin Installation>>”, you arrive at the installer screen. On this screen a random authentication number is shown. (It will be shown in the red area).
In /var/www/web1/web, create an empty file called: login.txt
Paste the random authentication number into it.
Save and close your textfile and proceed the setup for Gallery2 in your browser again.
Click on “Authenticate Me”. When Authentication is successful, click on “Continue to Step 2»”.
With step 2 within the Gallery2 installer, the required system settings are verified. When the system check is ok, click “Continue to Step 3»”.
At step 3 of the Gallery2 installer, choose your installation type. As we do an installation for the Gallery2 codebase, we choose for a standard installation.
Proceed by clicking “Continue to Step 4>>”.
Step 4 within the Gallery2 installer, guides you to set the right permissions for the g2data folder. However, we did this already, so simply press “Save”.
The next screen confirms that we have successfully setup the storage directory for Gallery2. Press “Continue to step 5 >>” to setup your database.
Step 5 within the Gallery2 installer, guides you to set up your database correctly.
To setup your database, please enter:
- MySQL databasename, which is web1_db1 in our example.
- MySQL user password
- MySQL username
After entering the required information, press “Save”.
If you’ve successfully setup the Gallery2 database, this will be confirmed. Press “Continue to step 6>>”.
Step 6 within the Gallery2 installer, is a form to define the administrator of Gallery2. Fill in the form and finally press “Create”.
If the Administrator for Gallery2 has been setup successfully, this will be confirmed. Press “Continue to step 7>>”.
Step 7 within the Gallery2 installer guides you to create a config file. On the server, in /var/www/web1/web, create an empty file called: config.php
Make this config.php file writeable for Apache with the command:
chmod 666 config.php
After that, in your browser, click “Create config file”.
If the Config file is created successfully this will be confirmed: Press “Continue to Step 8>>”.
By pressing "Continue to Step 8>>”, the Gallery codebase will be installed. If the Gallery2 Codebase has been created successfully, it will be confirmed.
Press “Continue to Step 9>>”.
At step 9 within the Gallery2 installer, you can select which modules you want to have installed. Click on “(un)check all”, because we only install the codebase right now. After that, click on "Continue to step 10 Without Activating” to proceed.
At step 10 within the Gallery installer we have to set the right permissions. Read the instructions on the screen.
Now, on the server - as root - give the following commands:
chmod 755 /var/www/web1/web
chmod 644 /var/www/web1/web/config.php
After chmod the mentioned files, in your browser press “Check Again”. If you’ve set the persmissions as described above, you’ll see that everything is safe now: Click on “Continue to Step 11>>” to finish the installation.
Now you are done, you can click on “Go to my Gallery!”
More information about Gallery2: http://gallery.menalto.com/