www.pokeroconnor.com

Quick Guide to New WordPress Install

June6
  1. http://codex.wordpress.org/Installing_WordPress
  2. Logon to your server, and cd document_root_name
  3. wget http://wordpress.org/latest.tar.gz
  4. tar -xzvf latest.tar.gz
  5. cd wordpress
  6. cp -r * ../
  7. cd ..
  8. rm -r wordpress
  9. rm latest.tar.gz
  10. http://codex.wordpress.org/Installing_WordPress#Using_phpMyAdmin
  11. sudo chown www-data document_root_name/
  12. http://example.com/wp-admin/install.php
  13. http://codex.wordpress.org/Changing_The_Site_URL. This is followed if you want to change the WordPress site name from example.com to www.example.com. You may need to add update_option(‘siteurl’,'http://example.com/blog’); and update_option(‘home’,'http://example.com/blog’); to the theme functions.php file. Then reload site, then DELETE these two lines from theme functions.php file.
  14. Change default theme to custom theme, so future updates don’t wipe your changes: cp -r twentyten/ customtheme
  15. Run script as defined on http://www.pokeroconnor.com/recursive-sed-script/ to change all previous theme name mentions

 

//

mysql cannot login with root user

November1

If you ever come across the issue where your ‘root’ user cannot login to mysql on debian, here’s a neat solution that will save you having to re-install mysql.

mysql -u root

ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: NO)

Then you try:

mysql -u root -pxxxxx

ERROR 1045 (28000): Access denied for user ‘root’@'localhost’ (using password: YES)

I don’t know how this happened, but on Debian what you can do is:

Go to your /etc/mysql/debian.cnf file, and copy the password for the debian-sys-maint mysql user.

Typically will look like:

host     = localhost
user     = debian-sys-maint
password = 123456789

Login to mysql as debian-sys-maint:

mysql -u debian-sys-maint -p123456789

Then, switch to mysql database,

use mysql;

Now check your root user is still there, on localhost. If so, just set a new password, i.e.

SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(‘password-value’);

Note, it will not work if you just do

SET PASSWORD FOR ‘root’ = PASSWORD(‘password-value’);

That’s it, exit, restart mysql and you should be able to log with root again!

Of course if root user doesn’t exist anymore in the user table on mysql, just recreate and ensure you grant all privileges.

One final thing – if you use phpmyadmin, you will need to change the password for root in /etc/phpmyadmin/config.inc.php to match your new one.

//
posted under hosting, MySQL | No Comments »

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″

//

Installing BIND Server

October21

The following are the best resources I could find on installing a BIND (9) server. I installed on Debian Lenny, but the principles of zone files etc are universal. I’ll also detail (somewhat) the steps to installing a BIND DNS server, and some of the common and annoying issues you may come across – damn you AppArmor!!!

For starters, here’s Zone files info. Zones and zone files is probably the most fundamental concept you need to understand when starting BIND/DNS use. Very basically, a zone in DNS terms is what you might in other conversations call a domain, sub-domain or url –  e.g. pokeroconnor.com is a zone, sub.pokeroconnor.com is a zone, poker is a zone etc. Each zone requires “definition” if you will, in named.conf, and forward and reverse zone files. A forward zone file for pokeroconnor.com defines forward name resolution, e.g. pokeroconnor.com to octal IP addresses (123.20.33.122). Reverse zone files then do the opposite (basically), providing octal -> name resolution.

In zone files you need to be aware of the following notation:

  • SOA – start of authority
  • IN – internet record
  • MX – mail record
  • NS – name server
  • A – A class address (in octal) e.g. 111.2.3.44
  • CNAME – really an alias for another zone e.g. if poker.me.com is a CNAME record for me.com, requests for poker.me.com resolve to me.com.

This is vital – every time you edit a zone file, you must increment (or change) the serial value. Otherwise your changes won’t get detected by BIND, and apparently its a very common source of errors. The common format of serial is e.g. 2009092201 – yes its the date, in year, month, day followed by the increment on that date, in this case 01. Of course you can have what you want here, just be sure to change it every time the file changes. More info here, and the definite work on BIND.

Then, to actually install Bind and setup your own nameservers, best links I could find are this and this basic one. Also install the dnsutils package. Important things to note are that it is a VERY good idea to setup bind/named to run in  a chroot ‘jail’. This is so that if someone hacks your bind install, they only have access to that particular app. Once you’ve followed these steps, e.g. install bind, setup chroot user, create zone files and configure named.conf etc, you can then cross your fingers and restart bind. Best place to check for errors of course is in your /var/log/syslog, so check it. I had a particularly annoying and extremely frustrating problem…I had everything installed and chrooted, zone files created, everything in its proper place, but bind would not start. I could stop it, but not start it. When I checked syslog, I saw errors similar to this:

named[22070]: zone 100.11.45.in-addr.arpa/IN: loading from master file 100.11.45.in-addr.arpa failed: file not found

Basically saying that the reverse zone files were not found…but they were there!! They were in the /var/lib/named/etc/bind directory as they should be, so how can the system be reporting them as not found??? It didn’t make ANY sense. Until that is, I eventually found this. If you run debian, I strongly suggest you check out that link. There is a package called AppArmor, which does what a chroot jail does. In other words, it restricts the access and rights of certain apps, and of course named is one of those apps it restricts!! The system couldn’t find the files that were there, because the named user was only allowed access to certain directories specified by AppArmor, and /var/lib/named/etc/bind was not one of them. So, simply doing apt-get –purge apparmor and restarting bind solved the problem. That was the hardest to solve error – I would recommend checking whether you have apparmor installed on your box, and if you do, and you don’t knowingly use it, then remove it!

//

Locate: command not found error

September23

I just recently did a fresh install of Debian Lenny, but when I tried to locate something, I got the following error:

-bash: locate: command not found

This is because you need to separately install locate, or even better, mlocate which is much faster apparently.

Doing this is simple, you just need to do 2 things…

Firstly, apt-get install mlocate to grab and install the mlocate stuff. Finally, you must run the updatedb command.

Viola, that’s it, short and sweet, now you can locate away!

Also worth mentioning is the purge option with apt-get, e.g. apt-get remove app_name –purge, which completely removes an application and all its configuration files. Or if you want to cleanup after removing an application, run apt-get clean.


//

a2 hosting guide

February15

A2 Hosting are by far the best web hosts I’ve come across, in terms of value for money, quality, reliability and customer support. So I’ll be adding some reference material here as I have time, more or less for my own benefit too.

Will be adding more here but for now here is the guide to installing TRAC.

SMTP and IMAP details for google apps mail. Vid tutorial of the same.

//
posted under hosting | No Comments »