Gentoo Linux Desktop Configuration Guide Grant Goodyear This guide shows you configure Gentoo Linux to be a full-purpose desktop system. Specifically, we walk through installing and configuring X, KDE, OSS and alsa (sound), postfix (electronic mail), cups (printing), and samba (unix/windows interoperability). 0.27 12 August 2002 Preliminaries

Needless to say, you first need to have Gentoo Linux installed (http://www.gentoo.org/doc/build.html). Having finished that rather enjoyable process, you also need to download the Portage tree. You really should read the Portage User Guide (http://www.gentoo.org/doc/portage-user.html), but if you're in a hurry you just need to type:

# emerge sync

A quick note is in order about the packages that I have chosen to discuss here. Gentoo Linux has a considerable wealth of window managers, mail transport agents, etcetera that can easily be installed. The specific packages that I have chosen to cover are not preferred by Gentoo Linux, they are simply packages that the author likes and/or knows how to configure. In other words, they're the packages on the author's own desktop.

X and KDE
Installation

Having installed Gentoo Linux and updated Portage, my first task is generally to install X and a desktop manager. X takes forever to compile, and KDE takes even longer, so I highly recommend doing this right before going to bed.

It's always useful to use the --pretend flag before doing an emerge to see what dependencies are going to be installed, and in our case it's quite a lot.

# emerge --pretend kde
# emerge kde-base/kde
Be careful when using emerge kde-base. This will only install the base KDE packages and none of KDE's helper applications. If you plan to use CUPS for printing then you probably want "cups" in your USE variables in /etc/make.conf before emerging kde-base/kdebase. Please reference the Gentoo Print Guide for a complete CUPS install explanation.

Have a nice nap!

If you have a Gentoo Linux binary CD, then you can install the packages directly off of the CD.
# export PKGDIR=/mnt/cdrom/gentoo/packages
Normally Portage expects packages to be in /usr/portage/packages

# emerge --usepkg /mnt/cdrom/gentoo/packages/All/kdebase-x.y.z.tbz2
The --usepkg flag makes sure that binary packages are used
for the dependencies (if available).
Configuring

I like using the console-based xf86config program to configure X, although the generated /etc/X11/XF86Config file is not very elegant -- see this tutorial for an alternative and more thorough X configuration. Before you start, you'll need to know the horizontal and vertical refresh rates of your monitor (my viewsonic G773 has Horizontal: 30-69 KHz, Vertical: 55-90 KHz), the type and amount of ram (in KB) of your video card (a 32768 KB GeForce card, in my case), and the type and device of your mouse (an intellimouse plugged into the ps/2 port /dev/psaux).

# /usr/X11R6/bin/xf86config

Because I have a three-button mouse I choose not to enable 3-button emulation. Don't forget to add XKB support if you have an internation keyboard or need multiple language support. You'll have to guess at a screen resolution and pixel depth that you'll like. I happen to like 1280x1024 at 24bpp on my viewsonic, but that's only because it doesn't work at a higher resolution. If you've never done this before, don't be surprised if you end up running xf86config multiple times.

If you don't know the refresh rates of your monitor, try doing a google search, http://www.google.com, on the model number and manufacturer of your monitor. The refresh rates are generally given as part of the monitor specs.

If you're an X-configuring veteran, you may be used to making a symbolic link from your mouse device to /dev/mouse. Such symlinks used to be problematic with devfs, since they tended to go away after a reboot. Gentoo Linux now handles symbolic links in /dev correctly. Just make the /dev/mouse symlink using ln -s and it will be preserved upon rebooting.

# startx

If you configured X properly, running startx should start an amazingly ugly X window manager (twm, to be specific). If X comes up, you're good to go. Hit <ctrl><alt><backspace> to kill the X server.

If you have a wheel mouse you'll want to edit the XF86Config file by hand:

# cp /etc/X11/XF86Config /etc/X11/XF86Config.working
# nano -w /etc/X11/XF86Config
Section "InputDevice"

# Identifier and driver

    Identifier	"Mouse1"
    Driver	"mouse"
    Option "Protocol"    "IMPS/2" 
    Option "Device"      "/dev/psaux"
    Option "ZAxisMapping"	"4 5"

Because I have an intellimouse I changed the "Protocol" from "PS/2" to "IMPS/2". Getting the wheel to scroll just requires adding the 'Option "ZAxisMapping" "4 5"' line, where '4' and '5' correspond to mouse wheel up and mouse wheel down.

Netscape 4.x won't scroll with the wheel by default; you'll need to create an .Xdefaults file first. Go here for instructions. Better yet, use konqueror, opera, mozilla, galeon, or some other real browser.

Run startx again just to make sure X still comes up. If you happen to have an NVIDIA card, now would be a good time to install the NVIDIA accelerated drivers.

# emerge nvidia-glx
# emerge nvidia-kernel
# nano -w /etc/X11/XF86Config
Section "Module"

# This loads the GLX module
#    Load       "glx" (Uncomment this line)
Section "Device"
    Identifier  "NVIDIA GeForce"
    #Driver      "nv"
    Driver      "nvidia"
    #VideoRam    32768
    # Insert Clocks lines here if appropriate
EndSection

Run startx one more time to make sure that X still comes up (this time with the NVIDIA splash screen, if you have installed the nvidia drivers). Assuming that it does, kill X and we'll start a real window manager instead. Thanks to Achim, Danarmak and Verwilst, Gentoo's KDE packagers, the KDE ebuild configures KDE quite well all by itself. The KDM display manager should work just by starting it.

# kdm

You should be able to log in and see KDE in full working order. Of course sound shouldn't be working yet, so you'll miss the annoying KDE start-up sound, but we'll fix that in a moment. Open a konsole, type ls /usr/bin (or anything else that more than fills the konsole window), and see if the mouse wheel lets you scroll up and down in the konsole window. It really should work!

All that's left is to make sure that X comes up when Gentoo boots. Edit /etc/rc.conf so that DISPLAYMANAGER="kdm".

# nano -w /etc/rc.conf
# What display manager do you use ?  [ xdm | gdm | kdm ]

DISPLAYMANAGER=kdm

Now we just need to make sure that the xdm start-up script is read when booting.

# rc-update add xdm default

Reboot, and see if X comes up!

The rc-update command is Gentoo Linux's improved version of the venerable chkconfig command for managing init scripts. Type rc-update by itself for a list of options.
X and GNOME
Installation

First, we have to install the necessary GNOME packages.

# emerge --pretend gnome
# emerge gnome

This will take a good while to do, so kick back and watch a movie.

GNOME configuration is basically the same as KDE from this point forward. It is still necessary to edit XF86Config and set up the NVIDIA drivers and default desktop manager. Please consult above for these procedures.

USB Mouse Configuration

A USB mouse is your friend on a high resolution screen. The kernel takes care of the scaling so you don't have to move your mouse five times across the pad to make it across the screen.

The first thing that has to be done is the installation of the kernel modules. The modules that will be needed for a USB mouse to work are usbmouse, mousedev, hid, usbcore, and input. After the necessary kernel configuration is done, insmod the modules.

When configuring the Input Core support for the mouse, make sure to enter the screen resolution that you will be using in X. This makes the scaling all pretty and correct.

Now, unplug the mouse, and plug it back in, and check your kernel log for a message that looks something like this

hub.c: USB new device connect on bus1/1, assigned device number 2
input0,hiddev0: USB HID v1.00 Mouse [Microsoft Microsoft IntelliMouse Optical] on usb1:2.0

Now that the mouse is detected, check /dev/input to make sure that your mouse is there and working.

# cd /dev/input
# cat mouse0

Move your mouse when you cat the device, you should see a lot
of garbage. 

Once the mouse is properly detected and installed, now we have to tell X to use the USB mouse. All that is required here is a slight change to what device X uses for the mouse.

# cp /etc/X11/XF86Config /etc/X11/XF86Config.working
# nano -w /etc/X11/XF86Config
Section "InputDevice"

# Identifier and driver

    Identifier	"Mouse1"
    Driver	"mouse"
    Option "Protocol"    "IMPS/2" 
    Option "Device"      "/dev/input/mouse0"
    Option "ZAxisMapping"	"4 5"

Okay, restart X, and the mouse should be working!

Don't forget to add the modules that your mouse uses to modules.autoload.

# echo $'/n'usbmouse $'/n'mousedev $'/n'hid #'/n'usbcore $'/n'input >> /etc/modules.autoload
Sound
Alsa

Gentoo Linux supports Alsa for sound using the default kernel. Alsa can be run with or without devfs. One note; if you've installed a new sys-kernel/linux-sources package, make sure that your Linux kernel has sound support enabled.

# emerge alsa-driver

I am going to assume here that you have devfs enabled; if you don't then please see the Gentoo FAQ: http://www.gentoo.org/doc/faq.html.

Now we set up the kerneld aliases.

# nano -w /etc/modules.d/alsa
# update-modules
##
## IMPORTANT:
## You need to customise this section for your specific sound card(s)
## and then run `update-modules' command.
## Read alsa-driver's INSTALL file in /usr/share/doc for more info.
##
##  ALSA portion
alias snd-card-0 snd-emu10k1
alias snd-card-1 snd-emu10k1
alias snd-card-2 snd-emu10k1
alias snd-card-3 snd-emu10k1
alias snd-card-4 snd-emu10k1
alias snd-card-5 snd-emu10k1
alias snd-card-6 snd-emu10k1
alias snd-card-7 snd-emu10k1

You'll want to replace snd-card-emu10k1 with your sound card.

You should also verify that /etc/devfsd.conf has the alsa devices and permissions correctly registered.

# nano -w /etc/devfsd.conf
# rc-update add alsasound boot
# ALSA/OSS stuff
# Comment/change these if you want to change the permissions on
# the audio devices
LOOKUP          snd          MODLOAD ACTION snd
LOOKUP          dsp          MODLOAD
LOOKUP          mixer        MODLOAD
LOOKUP          midi         MODLOAD
REGISTER        sound/.*     PERMISSIONS root.audio 660
REGISTER        snd/.*       PERMISSIONS root.audio 660
Notice that devfsd.conf sets /dev/sound permissions to be root.audio. Thus, for non-root users to use audio they will have to be part of the audio group. Note that the alsasound script should be added to the "boot" runlevel, not the "default" runlevel.

At this point the simplest method is to reboot. You still won't be able to hear any sound, though, because alsa keeps all sound channels muted by default.

# emerge alsa-utils
# amixer

Group 'Input Gain',0
  Capabilities: volume mute jointly-mute
  Channels: Front-Left Front-Right
  Limits: min = 0, max = 15
  Front-Left: 11 [73%] [mute] [---]
  Front-Right: 11 [73%] [mute] [---]
Group 'Master Mono',0
  Capabilities: volume mute capture exclusive-capture
  Capture exclusive group: 1
  Channels: Front-Left Front-Right
  Limits: min = 0, max = 31
  Front-Left: 23 [74%] [mute] [---]
  Front-Right: 23 [74%] [mute] [---]
Group 'Headphone',0
  Capabilities: volume mute jointly-mute
  Channels: Front-Left Front-Right
  Limits: min = 0, max = 31
  Front-Left: 0 [0%] [mute] [---]
  Front-Right: 0 [0%] [mute] [---]
Group 'Master',0
  Capabilities: volume mute jointly-mute capture exclusive-capture
  Capture exclusive group: 1
  Channels: Front-Left Front-Right
  Limits: min = 0, max = 63
  Front-Left: 50 [79%] [mute] [---]
  Front-Right: 50 [79%] [mute] [---]
[chopped for brevity]

# amixer set Master 100 unmute
# amixer set PCM 100 unmute
# aplay /usr/kde/3/share/sounds/pop.wav (pop.wav is part of KDE)

After installing the alsa utilities we use amixer to unmute the Master and PCM sound channels and to set their volume to 100%. We check to see if sound is working by using the aplay (alsa play) command. If you hear a pop, then sound is indeed working. Then, adjust the volume settings to your liking; the ncurses-based alsamixer is a great way to get them "just so".

You may want to emerge alsa-xmms as that will provide ALSA support for XMMS.

When you reboot your system, the alsasound init script will properly save and restore your volume settings.

Standard Kernel Sound Modules

For standard kernel sound, you will have to recompile the kernel if you didn't compile your sound module when you installed gentoo. If you chose to compile the sound driver as a module (not compile it directly into the kernel), they you need to add the module name (without the .o extension) to /etc/modules.autoload. Reboot the machine if you compiled the sound module into the kernel, or just modprobe drivername if you compiled the sound module as a module. With any luck the appropriate sound driver should now be loaded. To actually produce sound, a few more steps are required.

# cd /dev
# /usr/sbin/MAKEDEV audio
# cat /usr/kde/2/share/sounds/pop.wav > /dev/dsp
# emerge media-sound/sox
# play /usr/kde/2/share/sounds/pop.wav

If any sound at all results from cat'ing the .wav file to /dev/dsp, then sound is probably working. By emerge'ing sox one can use the play command to play .wav files (and, unlike using cat, the .wav file should actually sound good when using play).

Sound and KDE

KDE has some nice sound utilities, including the KDE sound mixer kmix.

# emerge --search kdemultimedia
[ Results for search key : kdemultimedia ]
[ Applications found : 1 ]

*   kde-base/kdemultimedia
      Latest version Available:  2.2.2
      Latest version Installed:  2.2.2
      Description:  ${DESCRIPTION}Multimedia
# kmix
If kmix cannot find a mixer, then it probably thinks you don't have sound support. Log out and remove ~/.kde/share/config/kmixrc and ~/.kde/share/config/kmix:* then log in again. This time it should find the sound mixer properly.
Mail
Postfix -- Install and Configure

I happen to like the postfix mail system because it emulates sendmail without the considerable nightmare of having to configure sendmail. While we're at it we'll also install mutt, a mail reader, so that we can test out our postfix configuration.

# emerge --pretend net-mail/postfix net-mail/mutt

These are the packages that I would merge, in order.
 
Calculating dependencies... done!
[ebuild N  ] dev-libs/libpcre-3.4-r1 to /
[ebuild N  ] net-mail/mailbase-0.00-r1 to /
[ebuild N  ] net-mail/postfix-20010228.2 to /
[ebuild N  ] net-mail/mutt-1.3.22.1 to /

# emerge net-mail/postfix net-mail/mutt

If you only intend to use your mail server for sending mail, then postfix is already set up for you. Otherwise, you'll want to edit /etc/postfix/main.cf. The main.cf file is reasonably well documented, and the defaults are reasonable for a standalone machine. If your workstation is directly on the internet (i.e., having its own non-private IP address and DNS name) then the only change you will probably have to make is enabling postfix to receive mail.

# RECEIVING MAIL

# The inet_interfaces parameter specifies the network interface
# addresses that this mail system receives mail on.  By default,
# the software claims all active interfaces on the machine. The
# parameter also controls delivery of mail to user@[ip.address].
#
#inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
inet_interfaces = $myhostname, localhost
mydestination = $myhostname, localhost.$mydomain
Postfix Testing (with Mutt)

Let's see if it works.

# postfix check

# newaliases
# postfix start
postfix-script: starting the Postfix mail system
# mutt -x root
/root/.maildir does not exist. Create it? ([y]/n): [answer y]
To:  <root>
Subject: test
(End message with a . on a line by itself)
test
.

# mutt
[You should see your message]

By using postfix check we make sure that main.cf parses properly and a number of important directories are created. Running newaliases sets up the system mail aliases, and postfix start then starts the mailer. I then used mutt (in mailx, or old-fashioned mail, mode) to send a message to myself on the local machine. Along the way mutt creates the user's (root's, in this case) mail spool directory, ~/.maildir. Running mutt in full interactive mode then showed me my message, so at least local sending and delivery is working. I then sent mail to one of my non-local email addresses (not shown) and verified that the mail did, indeed, get there.

