Before you can install Gallery 2, you need an up and running webserver with PHP support and a database server. For a full list of all requirements, please read our Installation Requirements page.
If you install Gallery 2 on a hosted webserver like most users do, you don't have to worry about how to install and set up a webserver etc. since it's all done and prepared for you. Your webhost has probably a control panel or other administration tools where you can create an empty database. Just skip this section and continue with Preparing to install.
Setting Up Your Own Webserver
Setting up your own webserver is not the easiest thing to do. There are some free packages available that install a complete webserver with PHP and a MySQL server for you with a few clicks, but if you run into problems, you'll soon see that it's not very intuitive if you have no experience in such things.
You can follow this step by step guide to setting up an Apple Mac as a webserver
If you don't have a static IP address or a dynamic DNS (dnydns) account, your Gallery 2 on your own webserver will only be accessible to you and other computers on your local network and none of friends or customers can view your Gallery in the internet. We assume that you either have a static IP address / dyndns account or that you want to access Gallery 2 only from your intranet / desktop computer.
Easy To Install All-In-One Packages
If you don't have installed any of the required components yet and if you prefer to not get involved with the technical details, there are some easy to install, all-in-one packages that install apache + MySQL + PHP with a few clicks.
XAMPP - http://www.apachefriends.org/ (for Windows, Linux, and other operating systems)
MAMP - http://www.mamp.info/ (for Mac OS X)
WAMP - http://www.wampserver.com (for Windows)
If you want to install Gallery 2 on your own computer / server, then we recommend linux / *BSD as operating system since these are our primary development platforms and these are also the platforms most professional webhosting companies use. Other operating systems are also supported of course. There are various Linux distributions. Debian and Gentoo (among others) are highly recommended because they are mature, stable and well-suited for server applications and they include excellent package managers which resolve dependencies for you. Installing a webserver, php or a database server on such linux distributions is as easy as entering a single command à la "emerge apache2" or "apt-get install apache".
Apache2 is the webserver of our choice. Some Gallery 2 features like short URLs are only available for apache (short URLs are also available for other webservers since Gallery 2.1).
Gallery 2 is mainly developed for MySQL, but it runs also very well with PostgreSQL and DB2. Gallery 2 is not very well tested with Oracle. You can expect the best performance with MySQL, also because we use built-in functions of MySQL that we have to mimic in other database servers with user-defined functions.
You can get precompiled PHP binaries or the whole sourcecode from php.net. If you compile it on your own, don't forget to compile database support into PHP (e.g. --with-mysql= ... and --with-mysql-sock=... if you're using MySQL). Also, for translation / multilanguage support, you'll need gettext. And there are a lot more PHP compile options / extensions that are either required (e.g. PCRE) by Gallery 2 or useful in general. If you rely on GD (an image toolkit that is built-in into PHP) instead of the external, mostly superior image toolkit binaries (imagemagick, netpbm, graphicsmagick), then you shouldn't forget to add all the image formats to the PHP compile options (--with-jpeg=... , --with-png=..., etc). Compiling PHP is a topic of its own. Gentoo, Debian, ... will configure and compile it for you with a single command. And you can find numerous tutorials and HOWTOs about this topic as well as about the whole webserver + mysql + PHP topic in general.
1. Latest Version - There are four ways to get the code.
Tarball - You can download a prepackaged file as a tarball or a zip file from SourceForge.
Pre-Installer - If you only have FTP access to your webserver and don't have the option to extract zip or tar files directly on the server, you should give the Gallery 2 Pre-Installer a try. It transfers the archive directly to your webserver and extracts it for you.
Nightly Snapshot - You can download a tarball or zip file with a snapshot of the most recent code. Find links to these on the Gallery Download Page.
Subversion - This is a better way to get the latest code, but it’s for advanced users. Follow the Subversion instructions to obtain the latest Gallery 2 code. It’s easier to stay up to date with this method since you can run one command and get the latest code at any time.
2. Storage - Create a directory for gallery to store photos. This must be writeable by the web server, but for security reasons we suggest that you do not put it in the web root. If you put it in the web root, then anybody can get directly to your images with their web browser which circumvents Gallery 2’s security.
$ cd $HOME
$ mkdir g2data
$ chmod 777 g2data
C:\> mkdir g2data
In the Unix example, you may note that modes of 777 on your g2data directory are not all that secure. However, making it more secure depends on how your system is configured. Talk with your system administrator about ways to change the permissions on that directory to make it so that Gallery can still write to the files but that others can’t.
3. Database - Right now we support MySQL, PostgreSQL, DB2, Oracle and MS SQL Server. MySQL is generally faster than PostgreSQL. We require you to create the database yourself. In our examples below, we’ll be creating a database called gallery2. You can use any database name that you choose.
Grant all required privileges to your database user. This includes but is not confined to: CREATE TABLE, ALTER TABLE, DROP TABLE in the gallery2 database; SELECT, INSERT, UPDATE, DELETE on all (gallery2) tables in the gallery2 database; CREATE INDEX and some other privileges that are specific to the different database management systems. CREATE/DROP DATABASEand the ability to GRANT privileges to other database users are not required.
4. Graphics Toolkits - Gallery 2 works with NetPBM, ImageMagick, GD or GraphicsMagick. They’re all almost equally good, though some say that NetPBM has slightly better quality and that ImageMagick is slightly faster than NetPBM. GD cannot do image rotation. GraphicsMagick and ImageMagick are very similar. GD can be very fast, but it will also use a lot of memory so it may cause you to run into predefined server limits. It is also compiled into PHP by default if your PHP is 4.3.0 or more recent, however it may not have support for all image types (e.g. it might not have JPEG support). If the binaries for NetPBM and ImageMagick are installed in default, or standard, locations then Gallery 2 will auto-detect them during installation. It won’t cause any harm to enable all of these toolkits—in fact you’ll get the widest file type support if you do so.