Sie sind auf Seite 1von 8

SquirrelMail 1.4.

6 on RedHat Linux 9
Part 1 - Installing SquirrelMail & Configuring the Apache Virtual Host

Requirements
RedHat Linux
Apache HTTPD
IMAP Server
PHP with IMAP
SquirrelMail 1.4.6
The SquirrelMail tutorial is the second part of a series I started this week on installing webmail access
on a server. We began with setting up an IMAP server using Dovecot that provides the back-end and
now we conclude with SquirrelMail being the front-end. This tutorial will teach you how to install and
configure the SquirrelMail 1.4.6 package, set up an Apache virtual host for your webmai sitel, and
verify your installation actually works. Before you continue you should already have Sendmail or
another SMTP server and Dovecot or another other IMAP server installed and working. My Sendmail
install uses SMTP AUTH to deny relaying abuse and that will play a part later on when configuring
SquirrelMail. Dovecot should be configured as an IMAP server and not necessarily utilizing SSL/TLS.
In Part 1 we'll download and install SquirrelMail and configure Apache for the webmail site.
At the time of this writing the latest stable version of SquirrelMail is 1.4.6 which is available at
http://www.squirrelmail.org/. Once again the target operating system is RedHat 9. I know it's kind of
dated and I promise one of these days I'll use a more up-to-date OS. We'll start by downloading the
SquirrelMail package.
Make sure you're logged in as root and are in your home directory. Start by downloading the
SquirrelMail gzip file using wget.
wget http://easynews.dl.sourceforge.net/sourceforge/squirrelmail/squirrelmail-1.4.6.tar.gz