If you send mail to an account using the default main.cf from a machine on a private network, then it is possible you will never see it. Many mail servers automatically reject mail coming from a source that can't be reached by reverse-DNS.

Assuming everything is working, then it's time to set up postfix so that it starts at boot time.

# postfix stop
postfix-script: starting the Postfix mail system
# rc-update add postfix default
 * postfix added to runlevel default...
 * Caching service dependencies...          [ ok ] 
 * rc-update complete.
# /etc/init.d/postfix start
Starting postfix......     [  ok  ]
Veteran sendmail or postfix junkies may be more used to storing mail in /var/spool/mail instead of in the user directories, and that mail is then stored in mbox format instead of in maildir format. It is not all that hard to reconfigure postfix and mutt to use the standard unix mailbox system (mbox) format instead. Edit /etc/postfix/main.cf to comment out home_mailbox and uncomment mail_spool_directory = /var/spool/mail. Make the mail spool directory with mkdir -p /var/spool/mail and restart postfix. That will take care of the mailer, for mutt you just have to edit /etc/mutt/Muttrc to use mbox with set mbox_type = mbox and the /var/spool/mail directory with set spoolfile=/var/spool/mail.

If you would prefer a GUI mail client, we install a web-based mail server, Squirrelmail, later in this guide. Alternatively, Daniel Robbins highly recommends a combination of IMAP (which we install below as a prerequisite to Squirrelmail) and KDE's kmail client. The kmail program is part of kde-base/kdenetwork:

 # emerge --search kdenetwork
