There is a new version of this tutorial available for Ubuntu 20.04 (Focal Fossa).

The Perfect Server - Ubuntu 14.04 (Apache2, PHP, MySQL, PureFTPD, BIND, Dovecot, ISPConfig 3) - Page 4

12. Install Postfix, Dovecot, MySQL, phpMyAdmin, rkhunter, binutils

For installing postfix we need to stop and remove sendmail 

service sendmail stop; update-rc.d -f sendmail remove

Now 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:

New password for the MySQL "root" user: <-- yourrootsqlpassword
Repeat password for the MySQL "root" user: <-- yourrootsqlpassword
General type of mail configuration: <-- Internet Site
System mail name: <-- server1.example.com

Next open the TLS/SSL and submission ports in Postfix:

vi /etc/postfix/master.cf

Uncomment the submission and smtps sections as follows - add the line -o smtpd_client_restrictions=permit_sasl_authenticated,reject to both sections and leave everything thereafter commented:

[...]
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 smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_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 smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
[...]

Restart Postfix afterwards:

service 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:

service mysql restart

Now check that networking is enabled. Run

netstat -tap | grep mysql

The output should look like this:

[email protected]:~# netstat -tap | grep mysql 
tcp        0      0 *:mysql                 *:*                     LISTEN      21298/mysqld
[email protected]:~#

13. 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:

service spamassassin stop
update-rc.d -f spamassassin remove

 

14. 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-doc apache2-utils 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-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 snmp

The PHP5 mcrypt module has to be enabled manually:

php5enmod mcrypt

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 cgi
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>
        suPHP_AddHandler application/x-httpd-suphp
AddType application/x-httpd-suphp .php .php3 .php4 .php5 .phtml <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:

service 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:

service apache2 restart

 

14.1 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:

service apache2 restart

 

14.2 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 
service apache2 restart

 

14.2 Additional PHP Versions

Starting with ISPConfig 3.0.5, it is possible to have multiple PHP versions on one server (selectable through ISPConfig) which can be run through FastCGI and PHP-FPM. To learn how to build additional PHP versions (PHP-FPM and FastCGI) and how to configure ISPConfig, please check this tutorial: How To Use Multiple PHP Versions (PHP-FPM & FastCGI) With ISPConfig 3 (Ubuntu 12.10) (works for Ubuntu 14.04 as well).

15. 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

[email protected]:~# newlist mailman
Enter the email of the person running the list:
 <-- admin email address, e.g. [email protected]
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

[email protected]:~#

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:

service postfix restart

Finally we must enable the Mailman Apache configuration:

ln -s /etc/mailman/apache.conf /etc/apache2/conf-available/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:

service apache2 restart

Then start the Mailman daemon:

service mailman start

 

Share this page:

Suggested articles

22 Comment(s)

Add comment

Comments

By:

When restarting postfix I get a lot of errors:

[email protected]:/home/admin# /etc/init.d/postfix restart

* Stopping Postfix Mail Transport Agent postfix /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions [ OK ] * Starting Postfix Mail Transport Agent postfix postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_client_restr ictions postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_client_restr ictions postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_client_restr ictions postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_client_restr ictions postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_client_restr ictions postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_client_restr ictions postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_client_restr ictions postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_client_restr ictions postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_client_restr ictions postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_client_restr ictions postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_client_restr ictions postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_client_restr ictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions /usr/sbin/postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_cl ient_restrictions [ OK ]

[email protected]:/home/admin#

By: admin

Please check your master.cf file again and compare it with the Version from the tutorial. You must have removed # in front of too many lines in the smtps and Submission sections when you get that error. remove the # just in front of the lines as shown in the tutorial.

By: Skrydal

Hi, I would like to say thank you for that tutorial. I have the same problem when I try to restart "service postfix restart"

[..]

(98)address already in use make_sock nginx

 [...]

I checked the  /etc/postfix/master.cf, and is exacly like you are showing in that tutorial.

Thanks For Help

Maciek

 

 

By: Zuyan Chang

In step 12 have Dovecot SSL setting ..
SSL option & hostname Setting .
But in Document miss it.

 

 

By:

I am facing that too and confused what will be inputs ? localhost ? and mail ? localhost.domain.com or server1.domain.com ???

By: yashx1

While installing mod_fastcgi i receive this error:-

/home/ubuntu# apt-get install libapache2-mod-fastcgi php5-fpm
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libapache2-mod-fastcgi is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libapache2-mod-fastcgi' has no installation candidate

By:

Please check your /etc/apt/sources.list if the multiverse repository is enabled.

By: Anonymous

Whenever I use the 'service' command, it says.....  

'service unrecognized'

Just wondering why ?

And why cant we still use /etc/init.d etc etc ?

 

By: admin