Using tar we'll unzip the package and then move into the squirrelmail-1.4.6 directory that was
extracted.
tar zxf squirrelmail-1.4.6.tar.gz
cd squirrelmail-1.4.6
SquirrelMail comes with a text-based configuration utility that makes creating the config file. We'll do
the SquirrelMail configuration in the second part of this guide. Next we're going to set up an Apache
virtual host for our webmail site. We're going to create some directories, move the SquirrelMail files to
the document root, move the data folder outside the document root, and change ownership of the data
folder to the apache user (or whatever user your httpd process runs as). I chose to install SquirrelMail
in /home in a directory called squirrelmail. You may want to put it somewhere else like in /var or
/var/www. It's up to you.
cd /home
mkdir squirrelmail
cd squirrelmail
mkdir html
mkdir html/cgi-bin
mkdir logs
mv /root/squirrelmail/* ./html/
mv html/data/ ./sqdata
chown -R apache.apache sqdata

Let me explain the structure. The html directory is the document root of the webmail site. We also
create a cgi-bin directory for our own purposes (not SquirrelMail) if we ever need it in the future. A
logs directory is created for our web server logs. The contents of the extracted squirrelmail tar.gz is
moved to the html directory. We then move the data directory from html to /home/squirrelmail/sqdata -
thus renaming it. It's not a requirement to rename it, it's merely so we know it's SquirrelMail data (your
address book, preferences, signature and other files are stored there). We then recursively change
ownership of sqdata to the apache user & group. SquirrelMail will need to be able to write to this
directory and our httpd process runs as apache. Typically httpd runs as apache by default if you
installed via RPM's. If you didn't change it in httpd.conf then yours should be the same.
Next we'll configure an Apache virtual host for our webmail site. If this is the first time you're
configuring Apache then you'll have to edit two lines (ServerName and NameVirtualHost) located in
/etc/httpd/conf/httpd.conf. Use your machine's IP address for both of these directives.
ServerName 192.168.1.110
NameVirtualHost 192.168.1.110:80
Open /etc/httpd/conf/httpd.conf with an editor like vi or pico and scroll all the way to the end of the
file. We'll add our new VirtualHost there.
vi /etc/httpd/conf/httpd.conf
<VirtualHost 192.168.1.110:80>
ServerAdmin admin@domain.com
ServerName 192.168.1.110
DocumentRoot /home/squirrelmail/html
ScriptAlias /cgi-bin/ /home/squirrelmail/html/cgi-bin/
ErrorLog /home/squirrelmail/logs/error_log
CustomLog /home/squirrelmail/logs/access_log combined
</VirtualHost>
We created a name based virtual host and will listen on port 80. We use six directives to configure our
site (ServerAdmin, ServerName, DocumentRoot, ScriptAlias, ErrorLog, and CustomLog).
• ServerAdmin specifies the email address of the administrator (that's you).
• ServerName is the IP address or FQDN of your site. I used an IP for this example but you'll
want to use something like webmail.yourdomain.com. Be sure to add whatever host you use to
your DNS zone file otherwise your webmail site won't be accessible. Read my BIND tutorial
for more information on adding a new host.
• DocumentRoot is the path to your HTML files or otherwise known as your web site root.
• ScriptAlias is used to create a cgi-bin for executable CGI/Perl scripts. It's mapped to
http://host.yourdomain.com/cgi-bin/.
• ErrorLog defines the name of your web server error file for this site. Any 404, 500, and other
HTTP or PHP errors will be written to this file.
• CustomLog creates a log of people that access your web site. At the end we use combined to
tell Apache to use the combined format for log file entries. If you wanted to use a web server
log analysis program like Awstats to parse your logs for HTML report creation then using the
combined format is ideal.
Save your changes and exit your editor. We have to tell Apache to reload httpd.conf and this can be
accomplished by restarting the httpd process (or using graceful).
/etc/init.d/httpd restart

That's it for getting your webmail site up. The next phase will be configuring SquirrelMail.
Change your Hostname without Rebooting in RedHat Linux
Requirements
RedHat Linux (should apply to 7.x and up)
This tutorial covers changing your hostname in RedHat Linux without having to do a reboot for the
changes to take effect. I've tested this on RedHat 7.3, 9, Fedora Core 3, and CentOS 4.1. It should work
for all the versions in between since they all closely follow the same RedHat configuration. What's the
point of this tutorial? Never reboot if you don't have to and keep your uptime intact.
Make sure you are logged in as root and move to /etc/sysconfig and open the network file in vi.
cd /etc/sysconfig
vi network

Look for the HOSTNAME line and replace it with the new hostname you want to use. In this example
I want to replace localhost with redhat9.
HOSTNAME=redhat9

When you are done, save your changes and exit vi. Next we will edit the /etc/hosts file and set the new
hostname.
vi /etc/hosts

In hosts, edit the line that has the old hostname and replace it with your new one.
192.168.1.110 redhat9

Save your changes and exit vi. The changes to /etc/hosts and /etc/sysconfig/network are necessary to
make your changes persistent (in the event of an unscheduled reboot).
Now we use the hostname program to change the hostname that is currently set.
hostname redhat9
And run it again without any parameters to see if the hostname changed.
hostname

Finally we will restart the network to apply the changes we made to /etc/hosts and
/etc/sysconfig/network.
service network restart
To verify the hostname has been fully changed, logout of your system and you should see your new
hostname being used at the login prompt and after you've logged back in.

Quick, painless, and you won't lose your server's uptime.

Bind Multiple IP Addresses to a Single Network Interface Card


(NIC)
Requirements
RedHat Linux
This tutorial demonstrates how to bind multiple IP addresses to a single NIC. By using multiple IP's
you can run a service under a specific IP while having another service under a different one (for
example, have HTTP on one and SMTP on another), or create a private LAN using a local IP and have
the alias hold your Internet IP (such as NAT). One of the major benefits is that you don't need a
physical adapter for each IP but instead can create many virtual ones tied to a single physical card. The
instructions provided apply to RedHat, Fedora, and CentOS. I'll be using LAN IP's in this example, so
replace them with the ones you'll be using.
The network scripts are located in /etc/sysconfig/network-scripts/. Go into that directory.
cd /etc/sysconfig/network-scripts/

The file we're interested in is ifcfg-eth0, the interface for the Ethernet device. If you have a second
Ethernet device then there would be an ifcfg-eth1 file and so on for each adapter you have installed.
Let's assume we want to bind three additional IP's (192.168.1.111, 192.168.1.112, and 192.168.1.113)
to the NIC. We need to create three alias files while ifcfg-eth0 maintains the primary IP address. This is
how we'll set up the aliases to bind the IP addresses.
Adapter IP Address Type
-----------------------------------
eth0 192.168.1.110 Primary
eth0:0 192.168.1.111 Alias 1
eth0:1 192.168.1.112 Alias 2
eth0:2 192.168.1.113 Alias 3
The :X (where X is the interface number) is appended to the interface file name to create the alias. For
each alias you create you assign a number sequentially. For this example we will create aliases for
eth0. Make a copy of ifcfg-eth0 for the three aliases.
cp ifcfg-eth0 ifcfg-eth0:0
cp ifcfg-eth0 ifcfg-eth0:1
cp ifcfg-eth0 ifcfg-eth0:2

Take a look inside ifcfg-eth0 and review the contents.


more ifcfg-eth0

We're interested in only two lines (DEVICE and IPADDR). We'll rename the device in each file to its
corresponding interface alias and change the IP's. We'll start with ifcfg-eth0:0. Open ifcfg-eth0:0 in vi
and change the two lines so they have the new interface and IP address.
vi ifcfg-eth0:0
DEVICE=eth0:0
IPADDR=192.168.1.111

Save ifcfg-eth0:0 and edit the other two alias files (ifcfg-eth0:1 and ifcfg-eth0:2) so they have the new
interfaces and IP addresses set (follow the table from above). Once you save all your changes you can
restart the network for the changes to take effect.
service network restart

To verify all the aliases are up and running you can run ifconfig (depending on how many new IP's you
set up, you can use ifconfig | more to pause the output).
ifconfig
You can also test the IP's by pinging them from a different machine. If everything is working then there
should be a response back.
ping 192.168.1.111
ping 192.168.1.112
ping 192.168.1.113
Looks like everything is working like a charm. With the new IP's you can set up sites in Apache bound
to a dedicated IP, anonymous FTP, and many other things. If you run into any problems during
configuration, please post your questions to the forum.

Das könnte Ihnen auch gefallen