CentOS Virtual Hosting Tutorial

Please take a look at the CentOS Virtual Hosting tutorial on the wiki: http://www.linode.com/wiki/index.php/CentOS

The tutorial covers the setup of a Linode for hosting multiple domains and email. The following software is installed and configured in the tutorial.

  • Lighttpd

  • ClamAV

  • Dovecot

  • Dovecot Sieve Plugin

  • MailScanner

  • MySQL

  • PHP

  • Postfix

  • Postfix Admin

  • SquirrelMail

  • SpamAssassin

I wrote this tutorial as I went through the process of setting up my own Linode. My hope is that it will save someone from the frustration that comes with learning how to be an admin.

Please feel free to make changes and/or suggestions. I put the tutorial on the wiki so I wouldn't have to maintain it. :D

21 Replies

Uptime

I have been testing the setup with my own domain for roughly three weeks now. Everything seems to be running smoothly, I haven't had to reboot it yet.

Spam Scanning

Four days ago I added a second domain which increased the amount of messages coming in to ~1000 per day. CPU usage remains around 3% to 5% and disk I/O averages 50.

Memory

free -m
             total       used       free     shared    buffers     cached
Mem:           360        263         97          0          3         76
-/+ buffers/cache:        183        177
Swap:          255         54        201

your tutorial is really good but

I prefer to use YUM when it's possible, and now it should be possible…

I'm doing something wrong?

I've followed the wiki how to (http://www.linode.com/wiki/index.php/CentOS) - selecting the Apache option.

When I do http://[Linode MyIP]/ I get:

Connection Failure

The requested URL could not be retrieved

Would it help if I post my config files?

Ok, fixed that error, now php. I've set up php in httpd.conf as follow:

LoadModule php5_module modules/libphp5.so
AddHandler php5-script php
DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl
#AddType application/x-httpd-php .php .php4 .php3
AddType text/html       php
AddType application/x-httpd-php-source phps

The removal of AddType application/x-httpd-php is recommended by http://dan.drydog.com/apache2php.html

I've tried it with or without the x-httpd-php. I've restarted apache with each change to httpd.conf.

When I surf to http://blahblah/setup.php it wants to download the file saying it is a PHP file (is this a case issue?)

if I surf to http://blahblah/ it wants to download the page because it is an application/x-httpd-php.

What am I missing here?

What does the following command show on your Linode?

yum list installed '*php*'

yum list installed '*php*' Loaded plugins: fastestmirror, priorities Installed Packages php.i386 5.1.6-23.2.el5_3 installed php-cli.i386 5.1.6-23.2.el5_3 installed php-common.i386 5.1.6-23.2.el5_3 installed php-devel.i386 5.1.6-23.2.el5_3 installed php-gd.i386 5.1.6-23.2.el5_3 installed php-imap.i386 5.1.6-23.2.el5_3 installed php-ldap.i386 5.1.6-23.2.el5_3 installed php-mbstring.i386 5.1.6-23.2.el5_3 installed php-mcrypt.i386 5.1.6-15.el5.centos.1 installed php-mysql.i386 5.1.6-23.2.el5_3 installed php-odbc.i386 5.1.6-23.2.el5_3 installed php-pdo.i386 5.1.6-23.2.el5_3 installed php-pear.noarch 1:1.4.9-4.el5.1 installed php-pear-Auth-SASL.noarch 1.0.2-4.el5.centos installed php-pear-DB.noarch 1.7.13-1.el5.centos installed php-pear-Date.noarch 1.4.7-2.el5.centos installed php-pear-File.noarch 1.2.2-1.el5.centos installed php-pear-HTTP-Request.noarch 1.4.2-1.el5.centos installed php-pear-Log.noarch 1.9.13-1.el5.centos installed php-pear-MDB2.noarch 2.4.1-2.el5.centos installed php-pear-Mail.noarch 1.1.14-1.el5.centos installed php-pear-Mail-Mime.noarch 1.4.0-1.el5.centos installed php-pear-Net-SMTP.noarch 1.2.10-1.el5.centos installed php-pear-Net-Sieve.noarch 1.1.5-2.el5.centos installed php-pear-Net-Socket.noarch 1.0.8-1.el5.centos installed php-pear-Net-URL.noarch 1.0.15-1.el5.centos installed php-pecl-Fileinfo.i386 1.0.4-3.el5.centos installed php-pecl-memcache.i386 2.2.3-1.el5_2 installed php-sqlite2.i386 5.1.6-200705230938 installed php-xml.i386 5.1.6-23.2.el5_3 installed php-xmlrpc.i386 5.1.6-23.2.el5_3 installed php5-ioncube-loader.i386 3.1-07051711 installed phpmyadmin.noarch 2.11.9.3-1.fc7.rf installed psa-php5-configurator.noarch 1.5.1-cos5.build92090422.13 installed

