The Perfect Server - Ubuntu 9.04 [ISPConfig 3] - Page 4

12 Install Postfix, Courier, Saslauthd, MySQL, phpMyAdmin, rkhunter, binutils

We can install Postfix, Courier, Saslauthd, MySQL, phpMyAdmin, rkhunter, and binutils with a single command:

aptitude install postfix postfix-mysql postfix-doc mysql-client mysql-server courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl libsasl2-2 libsasl2-modules libsasl2-modules-sql sasl2-bin libpam-mysql openssl maildrop getmail4 rkhunter binutils

You will be asked the following questions:

New password for the MySQL "root" user: <-- yourrootsqlpassword
Repeat password for the MySQL "root" user: <-- yourrootsqlpassword
Create directories for web-based administration? <-- No
General type of mail configuration: <-- Internet Site
System mail name: <-- server1.example.com
SSL certificate required <-- Ok

We want MySQL to listen on all interfaces, not just localhost, therefore we edit /etc/mysql/my.cnf and comment out the line bind-address = 127.0.0.1:

vi /etc/mysql/my.cnf

[...]
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address           = 127.0.0.1
[...]

Then we restart MySQL:

/etc/init.d/mysql restart

Now check that networking is enabled. Run

netstat -tap | grep mysql

The output should look like this:

root@server1:~# netstat -tap | grep mysql
tcp        0      0 *:mysql                 *:*                     LISTEN      8474/mysqld
root@server1:~#

During the installation, the SSL certificates for IMAP-SSL and POP3-SSL are created with the hostname localhost. To change this to the correct hostname (server1.example.com in this tutorial), delete the certificates...

cd /etc/courier
rm -f /etc/courier/imapd.pem
rm -f /etc/courier/pop3d.pem

... and modify the following two files; replace CN=localhost with CN=server1.example.com (you can also modify the other values, if necessary):

vi /etc/courier/imapd.cnf

[...]
CN=server1.example.com
[...]

vi /etc/courier/pop3d.cnf

[...]
CN=server1.example.com
[...]

Then recreate the certificates...

mkimapdcert
mkpop3dcert

... and restart Courier-IMAP-SSL and Courier-POP3-SSL:

/etc/init.d/courier-imap-ssl restart
/etc/init.d/courier-pop-ssl restart

 

13 Install Amavisd-new, SpamAssassin, And Clamav

To install amavisd-new, SpamAssassin, and ClamAV, we run

aptitude install amavisd-new spamassassin clamav clamav-daemon zoo unzip bzip2 arj nomarch lzop cabextract apt-listchanges libnet-ldap-perl libauthen-sasl-perl clamav-docs daemon libio-string-perl libio-socket-ssl-perl libnet-ident-perl zip libnet-dns-perl

 

14 Install Apache2, PHP5, phpMyAdmin, FCGI, suExec, Pear, And mcrypt

Apache2, PHP5, phpMyAdmin, FCGI, suExec, Pear, and mcrypt can be installed as follows:

aptitude install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-gd php5-mysql php5-imap phpmyadmin php5-cli php5-cgi libapache2-mod-fcgid apache2-suexec php-pear php-auth php5-mcrypt mcrypt php5-imagick imagemagick libapache2-mod-suphp

You will see the following question:

Web server to reconfigure automatically: <-- apache2
Configure database for phpmyadmin with dbconfig-common? <-- Yes
Password of your database's administrative user: <-- yourrootsqlpassword
MySQL application password for phpmyadmin: <-- [blank]

Then run the following command to enable the Apache modules suexec, rewrite, ssl, actions, and include:

a2enmod suexec rewrite ssl actions include

Secure phpMyAdmin by deleting the /etc/phpmyadmin/htpasswd.setup file...

rm -f /etc/phpmyadmin/htpasswd.setup

... and remove or comment out the following section in /etc/phpmyadmin/apache.conf:

vi /etc/phpmyadmin/apache.conf

[...]
## Authorize for setup
#<Directory /usr/share/phpmyadmin/setup>
#    <IfModule mod_authn_file.c>
#    AuthType Basic
#    AuthName "phpMyAdmin Setup"
#    AuthUserFile /etc/phpmyadmin/htpasswd.setup
#    </IfModule>
#    Require valid-user
#</Directory>
[...]

Restart Apache afterwards:

/etc/init.d/apache2 restart

 

15 Install PureFTPd And Quota

PureFTPd and quota can be installed with the following command:

aptitude install pure-ftpd-common pure-ftpd-mysql quota quotatool

Edit the file /etc/default/pure-ftpd-common...

vi /etc/default/pure-ftpd-common

