Install Perfect Mail Server with ISPConfig and Horde 5.0 on Debian Wheezy- Part-1 Rumi, October 13, 2014October 13, 2014 First, Install Basic Debian Wheezy. Make sure your network configurations are ok. Once installed start doing following- Fixing hostname- edit /etc/hosts. Make it look like this: vi /etc/hosts 127.0.0.1 localhost.localdomain localhost 192.168.0.100 server1.example.com server1 # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters Now run echo server1.example.com > /etc/hostname /etc/init.d/hostname.sh start Afterwards, run hostname hostname -f It is important that both show server1.example.com now! Update Your Debian Installation apt-get update apt-get upgrade Change The Default Shell /bin/sh is a symlink to /bin/dash, however we need /bin/bash, not /bin/dash. Therefore we do this: dpkg-reconfigure dash Use dash as the default system shell (/bin/sh)? <– No If you don't do this, the ISPConfig installation will fail. Synchronize the System Clock It is a good idea to synchronize the system clock with an NTP (network time protocol) server over the Internet. Simply run apt-get install ntp ntpdate and your system time will always be in sync. Install Postfix, Dovecot, MySQL, phpMyAdmin, rkhunter, binutils We can install Postfix, Dovecot, MySQL, rkhunter, and binutils with a single command: apt-get install postfix postfix-mysql postfix-doc mysql-client mysql-server openssl getmail4 rkhunter binutils dovecot-imapd dovecot-pop3d dovecot-mysql dovecot-sieve sudo You will be asked the following questions: General type of mail configuration: <– Internet Site System mail name: <– server1.example.com New password for the MySQL "root" user: <– yourrootsqlpassword Repeat password for the MySQL "root" user: <– yourrootsqlpassword Next open the TLS/SSL and submission ports in Postfix: vi /etc/postfix/master.cf Uncomment the submission and smtps sections as follows (leave -o milter_macro_daemon_name=ORIGINATING as we don't need it): […] submission inet n – – – – smtpd -o syslog_name=postfix/submission -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject # -o milter_macro_daemon_name=ORIGINATING smtps inet n – – – – smtpd -o syslog_name=postfix/smtps -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject # -o milter_macro_daemon_name=ORIGINATING […] Restart Postfix afterwards: /etc/init.d/postfix restart 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 Install Amavisd-new, SpamAssassin, And Clamav To install amavisd-new, SpamAssassin, and ClamAV, we run apt-get 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 The ISPConfig 3 setup uses amavisd which loads the SpamAssassin filter library internally, so we can stop SpamAssassin to free up some RAM: /etc/init.d/spamassassin stop update-rc.d -f spamassassin remove Install Apache2, PHP5, phpMyAdmin, FCGI, suExec, Pear, And mcrypt Apache2, PHP5, phpMyAdmin, FCGI, suExec, Pear, and mcrypt can be installed as follows: apt-get 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 libruby libapache2-mod-ruby libapache2-mod-python php5-curl php5-intl php5-memcache php5-memcached php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl memcached You will see the following question: Web server to reconfigure automatically: <– apache2 Configure database for phpmyadmin with dbconfig-common? <– No Then run the following command to enable the Apache modules suexec, rewrite, ssl, actions, and include (plus dav, dav_fs, and auth_digest if you want to use WebDAV): a2enmod suexec rewrite ssl actions include a2enmod dav_fs dav auth_digest Next open /etc/apache2/mods-available/suphp.conf… vi /etc/apache2/mods-available/suphp.conf … and comment out the <FilesMatch "\.ph(p3?|tml)$"> section and add the line AddType application/x-httpd-suphp .php .php3 .php4 .php5 .phtml – otherwise all PHP files will be run by SuPHP: <IfModule mod_suphp.c> #<FilesMatch "\.ph(p3?|tml)$"> # SetHandler application/x-httpd-suphp #</FilesMatch> AddType application/x-httpd-suphp .php .php3 .php4 .php5 .phtml suPHP_AddHandler application/x-httpd-suphp <Directory /> suPHP_Engine on </Directory> # By default, disable suPHP for debian packaged web applications as files # are owned by root and cannot be executed by suPHP because of min_uid. <Directory /usr/share> suPHP_Engine off </Directory> # # Use a specific php config file (a dir which contains a php.ini file) # suPHP_ConfigPath /etc/php5/cgi/suphp/ # # Tells mod_suphp NOT to handle requests with the type <mime-type>. # suPHP_RemoveHandler <mime-type> </IfModule> Restart Apache afterwards: /etc/init.d/apache2 restart If you want to host Ruby files with the extension .rb on your web sites created through ISPConfig, you must comment out the line application/x-ruby rb in /etc/mime.types: vi /etc/mime.types […] #application/x-ruby rb […] (This is needed only for .rb files; Ruby files with the extension .rbx work out of the box.) Restart Apache afterwards: /etc/init.d/apache2 restart Xcache Xcache is a free and open PHP opcode cacher for caching and optimizing PHP intermediate code. It's similar to other PHP opcode cachers, such as eAccelerator and APC. It is strongly recommended to have one of these installed to speed up your PHP page. Xcache can be installed as follows: apt-get install php5-xcache Now restart Apache: /etc/init.d/apache2 restart PHP-FPM Starting with ISPConfig 3.0.5, there is an additional PHP mode that you can select for usage with Apache: PHP-FPM. To use PHP-FPM with Apache, we need the mod_fastcgi Apache module (please don't mix this up with mod_fcgid – they are very similar, but you cannot use PHP-FPM with mod_fcgid). We can install PHP-FPM and mod_fastcgi as follows: apt-get install libapache2-mod-fastcgi php5-fpm Make sure you enable the module and restart Apache: a2enmod actions fastcgi alias /etc/init.d/apache2 restart Install Mailman Since version 3.0.4, ISPConfig also allows you to manage (create/modify/delete) Mailman mailing lists. If you want to make use of this feature, install Mailman as follows: apt-get install mailman Select at least one language, e.g.: Languages to support: <– en (English) Missing site list <– Ok Before we can start Mailman, a first mailing list called mailman must be created: newlist mailman root@server1:~# newlist mailman Enter the email of the person running the list: <– admin email address, e.g. listadmin@example.com Initial mailman password: <– admin password for the mailman list To finish creating your mailing list, you must edit your /etc/aliases (or equivalent) file by adding the following lines, and possibly running the `newaliases' program: ## mailman mailing list mailman: "|/var/lib/mailman/mail/mailman post mailman" mailman-admin: "|/var/lib/mailman/mail/mailman admin mailman" mailman-bounces: "|/var/lib/mailman/mail/mailman bounces mailman" mailman-confirm: "|/var/lib/mailman/mail/mailman confirm mailman" mailman-join: "|/var/lib/mailman/mail/mailman join mailman" mailman-leave: "|/var/lib/mailman/mail/mailman leave mailman" mailman-owner: "|/var/lib/mailman/mail/mailman owner mailman" mailman-request: "|/var/lib/mailman/mail/mailman request mailman" mailman-subscribe: "|/var/lib/mailman/mail/mailman subscribe mailman" mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman" Hit enter to notify mailman owner… <– ENTER root@server1:~# Open /etc/aliases afterwards… vi /etc/aliases … and add the following lines […] ## mailman mailing list mailman: "|/var/lib/mailman/mail/mailman post mailman" mailman-admin: "|/var/lib/mailman/mail/mailman admin mailman" mailman-bounces: "|/var/lib/mailman/mail/mailman bounces mailman" mailman-confirm: "|/var/lib/mailman/mail/mailman confirm mailman" mailman-join: "|/var/lib/mailman/mail/mailman join mailman" mailman-leave: "|/var/lib/mailman/mail/mailman leave mailman" mailman-owner: "|/var/lib/mailman/mail/mailman owner mailman" mailman-request: "|/var/lib/mailman/mail/mailman request mailman" mailman-subscribe: "|/var/lib/mailman/mail/mailman subscribe mailman" mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman" Run newaliases afterwards and restart Postfix: /etc/init.d/postfix restart Finally we must enable the Mailman Apache configuration: ln -s /etc/mailman/apache.conf /etc/apache2/conf.d/mailman.conf This defines the alias /cgi-bin/mailman/ for all Apache vhosts, which means you can access the Mailman admin interface for a list at http://<vhost>/cgi-bin/mailman/admin/<listname>, and the web page for users of a mailing list can be found at http://<vhost>/cgi-bin/mailman/listinfo/<listname>. Under http://<vhost>/pipermail you can find the mailing list archives. Restart Apache afterwards: /etc/init.d/apache2 restart Then start the Mailman daemon: /etc/init.d/mailman start Install PureFTPd And Quota PureFTPd and quota can be installed with the following command: apt-get 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 […] Now we configure PureFTPd to allow FTP and TLS sessions. FTP is a very insecure protocol because all passwords and all data are transferred in clear text. By using TLS, the whole communication can be encrypted, thus making FTP much more secure. If you want to allow FTP and TLS sessions, run echo 1 > /etc/pure-ftpd/conf/TLS In order to use TLS, we must create an SSL certificate. I create it in /etc/ssl/private/, therefore I create that directory first: mkdir -p /etc/ssl/private/ Afterwards, we can generate the SSL certificate as follows: openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem Country Name (2 letter code) [AU]: <– Enter your Country Name (e.g., "DE"). State or Province Name (full name) [Some-State]: <– Enter your State or Province Name. Locality Name (eg, city) []: <– Enter your City. Organization Name (eg, company) [Internet Widgits Pty Ltd]: <– Enter your Organization Name (e.g., the name of your company). Organizational Unit Name (eg, section) []: <– Enter your Organizational Unit Name (e.g. "IT Department"). Common Name (eg, YOUR name) []: <– Enter the Fully Qualified Domain Name of the system (e.g. "server1.example.com"). Email Address []: <– Enter your Email Address. Change the permissions of the SSL certificate: chmod 600 /etc/ssl/private/pure-ftpd.pem Then restart PureFTPd: /etc/init.d/pure-ftpd-mysql restart Edit /etc/fstab. Mine looks like this (I added ,usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0 to the partition with the mount point /): vi /etc/fstab # /etc/fstab: static file system information. # # Use 'blkid' 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> /dev/mapper/server1-root / ext4 errors=remount-ro,usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0 0 1 # /boot was on /dev/sda1 during installation UUID=46d1bd79-d761-4b23-80b8-ad20cb18e049 /boot ext2 defaults 0 2 /dev/mapper/server1-swap_1 none swap sw 0 0 /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0 To enable quota, run these commands: mount -o remount / quotacheck -avugm quotaon -avug Install BIND DNS Server BIND can be installed as follows: apt-get install bind9 dnsutils Install Vlogger, Webalizer, And AWstats Vlogger, webalizer, and AWstats can be installed as follows: apt-get install vlogger webalizer awstats geoip-database libclass-dbi-mysql-perl Open /etc/cron.d/awstats afterwards… vi /etc/cron.d/awstats … and comment out everything in that file: #MAILTO=root #*/10 * * * * www-data [ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh # Generate static reports: #10 03 * * * www-data [ -x /usr/share/awstats/tools/buildstatic.sh ] && /usr/share/awstats/tools/buildstatic.sh Install ISPConfig 3 To install ISPConfig 3 from the latest released version, do this: cd /tmp wget http://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz tar xfz ISPConfig-3-stable.tar.gz cd ispconfig3_install/install/ The next step is to run php -q install.php This will start the ISPConfig 3 installer. The installer will configure all services like Postfix, Dovecot, etc. for you. A manual setup as required for ISPConfig 2 (perfect setup guides) is not necessary. root@server1:/tmp/ispconfig3_install/install# php -q install.php PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/ming.ini on line 1 in Unknown on line 0 ——————————————————————————– _____ ___________ _____ __ _ ____ |_ _/ ___| ___ \ / __ \ / _(_) /__ \ | | \ `–.| |_/ / | / \/ ___ _ __ | |_ _ __ _ _/ / | | `–. \ __/ | | / _ \| '_ \| _| |/ _` | |_ | _| |_/\__/ / | | \__/\ (_) | | | | | | | (_| | ___\ \ \___/\____/\_| \____/\___/|_| |_|_| |_|\__, | \____/ __/ | |___/ ——————————————————————————– >> Initial configuration Operating System: Debian or compatible, unknown version. Following will be a few questions for primary configuration so be careful. Default values are in [brackets] and can be accepted with <ENTER>. Tap in "quit" (without the quotes) to stop the installer. Select language (en,de) [en]: <– ENTER Installation mode (standard,expert) [standard]: <– ENTER Full qualified hostname (FQDN) of the server, eg server1.domain.tld [server1.example.com]: <– ENTER MySQL server hostname [localhost]: <– ENTER MySQL root username [root]: <– ENTER MySQL root password []: <– yourrootsqlpassword MySQL database to create [dbispconfig]: <– ENTER MySQL charset [utf8]: <– ENTER Generating a 4096 bit RSA private key …………………………………………………….++ ………………………………………………………………………………………………………….++ writing new private key to 'smtpd.key' —– You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. —– Country Name (2 letter code) [AU]: <– ENTER State or Province Name (full name) [Some-State]: <– ENTER Locality Name (eg, city) []: <– ENTER Organization Name (eg, company) [Internet Widgits Pty Ltd]: <– ENTER Organizational Unit Name (eg, section) []: <– ENTER Common Name (e.g. server FQDN or YOUR name) []: <– ENTER Email Address []: <– ENTER Configuring Jailkit Configuring Dovecot Configuring Spamassassin Configuring Amavisd Configuring Getmail Configuring Pureftpd Configuring BIND Configuring Apache Configuring Vlogger Configuring Apps vhost Configuring Bastille Firewall Configuring Fail2ban Installing ISPConfig ISPConfig Port [8080]: <– ENTER Do you want a secure (SSL) connection to the ISPConfig web interface (y,n) [y]: <– ENTER Generating RSA private key, 4096 bit long modulus …………………………………………………………………………………….++ ……..++ e is 65537 (0x10001) You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. —– Country Name (2 letter code) [AU]: <– ENTER State or Province Name (full name) [Some-State]: <– ENTER Locality Name (eg, city) []: <– ENTER Organization Name (eg, company) [Internet Widgits Pty Ltd]: <– ENTER Organizational Unit Name (eg, section) []: <– ENTER Common Name (e.g. server FQDN or YOUR name) []: <– ENTER Email Address []: <– ENTER Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: <– ENTER An optional company name []: <– ENTER writing RSA key Configuring DBServer Installing ISPConfig crontab no crontab for root no crontab for getmail Restarting services … Stopping MySQL database server: mysqld. Starting MySQL database server: mysqld .. Checking for tables which need an upgrade, are corrupt or were not closed cleanly.. Stopping Postfix Mail Transport Agent: postfix. Starting Postfix Mail Transport Agent: postfix. Stopping amavisd: amavisd-new. Starting amavisd: amavisd-new. Stopping ClamAV daemon: clamd. Starting ClamAV daemon: clamd . Restarting IMAP/POP3 mail server: dovecot. [Tue May 07 02:36:22 2013] [warn] NameVirtualHost *:443 has no VirtualHosts [Tue May 07 02:36:22 2013] [warn] NameVirtualHost *:80 has no VirtualHosts [Tue May 07 02:36:23 2013] [warn] NameVirtualHost *:443 has no VirtualHosts [Tue May 07 02:36:23 2013] [warn] NameVirtualHost *:80 has no VirtualHosts Restarting web server: apache2 … waiting . Restarting ftp server: Running: /usr/sbin/pure-ftpd-mysql-virtualchroot -l mysql:/etc/pure-ftpd/db/mysql.conf -l pam -H -O clf:/var/log/pure-ftpd/transfer.log -Y 1 -D -u 1000 -A -E -b -8 UTF-8 -B Installation completed. root@server1:/tmp/ispconfig3_install/install# The installer automatically configures all underlying services, so no manual configuration is needed. You now also have the possibility to let the installer create an SSL vhost for the ISPConfig control panel, so that ISPConfig can be accessed using https:// instead of http://. To achieve this, just press ENTER when you see this question: Do you want a secure (SSL) connection to the ISPConfig web interface (y,n) [y]:. Afterwards you can access ISPConfig 3 under http(s)://server1.example.com:8080/ or http(s)://192.168.0.100:8080/ ( http or https depends on what you chose during installation). Log in with the username admin and the password admin (you should change the default password after your first login): Continue to Part-2 http://www.howtoforge.com/perfect-server-debian-wheezy-apache2-bind-dovecot-ispconfig-3 Administrations Networking DebianHordeISPConfigWheezy