Gallery 3 installation / upgrade in Ubuntu

Installation

aptitude install apache2 mysql-server-5.1

su - www-data
cd /var/www/user
wget http://downloads.sourceforge.net/gallery/gallery-3.0.4.zip
unzip gallery-3.0.4.zip
mv gallery3 gallery
rm gallery-3.0.4.zip
cd gallery
mkdir var
chmod 777 var
exit

mysql -u root -p
SHOW DATABASES;
SELECT User FROM mysql.user;
CREATE DATABASE `user-gallery3`;
CREATE USER `user-gallery`;
SET PASSWORD FOR 'user-gallery' = PASSWORD('mysecretpassword');
GRANT ALL PRIVILEGES ON `user-gallery3`.* TO 'user-gallery'@'localhost' IDENTIFIED BY 'mysecretpassword';
FLUSH PRIVILEGES;
EXIT
rm -f ~/.mysql_history

/etc/apache2/sites-enabled/user-ssl

<VirtualHost *:443>
        ServerAdmin user@zviretnik.eu
        ServerName user.zviretnik.eu
        ServerAlias user-nick.zviretnik.eu
        DocumentRoot /var/www/user/wordpress/

        <Directory /var/www/user/gallery>
                Options -Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
                DirectoryIndex index.php
        </Directory>

        Alias /gallery /var/www/user/gallery

        ErrorLog /var/log/apache2/user.zviretnik.eu-ssl-error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/user.zviretnik.eu-ssl-access.log combined

        SSLEngine on
        SSLProtocol all -SSLv2
        SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
        SSLCertificateFile /etc/ssl/user.zviretnik.cer
        SSLCertificateKeyFile /etc/ssl/private/user.zviretnik.key
        SSLCertificateChainFile /etc/ssl/startssl.sub.ca.pem
        SSLCACertificateFile /etc/ssl/startssl.root.cs.pem
        SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown

        CustomLog /var/log/apache2/user.zviretnik.eu-ssl-request.log \
         "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>

http://user.zviretnik.eu/gallery/installer/

rmdir /var/www/user/gallery/var/albums
ln -s /mnt/data/user/albums/ albums

Upgrade

/etc/init.d/apache2 stop

su - www-data
cd /var/www/user
wget http://downloads.sourceforge.net/gallery/gallery-3.0.4.zip
unzip gallery-3.0.4.zip
mv ./gallery/var ./gallery3/var
mv gallery gallery.old
mv gallery3 gallery
cd ./gallery
php index.php upgrade

Copy any custom or downloaded Themes or Modules from your old folder to the new one.

cd ..
rm gallery-3.0.4.zip
rm -rf gallery.old

/etc/init.d/apache2 start