[ Results for search key : kdenetwork ]
[ Applications found : 1 ]

*  kde-base/kdenetwork
      Latest version Available:  2.2.2
      Latest version Installed:  2.2.2
      Description:  ${DESCRIPTION}Network

Also below we will install Ximian's Evolution as our Personal Information Management software of choice, complete with Palm pilot support. It, too, can serve as an excellent mail client.

Printing
Simple printing -- PDQ

For simple systems where you don't need samba support the PDQ printing system is nice and simple.

# emerge net-print/pdq
# xpdq

Just click on Printer/Add printer and add your printer. If your type of printer isn't listed, see http://www.linuxprinting.org, and you can generate the required files from their web site. You will want to click on "Driver options" to further finish configuring the printer in xpdq. Any printers set up by running xpdq as root will be available to all users. That's all it takes!

Full-fledged printing -- CUPS CUPS configuration has been fully covered in the Gentoo Print Guide. Please refer to that.

CUPS is a much larger print spooler that is fully suitable for use as a large-scale print server. Fortunately it is pretty easy to set up, since most of the configuration can be done using CUPS' built-in web server. Although CUPS is nominally a System V print spooler (meaning that it uses the lp series of commands) it emulates all of the lpr commands as well.

# emerge --pretend net-print/gimp-print-cups
These are the packages that I would merge, in order.
 
