www.pokeroconnor.com

WordPress site redirect

February13

I had the following problem lately: I added the typical rules to htaccess to redirect example.com/anything to www.example.com/anything, e.g.

RewriteEngine On

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule (.*)$ http://www.example.com/$1 [L,NC,R=301]

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

But when I went to example.com I got infinite redirects…reason being I had the siteurl field in the wp_options table of the database set to http://example.com.

So, you need to change that to http://www.example.com, and also edit wp-config.php as follows:

define('WP_HOME','http://www.example.com');
define('WP_SITEURL','http://www.example.com');

That should be it - see here if not.

//

Installing IMAP SMTP Postfix Debian

February6

I run Debian Lenny, and have my bind server setup with mail.yourdomain.com. That’s my starting point, and the following is how to install and configure SMTP and IMAP, using Postfix and SASL.

On debian you need the courier-imap package, and note it runs on port 143.

apt-get install courier-imap

This is a good guide to IMAP side of things.

VIP: Support for maildir-style mailboxes needs to be added, so edit /etc/postfix/main.cf to add the following:

home_mailbox = Maildir/

SMTP

This guide rules as a starter for SMTP.

Run apt-get install postfix-tls sasl2-bin libsasl2 libsasl2-modules, and maybe apt-get install libsasl2-2 but MAKE SURE you change /etc/default/saslauthd to have the following:

START=yes
MECHANISMS=”pam”

Next file to edit is /etc/postfix/sasl/smtpd.conf (you have to create it):
pwcheck_method: saslauthd

VI: /etc/postfix/main.cf

smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes

smtpd_recipient_restrictions =
permit_sasl_authenticated,
permit_mynetworks,
reject_unauth_destination

NB, back in terminal do this:

rm -r /var/run/saslauthd/
mkdir -p /var/spool/postfix/var/run/saslauthd
ln -s /var/spool/postfix/var/run/saslauthd /var/run
chgrp sasl /var/spool/postfix/var/run/saslauthd
adduser postfix sasl

Also, copy other pam group to smtp:


cd /etc/pam.d
cp other smtp

Restart and go:

/etc/init.d/postfix restart
/etc/init.d/saslauthd start

Test your config by telnet-ing in:
telnet localhost smtp
Trying 80.237.145.96…
Connected to jimmy.co.at.
Escape character is ‘^]’.
220 kitana.jimmy.co.at ESMTP Mailserver
ehlo reptile.g-tec.co.at
250-kitana.jimmy.co.at
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH NTLM LOGIN PLAIN DIGEST-MD5 CRAM-MD5
250-AUTH=NTLM LOGIN PLAIN DIGEST-MD5 CRAM-MD5
250 8BITMIME
AUTH PLAIN amltbXkAamltbXkAcmVhbC1zZWNyZXQ=
235 Authentication successful

Or maybe not successful!!!!
VIP!!!!!!!!!!! May get an error in /var/log/mail.log with “warning: SASL authentication failure: no secret in database“.

In this case you need to set up a user and pass for SASL as follows:
saslpasswd2 -f /etc/sasldb2 -u yourdomain.com paul

Another error is “warning: SASL authentication problem: unable to open Berkeley db /etc/sasldb2: No such file or directory“.

This is solved here, READ IT!

In /etc/init.d/postfix,  around line 43 there is a list of files that are copied from their real directories into the chroot. Change the line so it looks like:
FILES=”etc/localtime etc/services etc/resolv.conf etc/hosts etc/nsswitch.conf etc/sasldb2″

//