The classic init System with scripts in /etc/init.d/ has been replaced in Ubuntu 14.04 with upstart. So the few scripts that still exist in /etc/init.d/ are just wrapper for the upstart service .. commands and not all services have wrapper scripts in /etc/init.d/ anymore and some others are faulty. If the command "service" is not known on your server, then you are either not logged in as root user or you do not use Ubuntu 14.04.

I installed a Server xesterday with this guide, all commands worked out of the box, I could do a simple copy&paste from the guide to my ssh terminal for all commands.

By: Anonymous

Thanks for your reply but I have solved it now .....

For 'Service restart'

 it needs to be....

'Service full-restart'

Now I dont get any problems.

Many thanks.

By: Anonymous

If you are running PHP on cli you may get errors like:

Cannot adopt OID in NET-SNMP-AGENT-MIB: netSnmpAgentMIB ::= { netSnmpModuleIDs 2 }
Cannot adopt OID in LM-SENSORS-MIB: lmFanSensorsValue ::= { lmFanSensorsEntry 3 }
Cannot adopt OID in LM-SENSORS-MIB: lmFanSensorsDevice ::= { lmFanSensorsEntry 2 }
Cannot adopt OID in LM-SENSORS-MIB: lmFanSensorsIndex ::= { lmFanSensorsEntry 1 }
Cannot adopt OID in LM-SENSORS-MIB: lmTempSensorsValue ::= { lmTempSensorsEntry 3 }
Cannot adopt OID in LM-SENSORS-MIB: lmTempSensorsDevice ::= { lmTempSensorsEntry 2}

You need to install "snmp-mibs-downloader".

By: Anonymous

Thank you for this answer it worked great.

No more errors in the cron log & PHP CLI working 100%

 

Many thanks.

By:


Let me say, fandabadozy instructions. Although I am having a little difficulty getting ISPConfig and Apache to run. So I started again. I got as far as step 11 this time, and ran into an issue that none of the packages could be found when starting step 12.

My situation is a little different... dare a say "gasp" using a Mac and VirtualBox by Solaris to run this tutorial... got it up to and including squirrel mail with no issues even got an email from mailman last night. Issue I had with Apache not starting was something to do with Suexecispconfig in the default.conf file for apache... didn't seem to recognize the user ispconfig. I am guessing I missed something.

Starting from scratch...  

 

 

By: admin

Please check your /etc/apt/sources.list. Seems as if you did not enable all repositories (universe + multiverse).

By: Alan

Great tutorial.  however, I updated the sources list and ran apt-get update multiple times but it consistently can't find getmail4.  Am I the only one still running into this problem?

By:

I'm going to press on without it... not sure how important getmail4 is, but it isn't found with apt-get install

 apt-get install getmail4

Reading package lists... Done

Building dependency tree       

Reading state information... Done

E: Unable to locate package getmail4

By:

I had to reconfigure the update process, by ensuring that I had latest updates using apt-get update, which I did prior per the tutorial but seems some stuff was skipped. Now it seems to be installing these apps as intended. Doing them one at a time to isolate any issues.

 Pain, but necessary.

By: Nico

Installing xcache (14.1) on ubuntu 14.04 digital ocean you might have an issue migrating a drupal site.  I had a plain site that worked migrating site with views cck and others would get the wsod after several hours disabling views along with search_api_views and views_ui it would show but not entire site, after much digging.. uninstall php5-xcache fixed it and enabled them models again.

 i did the,

"sudo apt-get remove --auto-remove php5-xcache" with a "sudo apt-get purge --auto-remove php5-xcache"

 not sure how big of a hit I will get for xcache being removed but it works and I am happy, just migrated from centos 5.x to ubuntu 14.04 because some email issues and i now have email/smtp and everything working, also migrated from webuzo to ispconfig3

 

By:

after upgrade from 10.04 to 14.04 and i get error in Apache line

AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/ports.conf:8
 

By: Anonymous




I had and issue that when going to the mailman admin pages, all of the linked images were missing.

 I had to:

 


ln -s /etc/mailman/apache.conf ../conf-enabled/mailman.conf

 service apache2 restart 


 

By: Bevan

Hello,

I have got right to the end of this tutorial, and it's pretty darn good. There's a single issue for me: phpmyadmin won't work.

I'm on an AWS EC2 VM running Ubuntu14.04 so I started at step 4, root access.

Now, it always falls over when I click the phpmyadmin link - and gives me a 404 error: requested url not found

Feeling a bit lost and stuck here :)

By: PowhatanDave

Followed this tutorial and Dovecot Sieve filters are not working.  I put a "discard;" in for a user's mailbox, and the mail was still delivered.  That one line should drop all incoming mail from that user.  dovecot-sieve is installed as per your instructions above.  However, if I put an unrecognized command in the Custom Rules tab, the .sieve.log in the user's mailbox does show an error.  So it is being run but it's like it's not applying the rules.