Calculating dependencies.. done!
[ebuild N  ] net-print/cups-1.1.10-r6 to /
[binary N  ] net-print/gimp-print-cups-4.1.1 to /
# emerge gimp-print-cups
# rc-update add cupsd default
 * cupsd added to runlevel default...
 * Caching service dependencies...         [ ok ] 
 * rc-update complete.
# /etc/init.d/cupsd start
Starting Common Unix Printing System...... [  ok  ]
# konqueror localhost:631

The gimp-print-cups package is a set of printer drivers for cups, which is useful because the cups package itself includes drivers only for HP and Epson printers. Building gimp-print-cups builds cups as a dependency. Once cups is built we add its init scripts to the default runlevel using rc-update, and then we turn on the cups daemon by starting the init script.

Configuring cups simply requires using a web browser to connect to the web server that cups runs on the localhost network on port 631. [Note that because the cups web server is configured to accept requests only on localhost and not on any of the ethx interfaces, it is reasonably secure. Of course, that also means that it is difficult to administer cups remotely in any sort of nice fashion (the command-line lpadmin command would be an option, but it is also a considerable nightmare). Fortunately, the cups web server renders quite well in lynx, so it can be administered from a terminal window.] Once you connect to the web interface, click (or its equivalent if using lynx) on "Do Administrative Tasks". You will be asked for the cups account name and password; you can either use "root" (and the root password), or provide a username and password for a user in the "lp" group. Again, since the web server exists only on localhost, you don't have to worry about that information being transmitted on the internet. To add a printer click on "Add Printer", and follow the directions. Help may be obtained by clicking on "Help", and then reading the Software Administrator's Manual. If you find that you lack the appropriate printer driver then you can create one by heading to the rather impressive linuxprinting.org site.