Well, you certainly don't seem to be missing the PHP package. Maybe the module isn't being loaded for some reason? Does php5_module show up when you run the following?

/usr/sbin/httpd -M

This is what I get:

# /usr/sbin/httpd -M
[Fri Jun 26 08:26:38 2009] [warn] module php5_module is already loaded, skipping
...
php5_module (shared)

Hmm, afraid I can't offer much help then. When I installed Apache and PHP on CentOS, it "just worked." If you don't mind abandoning your current configuration, maybe try deleting it, removing the httpd and php* packages, and re-installing them?

I've uploaded it to my other server:

http://www.paranoidandroid.co.za/files/httpd.conf

http://www.paranoidandroid.co.za/files/ … hosts.conf">http://www.paranoidandroid.co.za/files/httpd_vhosts.conf

Most of my changes are marked with [ALE MOD]

I checked your httpd.conf after sent you a pm.

I think there is a mime type problem.

But your httpd.conf is seems ok.

LoadModule php5_module modules/libphp5.so

AddHandler php5-script php

AddType text/html php

Php module is loaded too.

:?

Ok, just to update all and to ask a new question(s):

I've re-installed Centos (twice now, last time following the wiki article to the letter)

Now the first question:

I get the following in mailllog file

Jul 17 16:59:15 li73-31 postfix/postfix-script[27010]: warning: not owned by root: /etc/postfix/sql
Jul 17 16:59:15 li73-31 postfix/postfix-script[27011]: warning: not owned by root: /etc/postfix/sql/mysql_virtual_domains_maps.cf
Jul 17 16:59:15 li73-31 postfix/postfix-script[27012]: warning: not owned by root: /etc/postfix/sql/mysql_virtual_alias_maps.cf
Jul 17 16:59:15 li73-31 postfix/postfix-script[27013]: warning: not owned by root: /etc/postfix/sql/mysql_virtual_mailbox_maps.cf
Jul 17 16:59:15 li73-31 postfix/postfix-script[27027]: starting the Postfix mail system
Jul 17 16:59:15 li73-31 postfix/master[27028]: daemon started -- version 2.6.2, configuration /etc/postfix

Do I need to worry about it?

If so what should I do to fix it?

Thank you :)

[Fixed] Also…

Postfix is having problems…

Jul 17 20:06:39 li73-31 postfix/smtpd[16986]: fatal: open database /etc/aliases.db: No such file or directory

And I don't have newaliases on my installation (I've un-installed sendmail as per the wiki.) What I can figure out is that newaliases is part of sendmail.

Should I re-install sendmail? [Yes]