... and make sure that the start mode is set to standalone and set VIRTUALCHROOT=true:

[...]
STANDALONE_OR_INETD=standalone
[...]
VIRTUALCHROOT=true
[...]

Then restart PureFTPd:

/etc/init.d/pure-ftpd-mysql restart

Edit /etc/fstab. Mine looks like this (I added ,usrquota,grpquota to the partition with the mount point /):

vi /etc/fstab

# /etc/fstab: static file system information.
#
# Use 'vol_id --uuid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
# / was on /dev/mapper/server1-root during installation
UUID=b8d265bc-5959-404d-a68e-8dc1c76f18d6 /               ext3    relatime,errors=remount-ro,usrquota,grpquota 0       1
# /boot was on /dev/sda5 during installation
UUID=01e9c3c7-2ad0-4f52-a356-18290517b362 /boot           ext2    relatime        0       2
# swap was on /dev/mapper/server1-swap_1 during installation
UUID=c1e0bcbb-5c73-4bd2-a7b2-8beeb7526200 none            swap    sw              0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0

To enable quota, run these commands:

touch /quota.user /quota.group
chmod 600 /quota.*
mount -o remount /

quotacheck -avugm
quotaon -avug

 

16 Install MyDNS

Before we install MyDNS, we need to install a few prerequisites:

aptitude install g++ libc6 gcc gawk make texinfo libmysqlclient15-dev

MyDNS is not available in the Ubuntu 9.04 repositories, therefore we have to build it ourselves as follows:

cd /tmp
wget http://heanet.dl.sourceforge.net/sourceforge/mydns-ng/mydns-1.2.8.27.tar.gz
tar xvfz mydns-1.2.8.27.tar.gz
cd mydns-1.2.8
./configure
make
make install

Next we create the start/stop script for MyDNS:

vi /etc/init.d/mydns

#! /bin/sh
#
# mydns         Start the MyDNS server
#
# Author:       Philipp Kern <phil@philkern.de>.
#               Based upon skeleton 1.9.4 by Miquel van Smoorenburg
#               <miquels@cistron.nl> and Ian Murdock <imurdock@gnu.ai.mit.edu>.
#

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/sbin/mydns
NAME=mydns
DESC="DNS server"

SCRIPTNAME=/etc/init.d/$NAME

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

case "$1" in
  start)
        echo -n "Starting $DESC: $NAME"
        start-stop-daemon --start --quiet \
                --exec $DAEMON -- -b
        echo "."
        ;;
  stop)
        echo -n "Stopping $DESC: $NAME"
        start-stop-daemon --stop --oknodo --quiet \
                --exec $DAEMON
        echo "."
        ;;
  reload|force-reload)
        echo -n "Reloading $DESC configuration..."
        start-stop-daemon --stop --signal HUP --quiet \
                --exec $DAEMON
        echo "done."
        ;;
  restart)
        echo -n "Restarting $DESC: $NAME"
        start-stop-daemon --stop --quiet --oknodo \
                --exec $DAEMON
        sleep 1
        start-stop-daemon --start --quiet \
                --exec $DAEMON -- -b
        echo "."
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

Then we make the script executable and create the system startup links for it:

chmod +x /etc/init.d/mydns
update-rc.d mydns defaults

 

17 Install Vlogger And Webalizer

Vlogger and webalizer can be installed as follows:

aptitude install vlogger webalizer

 

18 Install Jailkit

Jailkit is needed only if you want to chroot SSH users. It can be installed as follows (important: Jailkit must be installed before ISPConfig - it cannot be installed afterwards!):

aptitude install build-essential autoconf automake1.9 libtool flex bison

cd /tmp
wget http://olivier.sessink.nl/jailkit/jailkit-2.5.tar.gz
tar xvfz jailkit-2.5.tar.gz
cd jailkit-2.5
./configure
make
make install
cd ..
rm -rf jailkit-2.5*

 

19 Install fail2ban

This is optional but recommended, because the ISPConfig monitor tries to show the fail2ban log:

aptitude install fail2ban

Share this page:

36 Comment(s)

Add comment

Comments

From: jbphoto at: 2009-05-30 06:02:41

This setup works great, though it seems that I am a little confused about the end config.

I am looking to have webmail (squirrel or other) available for each subdomain. As this set up is, it is available under server1. example.com/webmail/  and that works well.

 

I dont have an "umbrella" domain for hosting. What I am hoping to set up is something like

domain1.com

domain2.com

domain3.com

and have webmail.domain1.com be the webmail for that domain, and again for each of the other domains. 

Any suggestions, or a link to help would be greatly appreciated. I have had no luck finding anything that gets me to a place that helps. I am set up with the server config from this guide, and would like to be able to get this one set up to play with. 

 

Any help is greatly appreciated.

 

Thanks

From: Anonymous at: 2009-06-04 19:35:00

you could just create a symbolic like in each of your sites root directories to the same location you did in this tutorial. For example lets assume your apache setup stores each site in /var/www/sites/, so site1 would be located here: /var/www/sites/site1 & site2, here: /var/www/sites/site2 To enable access to squirrelmail from both of these domains just enter:  ln -s /usr/share/squirrelmail/ /var/www/sites/site1 ln -s /usr/share/squirrelmail/ /var/www/sites/site2 Hope this helps, Good Luck!

From: Nakarti at: 2009-07-22 14:07:33

That sounds like something you'd want to configure with Apache, since it allows you to configure multiple sites with different directories. So for example, your main site is domain1.com, with all the regular stuff and it responds to www.domain1.com Assuming you have more than one IP to your webserver, webmail.domain1.com can be a different site in apache, listening to the other interface, and serving only the squirrelmail tree. You can even do this if the webmail files are under the main web directory, just that people would also be able to get webmail with www.domain1.com/webmail/ I played with the idea before, but I only have one IP, and putting things on different ports was less convenient than just different folders(with symlinks)

From: Shimona at: 2009-10-29 11:48:25

When I run :aptitude install ssh openssh-server

 I get errors like :

Couldn't find any package matching "ssh".

Couldn't find any package whose name or description matched "openssh-server".

Can someone help me please?

From: merkur at: 2009-05-16 15:50:25

Cpt. Obvious says:

If you don't restart your server before using ISPConfig you need to start MyDNS by hand:

/etc/init.d/mydns start

BTW: This Howto also works with Ubuntu 9.04 JeOS on AMD64 without any change.

From: boynas at: 2009-06-30 18:17:49

Since we are installing MyDNS from source...

 Does that mean that our box will be broken if we update our box using the repositories... as we should do?

Please advise.

From: ATRAN at: 2009-05-13 09:44:10

how can i use Dovecot instead of Courier in this howto?

 is it just a simple change or will it be too complicated to use Dovecot instead?

 does ISPConfig works better with Courier or Dovecot?

From: GenX at: 2009-05-14 14:35:55

I wonder about the same thing.

I would love to see a Perfect Server Howto covering the following:

Ubuntu 9.04
Postfix
Dovecot with MySQL integration for virtual users
myDNS
ISPConfig3
Squirrelmail

and round this off with the other bits and pieces already covered here.

There are many of these tutorials online already, but none of them actually work.

Are we going to see this setup here?

From: David at: 2009-05-25 16:17:46

Me too.

 I'm setting up a configuration like this, with Dovecot&Virtual Users over mysql db, on a fresh Debian intallation.

 I didn't find any documentation about this.

From: OmegaQuest at: 2009-07-04 14:25:22

I seem to have a problem here.  I followed everthing to the letter and everything seems to work great except I have problems uploading/removing anything when I log into the FTP under the users account.

When I log in to FTP, I go to the users directory automatically.  But the Owner shows 5003 (not web2 for example).

The strange thing is, if I creat them an SSH account SFTP and login with that the upload works fine and the Owner shows web2.

I did a look at the root web directory permissions/groups for the users (/var/www/clients/client4/web2) inside SSH (PuTTY) and the permissions show properly.

Any idea why the users has to have AND login via their SSH account (SFTP - Port 22) to be able to upload stuff and not just regular FTP (Port 21)????

Thanks

From: Anonymous at: 2009-10-27 12:47:18

I added the quota stuff in my fstab file # /etc/fstab: static file system information. # # Use 'vol_id --uuid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # proc /proc proc defaults 0 0 # / was on /dev/sda1 during installation UUID=fc726e41-4e5e-4493-9518-ceaed04ab8cb / ext3 relatime,errors=remount-r,usrquota,grpquotao 0 1 # swap was on /dev/sda5 during installation UUID=bd3ff276-b49b-46fd-b26c-3d5729995f42 none swap sw 0 0 /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0 But when I run the commands root@server:/# mount -o remount / mount: / not mounted already, or bad option root@server:/# quotacheck -avugm quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option. What did I do wrong?

From: ctroyp at: 2009-09-27 03:47:18

Just a FYI, in step 12, you mention that phpmyadmin is being installed in this step, when it is actually being installed in step 14.

 Also, thanks for another great tutorial falko!

From: Sn3akyP3t3 at: 2009-09-15 23:03:06

Attempting to install "apache2-suexec" fails on Ubuntu Server LTS 8.04.3.  I get error "Couldn't find any package whose name or description matched "apache2-suexec".  I will ignore this problem for now since the server will be redone next year and currently there are no plans to run anything CGI.  If anyone knows of the correct method please inform me.

From: Sn3akyP3t3 at: 2009-09-16 00:55:47

I had some difficulty installing postfix, but running this command prior to the mail setup portion of this tutorial fixes the problem.


sudo /etc/init.d/exim4 start

From: at: 2012-03-16 05:35:33

Hi..Can someone help me with my problem here? After enter this command - sudo apt-get install libsas12-modules libsas12-modules-sql libgsas17\libauthen-sasl-cyrus-perl sas12-bin libpam-mysql

And somehow having like below error.Have no problem with installing MySql & Postfix..


Reading package lists... Done
Building dependency tree      
Reading state information... Done
E: Unable to locate package libsas12-modules
E: Unable to locate package libsas12-modules-sql
E: Unable to locate package libgsas17libauthen-sasl-cyrus-perl
E: Unable to locate package sas12-bin

FYI, am just doing some testing & tutorial How To Set Up Mail Server on Gnu/ Linux..Hope there's someone out there can help  me with it..Thanks a mill..really appreciate it!!~

 

From: jon at: 2009-05-22 14:19:50

Hi, what a great Howto. It all worked flawlessly except on the end where I get this.

 ERROR: Unable to load SQL-Dump into database table.

Ant suggestions to what it might be?

 

/jon

From: Dalibor at: 2009-06-19 10:16:42


on some servers there is just
apt-get
so if you want to use aptitude
you need to type
sudo apt-get install aptitude

on some servers there is a problem with locales
annoying error  like

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

to fix this
sudo apt-get install --reinstall language-pack-en
then
sudo dpkg-reconfigure locales

that worked for me..
best regards and once more gr8 tut m8

From: Martin Siron at: 2009-06-10 03:47:52

I followed the whole guide threw every details everything worked untill I got to the webmail part.

The installation went fine, when I went on 192.168.1.50/webmail (the IP I set up because 192.168.1.100 was taken by the TV, and 192.168.0.* wasnt available) it worked, showed me the login and everything, but when I went on server1.mwd.com (the dns I set up,) it showed "Page Not Found!"

I went back threw it twice, reinstalled it a second time, but still dosnt work, hostname and hostname -f commands show the right host name, I have the right domain and host name, IP address, gateway, subnet. I think though I need a different Name Server, I entered 192.168.1.1, because that's what it showed at first...

From: Anonymous at: 2009-06-10 06:26:18

Awesome tutorial, only thing that had me for a bit was my virtualhosts were working on the main domain but not www.

Had to remove the apache default config and restart apache in order for ISPConfig to control all the vhosts.

# sudo rm /etc/apache2/sites-enabled/000-default

# sudo /etc/init.d/apache2 restart

From: Lesseps at: 2009-06-14 02:15:34

Great tutorial, thank you!

 This is the first time I have tried to set up a server, just trying to learn, in my LAN.

"Afterwards you can access ISPConfig 3 under http://server1.example.com:8080/ or http://192.168.0.100:8080/ [...] "

 http://server1.example.com:8080/ cannot be accessed  only http://192.168.0.100:8080/

The same for squirrelmail.

 What have I  done wrong? Server twice installed with the same result.

From: Anonymous at: 2009-07-31 13:53:19

Has to do with DNS.  The first DNS resolves to an IP and since this address and domain does not exist in your DNS it does not resolve correctly.

You should use a hostname and domain that you control. You would then configure the DNS to resolve to the correct IP.

One thing  to keep in mind is that you may need to create what is called "Split Brain DNS" where you have a DNS Server for inside your network and a DNS Server for Internet Facing clients.  The internal DNS Server will be given to your IP stack through DHCP.  The internal DNS Server will be configured to resolve mail.server.com to the Internal IP eg.. 192.168.x.x.  The External facing DNS will be configured to to resolve mail.server.com to the Publicly accessable IP address which would be on your Router of Firewall which will forward the correct ports through to the internal server.

 Thanks..

From: at: 2009-08-01 16:39:56

For use inside your your lan, you need to edit the /etc/hosts files on all rout machines (that's the simple way in you aren't able do this with dns locally)

You want to add the entry to the /etc/hosts file like this

ipaddress                               hostname

your.server.ip.address        whateveryouwanttocallyourserverlocally

so for an ipaddress of 192.168.2.100 and a hostname of localmachine you put an entry like this in the /etc/hosts file of all your machines:

192.168.2.100                    localmachine

 this will let you type localmachine/webmail into your browser bar on any machine that you have edited the hosts file, on your lan.

From: Keith at: 2009-08-28 02:21:50

Hey great set of tutorial's.  I have the same problem, thanks for the tip!

From: Anonymous at: 2009-07-10 16:32:28

thank you very much for this tutorial.

its  very heplful to me .

From: Nakarti at: 2009-07-21 20:31:30

I even successfully skipped some parts(like I don't want to get a build environment when my livecd is down to 400MB free.)

So why couldn't I get your other ubuntu squirrelmail tutorial to work?...

Also I don't get why sql would need to listen outside the network. I'll have to fiddle with that once it's production.

From: Nakarti at: 2009-07-30 03:00:01

I need to be sure which ports I need to forward, how to avoid that being a relay, and then give everyone this script(STOP for input at the >> spots) to save time if you have to redo the server, like I did(Four times, counting the Wrong version of ubuntu-6.06, missed steps and failed backout, virtual test system, and final working copy.)

 And since the comment system truncates me and I elected to not ;; every line:

http://www.nakarti.com/files/ThePerfectServerQuick.txt

From: Nakarti at: 2009-09-22 20:44:36

We're building various ssl keys but nowhere does it mention using or making sure work those https connections!

 Plus shouldn't there be some help installing the change_mysqlpass squirrelmail plugin?

From: Dunc at: 2009-07-20 13:04:26

Great tutorial, not that confident with servers so I approached with a fair bit of trepidation. The whole job could not have gone more smoothly. I had one 'moment' where I didn't read far enough ahead, and that was the note to change the download for the latest version of ISPConfig ready for the final stage, backtracked and got the latest version up and running at the first try. For anyone contemplating this install, it looks lengthy and complicated, take the steps steadily, check your typing and it will work. Thank You

From: Wolfgang at: 2009-08-20 12:44:06

Great Tutorial - Thank you very much!

However: What about Quotas using quota.user instead of aquota.user when using ext3 anyway?

"quotacheck: Your kernel probably supports journaled quota but you are not using it. Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown."

Using Google i found the following here: http://ubuntuforums.org/showthread.php?t=1014051&page=2

"See above, that file aquota.user already exists. The old quota format - vfsold - uses file quota.user instead. I guess we have no reason to use the old format anymore - and there is convertquota command for case of "historical" disks anyway."

 Regards Wolfgang

 

From: Gabriel at: 2009-09-24 05:33:11

Muy buen tutorial, segui paso a paso y funciono perfecto..

He creado 1 dominio y 1 usuario con ssh y quede impresionado

gracias

From: Anonymous at: 2009-11-09 11:43:18

very nice, maybe just fdisk the partitions and install some better sever.

You guys have to be NUTS to run ubuntu as a server! 

Funny, ppl think that they run ubuntu and they know really what linux is about...

and what that shite about disabling AppArmor? what the . . .


 

From: at: 2009-10-28 02:44:57

Hi just thought id mention i used ubuntu 8.10 64-bit server edition, and it worked without changing anything. Thanks again.

From: Patrick Johnson at: 2009-09-02 23:54:48

Just wanted to say that my setup went perfect with all the instructions provided. I hoping I can contribute to this forum in the future when I become very familiar with ISPConfig, or any PHP related help.

Thanks

From: Anonymous at: 2010-07-29 23:22:30

Just wanted to mention, this guide works with Ubuntu 10.04 as well.

From: Anonymous at: 2010-11-30 13:07:27

Warning: require_once(/var/www/domen/7sbmnfhedm8b2a1h/public_html/www/includes/defines.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/domen/7sbmnfhedm8b2a1h/public_html/www/index.php on line 21

Fatal error: require_once() [function.require]: Failed opening required '/var/www/domen/7sbmnfhedm8b2a1h/public_html/www/includes/defines.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/domen/7sbmnfhedm8b2a1h/public_html/www/index.php on line 21

heeelp!!

From: pravednik at: 2010-12-01 19:23:02

Warning: require_once() [function.require-once]: open_basedir restriction in effect. File(../lib/config.inc.php) is not within the allowed path(s): (.) in /usr/local/ispconfig/interface/web/index.php on line 33 Warning: require_once(../lib/config.inc.php) [function.require-once]: failed to open stream: Operation not permitted in /usr/local/ispconfig/interface/web/index.php on line 33 Fatal error: require_once() [function.require]: Failed opening required '../lib/config.inc.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/local/ispconfig/interface/web/index.php on line 33 ------------------------------------------- error, plz, help, i`m reinstall panel.