Samba

Samba is a remarkable package that lets your linux box share files and printers with MS Windows machines. For more detailed information read the Samba articles by Daniel Robbins at http://www.ibm.com/developerworks.

# emerge net-fs/samba
# rc-update add samba default
# cd /etc/samba
# cp smb.conf.example smb.conf
# nano -w smb.conf
# workgroup = NT-Domain-Name or Workgroup-Name, eg: REDHAT4
   workgroup = MYGROUP [change to match your workgroup]
# It should not be necessary to specify the print system type unless
# it is non-standard. Currently supported print systems include:
# bsd, sysv, plp, lprng, aix, hpux, qnx
;   printing = bsd
    printing = cups
# You may wish to use password encryption. Please read
# ENCRYPTION.txt, Win95.txt and WinNT.txt in the Samba documentation.
# Do not enable this option unless you have read those documents
  encrypt passwords = yes

I have fairly minimal Samba needs. I just want to be able to share files between my linux and windows machines, and I want to use my linux box as a print server (using cups). After installing, it suffices to make a few minor edits to the /etc/samba/smb.conf file. Specifically, the workgroup variable needs to match the workgroup for the windows network (I usually use "OLYMPUS", but "WORKGROUP" is the default on windows if I remember correctly), printing needs to be cups instead of bsd, and the encrypt passwords = yes line needs to be uncommented. Windows machines use encrypted passwords by default, so that last change is essential unless you want to hack the Windows registry on all of your windows machines [not recommended]. Unfortunately, Windows uses a different encryption method for passwords than does Linux, so you have to maintain a separate password file for samba.