Will it break my current postfix setup? [Doesn't seem to break postfix]

Newaliases is part of Postfix's Sendmail compatibility interface. If you had both installed simultaneously, I can see how that might cause Postfix's versions of newaliases / sendmail / mailq to not be present. You almost certainly want them, as other applications tend to rely on their presence.

You might want to first try running system-switch-mail (if not present, just do yum install system-switch-mail) to choose Postfix as your system's MTA. That might be enough to get all the pieces in place. Otherwise, I'd suggest removing both Sendmail and Postfix and then re-installing Postfix only, followed by system-switch-mail.

Hi

Thank you for the response.

It seems to be working if I have sendmail installed but not running.

Hi All

I'm posting here because I use this setup. I'm having trouble setting up the mail.

My mail seems to be eaten up…

In the maillog file I get:

Aug  7 09:49:18 li73-31 postfix/smtpd[9962]: connect from ey-out-2122.google.com[74.125.78.26]      
Aug  7 09:49:18 li73-31 postfix/smtpd[9962]: B9E752727A: client=ey-out-2122.google.com[74.125.78.26]
Aug  7 09:49:18 li73-31 postfix/cleanup[9968]: B9E752727A: hold: header Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.26])??by mail.paranoidandroid.co.za (Postfix) with ESMT
P id B9E752727A??for <andre@paranoidandroid.co.za>; Fri,  7 Aug 2009 09: from ey-out-2122.google.com
[74.125.78.26]; from= <tungsten15@gmail.com>to= <andre@paranoidandroid.co.za>proto=ESMTP helo= <ey-ou t-2122.google.com="">Aug  7 09:49:18 li73-31 postfix/cleanup[9968]: B9E752727A: message-id=<4A7BDC6B.5080403@googlemail.c
om>                                                                                                 
Aug  7 09:49:23 li73-31 MailScanner[9833]: New Batch: Scanning 1 messages, 2821 bytes               
Aug  7 09:49:23 li73-31 MailScanner[9833]: Virus and Content Scanning: Starting                     
Aug  7 09:49:23 li73-31 MailScanner[9833]: Requeue: B9E752727A.A4428 to 65A0F27283                  
Aug  7 09:49:23 li73-31 MailScanner[9833]: Uninfected: Delivered 1 messages                         
Aug  7 09:49:23 li73-31 postfix/qmgr[7425]: 65A0F27283: from=<tungsten15@gmail.com>, size=2115, nrcp
t=1 (queue active)                                                                                  
Aug  7 09:49:23 li73-31 postfix/error[9972]: 65A0F27283: to=<andre@paranoidandroid.co.za>, relay=non
e, delay=4.9, delays=4.8/0/0/0.05, dsn=4.3.0, status=deferred (mail transport unavailable)          
Aug  7 09:49:23 li73-31 MailScanner[9833]: Deleted 1 messages from processing-database</andre@paranoidandroid.co.za></tungsten15@gmail.com></ey-ou></andre@paranoidandroid.co.za></tungsten15@gmail.com></andre@paranoidandroid.co.za>

And also:

Aug  7 09:56:20 li73-31 postfix/error[9998]: 37FE62727E: to=<andre@paranoidandroid.co.za>, relay=non
e, delay=940, delays=940/0.03/0/0.01, dsn=4.3.0, status=deferred (mail transport unavailable) 

Aug  7 09:56:20 li73-31 postfix/qmgr[7425]: warning: connect to transport private/dovecot: No such file or directory</andre@paranoidandroid.co.za> 

I guess the MailScanner doesn't copy the email to where it should be, just delete it…?

Your mail is in the postfix local delivery queue. postfix is reporting an error:````
Aug 7 09:49:23 li73-31 postfix/error[9972]: 65A0F27283: to=andre@paranoidandroid.co.za, relay=none, delay=4.9, delays=4.8/0/0/0.05, dsn=4.3.0, status=deferred (mail transport unavailable)

because the specified local delivery transport is unavailable:

Aug 7 09:56:20 li73-31 postfix/qmgr[7425]: warning: connect to transport private/dovecot: No such file or directory
````

Thank you for the response.

The week was long and I'm a bit slow.

Is private/dovecot a directory or the bin file? I've created a directory in /var/spool/postfix/private/dovecot (just after I posted the previous post). Now I get a Connection refused error

Did you install Dovecot yet?

Yes this is my setting:

# 1.2.1: /usr/etc/dovecot.conf
# OS: Linux 2.6.18.8-x86_64-linode1 x86_64 CentOS release 5.3 (Final)
protocols: imap imaps pop3 pop3s
ssl_cert_file: /etc/pki/paranoidandroidCA/server.crt
ssl_key_file: /etc/pki/paranoidandroidCA/server.key
login_dir: /usr/var/run/dovecot/login
login_executable(default): /usr/libexec/dovecot/imap-login
login_executable(imap): /usr/libexec/dovecot/imap-login
login_executable(pop3): /usr/libexec/dovecot/pop3-login
mail_executable(default): /usr/libexec/dovecot/imap
mail_executable(imap): /usr/libexec/dovecot/imap
mail_executable(pop3): /usr/libexec/dovecot/pop3
mail_plugin_dir(default): /usr/lib/dovecot/imap
mail_plugin_dir(imap): /usr/lib/dovecot/imap
mail_plugin_dir(pop3): /usr/lib/dovecot/pop3
auth default:
  mechanisms: plain login cram-md5 ntlm
  passdb:
    driver: sql
    args: /etc/dovecot/dovecot_sql_passdb.conf
  userdb:
    driver: sql
    args: /etc/dovecot/dovecot_sql_userdb.conf
  socket:
    type: listen
    client:
      path: /var/spool/postfix/private/auth
      mode: 432
      user: postfix
      group: postfix
    master:
      path: /usr/var/run/dovecot/auth-master
      mode: 384
      user: vmail

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct