Home‎ > ‎unix/linux‎ > ‎Gentoo Systems‎ > ‎

Gentoo: Gallery

Overview:
If you take a lot of photos, where do you keep them?  Picasa and iPhoto are nice, but they are not good for sharing.  Flickr is nice but there is no privacy, Picasa Web Albums are nice but won't let you store all your 50,000 photos.  So what do you do?

Gallery!  (and I like to run it on Gentoo.)

So here's how to set up a standalone server running gallery on gentoo.



Install Gentoo

Following Gentoo Quick Start Doc

grep bogo /proc/cpuinfo

bogomips        : 6004.53
bogomips        : 6000.36

hdparm -tT /dev/sda

/dev/sda:
 Timing cached reads:   3524 MB in  2.00 seconds = 1761.72 MB/sec
 Timing buffered disk reads:  172 MB in  3.02 seconds =  56.89 MB/sec

grep MemTotal /proc/meminfo

MemTotal:      1026360 kB

# setup disks:
fdisk /dev/sda


# view and delete old drive partitions
p
d
(1-#) all the drives

# create new drives
p
n, p, 1, [enter], +32M #boot
n, p, 2, [enter], +1024M #swap
n, p, 3, [enter], [enter] #root
t, 2, 82  #set swap drive to swap type
a, 1     #set boot to bootable
w        #write changes
Disk /dev/sda: 250.0 GB, 250058301440 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 5 40131 83 Linux
/dev/sda2 6 130 1004062+ 82 Linux swap / Solaris
/dev/sda3 131 30401 243151807+ 83 Linux

Code Listing 2.9: Create the file systems and activate swap
mke2fs /dev/sda1
mke2fs -j /dev/sda3
mkswap /dev/sda2 && swapon /dev/sda2

Code Listing 2.10: Mount the file systems
mount /dev/sda3 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot
cd /mnt/gentoo

Code Listing 2.11: Set the date and UTC tim
date 081012172010 (Format is MMDDhhmmYYYY)

Code Listing 2.12: Download a stage3 archive
wget ftp://distfiles.gentoo.org/pub/gentoo/releases/x86/current-stage3/stage3-i686-*.tar.bz2
time tar xjpf stage3*

Code Listing 2.14: Download the latest Portage snapshot
cd /mnt/gentoo/usr
wget http://distfiles.gentoo.org/snapshots/portage-latest.tar.bz2
time tar xjf portage-lat*

Code Listing 2.16: Chroot
cd /
mount -t proc proc /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev
cp -L /etc/resolv.conf /mnt/gentoo/etc/

chroot /mnt/gentoo /bin/bash
env-update && source /etc/profile

Code Listing 2.17: Setting your timezone
cd /etc
echo "127.0.0.1 gallery.cmed.us gallery localhost" > hosts
sed -i -e 's/HOSTNAME.*/HOSTNAME="gallery"/' conf.d/hostname
hostname gallery
hostname -f


Code Listing 2.19: Install a kernel source, compile it and install the kernel
time emerge gentoo-sources
cd /usr/src/linux
make menuconfig

Or you can have gentoo configure the kernel itself via:
emerge -k sys-kernel/gentoo-sources; emerge -k genkernel; genkernel all

and note the following:
root=/dev/ram0
init=/linuxrc
real_root=/dev/sda3
splash=verbose
/boot/kernel-genkernel-x86-2.6.34-gentoo-r1
/boot/initramfs-genkernel-x86-2.6.34-gentoo-r1

* Kernel compiled successfully!
*
* Required Kernel Parameters:
* real_root=/dev/$ROOT
*
* Where $ROOT is the device node for your root partition as the
* one specified in /etc/fstab
*
* If you require Genkernel's hardware detection features; you MUST
* tell your bootloader to use the provided INITRAMFS file. Otherwise;
* substitute the root argument for the real_root argument if you are
* not planning to use the initramfs...

# * Please specify /boot/kernel-2.4.20-gentoo-r8
#   and            /boot/initrd-2.4.20-gentoo-r8


Configure the kernel, and continue:

time make -j2
make modules_install
cp arch/i386/boot/bzImage /boot/kernel

Code Listing 2.20: Example fstab
emerge vim screen
cd /etc

vim fstab
/dev/sda1               /boot           ext2            noauto,noatime  1 2
/dev/sda3               /               ext3            noatime         0 1
/dev/sda2               none            swap            sw              0 0
/dev/cdrom              /mnt/cdrom      auto            noauto,ro       0 0
shm                     /dev/shm        tmpfs           nodev,nosuid,noexec     0 0


Code Listing 2.21: Configure networking
cd conf.d
echo 'config_eth0=( "192.168.1.10/24" )' >> net
echo 'routes_eth0=( "default via 192.168.1.1" )' >> net
rc-update add net.eth0 default
rc-update add sshd default

Other Cleanup:
passwd
vim /etc/conf.d/clock
TIMEZONE="EST"
vim /etc/rc.conf
#EDITOR="/bin/nano"
EDITOR="/usr/bin/vim"
#EDITOR="/usr/bin/emacs"
Code Listing 2.25: Install a syslogger and a cron daemon
time emerge syslog-ng vixie-cron
rc-update add syslog-ng default
rc-update add vixie-cron default

Code Listing 2.27: Emerge grub and edit its configuration file
time emerge grub
vim /boot/grub/grub.conf
default 0
timeout 10

root=/dev/ram0
init=/linuxrc
real_root=/dev/sda3
splash=verbose

title Gentoo
root (hd0,0)
kernel /boot/kernel root=/dev/sda3
grub
root (hd0,0)
setup (hd0)
quit
Code Listing 2.30: Reboot
exit
umount /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo/boot /mnt/gentoo
reboot

Cleanup of Install:

Code Listing 2.33: Use mirrorselect and set MAKEOPTS
emerge mirrorselect
mirrorselect -i -o >> /etc/make.conf
mirrorselect -i -r -o >> /etc/make.conf
(Usually, (the number of processors + 1) is a good value)
echo 'MAKEOPTS="-j2"' >> /etc/make.conf

Code Listing 2.35: Define locales

cd /etc
vim locale.gen
locale-gen

Code Listing 2.37: Update your packages
emerge -vpuD --newuse world
time emerge -vuD --newuse world
emerge --oneshot libtool
dispatch-conf
time perl-cleaner all
python-updater

Install Apps:

Install Gallery

echo 'USE="apache2 unicode gd imagemagick netpbm mysql jpeg"' >> /etc/make.conf
emerge --sync
emerge -vpuD --newuse world
time emerge -vuD --newuse world

emerge app-portage/portage-utils app-portage/gentoolkit
/usr/sbin/libpng-1.4.x-update.sh
revdep-rebuild
emerge www-apps/gallery
rc-update add apache2 default


eselect news read


Make sure php is working properly
echo '<?php phpinfo(); ?>' >> /var/www/localhost/htdocs/info.php

Then browse to http://192.168.1.10/info.php
If you get a rich test page, then you know you set it up properly.


Configure MYSQL:
emerge --config mysql

enter new db root password:  (see root dir)

Then start up mysql and create the Gallery DB
/etc/init.d/mysql start
rc-update add mysql default
mysqladmin -u root -p create gallery2
mysql gallery2 -uroot -p -e"GRANT ALL ON gallery2.* TO gallery@localhost"

Configure Gallery

browse to http://192.168.1.10/gallery and follow instructions.

When prompted by the webpage, add the key in the gallery dir
/var/www/localhost/htdocs/gallery


Create the gallery picture directory in
/home/gallery/g2data/


Enter the config file
touch /var/www/localhost/htdocs/gallery/config.php
chmod 666 /var/www/localhost/htdocs/gallery/config.php

and secure the config file
chmod 644 /var/www/localhost/htdocs/gallery/config.php

Set PHP to allow large file uploads: (between video and large res pictures,
it needs to be cranked up a lot!) NOTE: Search and replace the two commands
with the new values. Don't simply add these two commands.

vim /etc/php/apache2-php5/php.ini
post_max_size = 75M
upload_max_filesize = 75M

Then restart apache to have the changes take place.
/etc/init.d/apache2 restart







Comments