# smbpasswd -a grant [Replace "grant" with your user name]
New SMB password:
Retype new SMB password:
Added user grant.
Before adding a user to samba's password list that user must first be listed in /etc/passwd.

For each user that you want to be able to use samba from a windows machine you need to run the smbpasswd command. Samba stores passwords in /etc/samba/private/smbpasswd, which will be created for you the first time you run the smbpasswd command.

# /etc/init.d/samba start
Starting samba...        [  ok  ]

Start samba, and you should be able to connect to your Gentoo Linux box from any of your windows machines and see the home directory for whatever user you connect as and also whatever printers you have set up. If you can't connect, take a look at /usr/share/doc/samba-2.2.3a/full_docs/textdocs/DIAGNOSIS.txt.gz for additional help.

Apache and Squirrelmail webmail
Apache with SSL and PHP

Assuming that you have a static IP address (or you use a service such as dyndns with your dynamic IP address), then you might want an effective way to check your e-mail when you're out of town. The solution that I have chosen is to set up a webmail server, Squirrelmail, that I can access remotely using any web browser.

The first step is to install a web server. Most of the rest of the world uses Apache; we will too. We will also install PHP (PHP4, actually) at the same time, since Squirrelmail is a PHP program. The version numbers shown in the code listing below might be different by the time you read this. Please adjust them accordingly. Don't just copy and paste the commands into your terminal!

# emerge net-www/apache dev-lang/php net-www/mod_ssl
# ebuild /var/db/pkg/dev-lang/php-4.1.2-r7/php-4.1.2-r7.ebuild config
# ebuild /var/db/pkg/net-www/mod_ssl-2.8.8/mod_ssl-2.8.8.ebuild config
# nano -w /etc/apache/conf/apache.conf
You want to make sure that you install mod_ssl if you want Apache to have SSL support. If you want to check your e-mail remotely without sending your password across the internet unencrypted, then you do want SSL!.

You should take a good look at /etc/apache/conf/apache.conf, since Apache is very customizable. By default the Apache document root (where it first looks for html files when you connect to http://www.servername.foo or http://localhost) is /home/httpd/htdocs; feel free to relocate it if you wish.

# Do NOT add a slash at the end of the directory path.
#
DocumentRoot "/home/httpd/htdocs" (edit this line if desired)

# rc-update add apache default
 * apache added to runlevel default...
 * Caching service dependencies...               [ ok ]
 * rc-update complete.
# nano -w /etc/conf.d/apache

Use rc-update to add Apache to the default runlevel, and then edit /etc/conf.d/apache to add the following lines so that Apache automatically loads the SSL and PHP modules at start-up.

APACHE_OPTS="-D SSL -D PHP4"
# /etc/init.d/apache start
 * Starting Apache...                            [ OK ]
# lynx localhost

You can check to make sure your Apache web server is working by using any browser to connect to localhost. To make sure that SSL support is functional, use a browser to connect to https://localhost. The https prefix tells the browser to make a secure connection to the server using SSL. Graphical browsers will have a padlock icon somewhere indicating the secure connection.

When making a secure connection to your server, you will most likely receive a warning that the site's security certificate is not recognized. The mod_ssl ebuild installs a self-signed security certificate, which is intended to be used for testing purposes only. See the mod_ssl manual: http://localhost/doc/mod_ssl-2.8.8/html. For personal use a self-signed certificate is just fine.

Now we need to make sure that PHP is working correctly. The first step is to create a simple PHP file and put it in the Apache DocumentRoot directory.

# echo "<? phpinfo(); ?>" > /home/httpd/htdocs/test.php
# lynx http://localhost/test.php
                                                           phpinfo() (p1 of 26)
                                  PHP Logo
 
                             PHP Version 4.0.6
 
     System Linux my.server.edu 2.4.10 #1 Tue Oct 9 16:33:50 Local
           time zone must be set--see zic manuali686 i686 unknown
                           Build Date Oct 16 2001

If you see something like the above, then Apache is successfully processing PHP code.

If you look at the full output of the above, you'll find out that the test.php script gives out a lot of information about your system. You should probably get rid of it once you know that php is working. (Or you can do what I do, and just mv test.php test.phps. Apache will display test.phps as a PHP source file instead of executing the script.)
Courier IMAP

Squirrelmail is a PHP application, but it relies on an IMAP server as the glue between the web server and e-mail. Since Gentoo linux uses Maildir mail folders by default, Courier IMAP is a good choice.

# emerge net-mail/courier-imap
# rc-update add courier-imapd default
 * courier-imapd added to runlevel default...
 * Caching service dependencies...                        [ ok ]
 * rc-update complete.
# nano -w /etc/courier-imap/authdaemonrc
# /etc/init.d/courier-imapd start
# telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
* OK Courier-IMAP ready. Copyright 1998-2001 Double Precision, Inc.  
See COPYING for distribution information.
1 LOGIN grant passwd (<-- replace "grant" w/ your username 
                          and "passwd" w/ your password)
1 OK LOGIN OK
(Hit <ctrl>-"]" and type "quit" to exit)
##NAME: authmodulelist:0
#
# The authentication modules that are linked into authdaemond.  The
# default list is installed.  You may selectively disable modules simply
# by removing them from the following list.  The available modules you
# can use are: authcustom authcram authuserdb authpam

#authmodulelist="authcustom authcram authuserdb authpam"
authmodulelist="authpam"
Courier IMAP usually hardwires the name of the user's Maildir-type inbox directory that is used in its rc start-up script, /usr/lib/courier-imap/imapd.rc, to be $HOME/Maildir. Gentoo linux, however, uses $HOME/.maildir instead, so the courier-imap ebuild modifies the imapd.rc script to use $MAILDIR, which it obtains from the Gentoo init script /etc/init.d/courier-imap. If you choose to use a home user's mailbox other than .maildir, you'll need to modify the MAILDIR=.maildir entry in courier-imap's init script.

If you want Courier IMAP to have SSL support you just need to make the IMAP SSL certificate (and tell courier-imap where to find it),

# /usr/sbin/mkimapdcert 

and then start up imap-ssl.

# rc-update add courier-imapd-ssl default
# /etc/init.d/courier-imapd-ssl start

You can verify that imap is working by using any IMAP-enabled mail client, such as netscape, kmail, or mutt.

# mutt -f imap://localhost
Squirrelmail

Fortunately, installing and configuring Squirrelmail, once all of the components are in place, is straightforward.

# emerge net-mail/squirrelmail
# cd /home/httpd/htdocs
# cd squirrelmail
# ./configure
If your Apache DocumentRoot is not /home/httpd/htdocs, you will want to edit the net-mail/squirrelmail ebuild to point there.

For squirrelmail to work correctly, you need to make sure that all of the files are owned by the user that Apache runs as (the squirrelmail ebuild assumes that user is "apache"). Use ./configure to select option 2.

SquirrelMail Configuration : Read: config.php
---------------------------------------------------------
Server Settings
1.  Domain               : my.server.edu
2.  IMAP Server          : localhost
3.  IMAP Port            : 143
4.  Use Sendmail/SMTP    : SMTP
6.    SMTP Server        : localhost
7.    SMTP Port          : 25
8.    Authenticated SMTP : false
9.  Server               : courier
10. Invert Time          : false
11. Delimiter            : detect
 
R   Return to Main Menu
C.  Turn color off
S   Save data
Q   Quit
 
Command >>

Make sure that Server is set to courier. Return to the main menu and select option 4, General Options.

SquirrelMail Configuration : Read: config.php
---------------------------------------------------------
General Options
1.  Default Charset        : iso-8859-1
2.  Data Directory         : ../data/
3.  Attachment Directory   : /tmp/
4.  Default Left Size      : 150
5.  Usernames in Lowercase : false
 
R   Return to Main Menu
C.  Turn color off
S   Save data
Q   Quit
 
Command >>

I use the data directory in the package, although it would be better security to use one outside the Apache document tree. I also use /tmp as my directory to store attachments.

Before using squirrelmail, we first have to modify the PHP configuration file, /etc/php4/php.ini, to turn on register variables and then restart apache:

# nano -w /etc/php4/php.ini
# /etc/init.d/apache restart
; You should do your best to write your scripts so that they do not require
; register_globals to be on;  Using form variables as globals can easily lead
; to possible security problems, if the code is not very well thought of.
;register_globals = Off
register_globals = On

Now you can browse to https://localhost/squirrelmail/, and it should work!

# lynx https://localhost/squirrelmail/
                                           SquirrelMail - Login
                               [sm_logo.jpg]
 
                      SquirrelMail version 1.2.0 [rc2]
                    By the SquirrelMail Development Team
 
                             SquirrelMail Login
 
       Name: ____________________
   Password: ____________________
 
                                   Login

(I don't really suggest using lynx with Squirrelmail, but you could!)

Personal Information Management
Evolution with Palm support

Evolution is an exceptionally nice Personal Information Management tool that syncs with a Palm pilot quite well. The first step is to emerge evolution. If you do intend to use evolution with a Palm pilot, make sure "pda" is in your USE variables in /etc/make.conf before emerging evolution.

# emerge --pretend net-mail/evolution

These are the packages that I would merge, in order.

Calculating dependencies................................ done!
[ebuild N  ] app-text/ghostscript-6.50-r2 to /
[ebuild N  ] app-text/tetex-1.0.7-r4 to /
[ebuild   U] media-libs/freetype-2.0.5-r1 to /
[ebuild N  ] gnome-base/ORBit-0.5.12-r1 to /
[ebuild N  ] media-libs/giflib-4.1.0-r3 to /
[ebuild N  ] media-libs/imlib-1.9.10-r1 to /
[ebuild N  ] gnome-base/gnome-libs-1.4.1.2-r2 to /
[ebuild N  ] dev-libs/libxml-1.8.16 to /
[ebuild N  ] gnome-base/libglade-0.17-r3 to /
[ebuild N  ] media-libs/gdk-pixbuf-0.14.0 to /
[ebuild N  ] gnome-base/gnome-print-0.34 to /
[ebuild N  ] dev-libs/popt-1.5 to /
[ebuild N  ] dev-util/intltool-0.12 to /
[ebuild N  ] gnome-base/oaf-0.6.7 to /
[ebuild N  ] gnome-base/bonobo-1.0.17 to /
[ebuild N  ] dev-libs/libunicode-0.4-r1 to /
[ebuild N  ] dev-util/guile-1.5.4 to /
[ebuild N  ] gnome-base/gconf-1.0.7-r2 to /
[ebuild N  ] gnome-base/gnome-vfs-1.0.3 to /
[ebuild N  ] gnome-extra/gal-0.18.1 to /
[ebuild N  ] gnome-base/control-center-1.4.0.1-r3 to /
[ebuild N  ] dev-libs/pilot-link-0.9.6-r3 to /
[ebuild N  ] app-text/scrollkeeper-0.2 to /
[ebuild N  ] gnome-base/gnome-core-1.4.0.4-r3 to /
[ebuild N  ] gnome-extra/gnome-pilot-0.1.64 to /
[ebuild N  ] gnome-base/libghttp-1.0.9-r1 to /
[ebuild N  ] gnome-extra/gtkhtml-1.0.0 to /
[ebuild N  ] gnome-extra/bonobo-conf-0.14 to /
[ebuild N  ] app-arch/zip-2.3-r1 to /
[ebuild N  ] app-arch/unzip-5.42 to /
[ebuild N  ] net-www/mozilla-0.9.6-r4 to /
[ebuild N  ] net-mail/evolution-1.0-r2 to /

# emerge net-mail/evolution 

Unfortunately, the evolution build takes slightly longer than forever (notice that mozilla is a dependency!); have several gallons of coffee/tea while you wait.

While building evolution the necessary Palm pilot tools should have been built as well. To make sure that regular users can sync a pilot we need to make a couple of changes to the serial port permissions. I'll assume your Palm cradle plugs into the first serial port (/dev/ttyS0, or /dev/tts/0 in "devfs" notation).

# groupadd serial
# chown root.serial /dev/tts/0
# chmod g+rw /dev/tts/0
# ls -l /dev/tts/0
crw-rw----    1 root     serial     4,  64 Dec 31  1969 /dev/tts/0
# ln -s /dev/tts/0 /dev/pilot
# nano -w /etc/group (add appropriate users to the serial group)

We've added a "serial" group to the system, and you should add any users who need to use the serial port (any Palm pilot users) to the serial group. We've given the serial group "rw" permissions on /dev/tts/0, and for future reference we have made a /dev/pilot symbolic link to /dev/tts/0. Thanks to recent changes in how devfs is handled on Gentoo these changes will persist after rebooting.

Users of pre-rc6-r13 can either upgrade sys-apps/baselayout and sys-apps/devfsd (and merge in any "._cfg*" files in /etc that result), or simply add the appropriate permissions and symlink in /etc/devfsd.conf.

Users will want to use the tools/Pilot settings menu option in evolution to set up the Gnome pilot software. Don't forget to set up the "Pilot Conduits" as well as the "Pilot Link" in the Gnome Control Center.