Exchange mailstore full

Why does every Exchange admin have to find out the hard way that there is a limit to the database size (16GB for 2000, 75GB for 2003 I think).

The chances are that it isn’t actually full of data, just very very fragmented.  I’ve reduced a 75GB file to around 20GB.  To defrag it:

  • Dismount the exchange store using exchange system manager
  • If your low on disk space, connect a USB hard disk or similar, the defrag will need as much space as it already uses free.
  • cd progra~1\exchsrvr\bin
  • eseutil /d c:\Exchsrvr\mdbdata\priv1.edb /tf:\Tempdfrg.edb
    /ff:\Tempdfrg.stm /bf:\origmbox

    (help:
    /d         – <database name>
    /t<db>     – set temp. database name (default: TEMPDFRG*.EDB)
    /f<file>   – set temp. streaming file name
    /b<db>     – make backup copy under the specified name)

  • Once finished check mdbdata dir for new priv1.edb and
    priv1.stm – they should be significantly smaller
  • Mount the exchange store

Also see: http://support.microsoft.com/kb/192185

Qmail: forward emails to a PHP script

In qmail, first add the domain alias.

For myscript@servername make /var/qmail/alias/.qmail-myscript

If its for myscript@mydomain.com /var/qmail/mailnames/mydomain.com/.qmail-myscript should do it.

Contents need to be along the lines of:

|/var/www/vhosts/mydomain.com/httpdocs/script.php

references:

http://www.devarticles.com/c/a/PHP/Incoming-Mail-and-PHP/1/

http://forum.swsoft.com/showthread.php?t=40510&highlight=qmail+alias

Curl Error: openssl missing CA

This seems to happen with different versions on libcurl on el4. Just make sure that there is a ca-bundle in the right place:

mkdir -p /etc/pki/tls/certs && ln -s /usr/share/ssl/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt

You can find where its looking for the bundle using curl -v :

curl -v https://www.google.co.uk
* About to connect() to www.google.co.uk port 443 (#0)
* Trying 209.85.229.104… connected
* Connected to www.google.co.uk (209.85.229.104) port 443 (#0)
* error setting certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none

Convert SSL from pfx to pem

Convert an SSL certificate from IIS pfx to Apache pem format:

# Export the private key file from the pfx file
openssl pkcs12 -in filename.pfx -nocerts -out key.pem
# Export the certificate file from the pfx file
openssl pkcs12 -in filename.pfx -clcerts -nokeys -out cert.pem
# This removes the passphrase from the private key so Apache won’t
# prompt you for your passphase when it starts
openssl rsa -in key.pem -out server.key

Compare RPM’s on two servers

Useful if your migrating from an old server to a new one and want to check everything needed is installed.

First, pull a list of RPM package by name only:

rpm -qa –queryformat=’%{NAME}\n’ | sort > server.txt

Once you’ve done that on both servers, just use diff to compare the two files:

diff serverold.txt servernew.txt
or
diff serverold.txt servernew.txt > diff.txt
cat diff.txt | grep “>”

Recursively change file permissions

If you chmod -R it will recursively chmod everything whether it be a file or directory. A more sensible way is:

# Change directories
find . -type d -exec chmod 755 {} \;

# Change files
find . -type f -exec chmod 644 {} \;

Obviously chowning is similar:
find . -type f -exec chown user:group {} \;

Find is also useful in directories with a very large number of files, where a standard chmod/chown may time out.

find . -name “*.gif” -exec chown apache:apache ‘{}’ \;

Run CGI scripts in httpdocs

Plesk only allows .cgi files to be executed from cgi-bin but allows .pl files to be executed from anywhere. To allow .cgi to be executed from httpdocs add line to .htaccess:

AddHandler cgi-script .cgi

Apache case insensitive URL’s

If your moving a site from a Windows host to Linux and all of the cases are messed up (Yes Windows is case-insensitive ), you could try to substitute through all the code to make sure the links are the correct case. If your lucky though, enable mod_speling and this should work:

# Add the following line to a .htaccess file
CheckSpelling On

Linux at command

A useful utility for scheduling one-off tasks.

atq = view scheduled jobs

at -c 7 = show command to be run in job number 7

atrm 7 = delete job number 7

at -m 08:50 2009-10-15 < updatejob = schedule a job to run the contents of updatejob or type: at -m 08:50 2009-10-15 then the command on the next line, i.e: yum clean all && yum -y update && shutdown -r now then ctrl-D to submit the job

Apache MySQL Authentication

mod_auth_mysql will need to be loaded.

in vhost.conf add:


AuthType Basic
AuthName “Auth required”
AuthMySQLHost localhost
AuthMySQLUser auth_user
AuthMySQLPassword mypassword
AuthMySQLDB mysqlauth
AuthMysqlUserTable clients
AuthMySQLNameField username
AuthMySQLPasswordField passwd
AuthMySQLPwEncryption none
AuthMySQLEnable on
require valid-user

Then in MySQL:

create database mysqlauth;

use mysqlauth;

CREATE TABLE `clients` ( `username` varchar(25) NOT NULL default ”, `passwd` varchar(25) NOT NULL default ”, `groups` varchar(25) NOT NULL default ”, PRIMARY KEY (`username`), KEY `groups` (`groups`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `clients` VALUES (‘bob’, ‘testpass12′, ‘testgroup’);

grant all on mysqlauth.* to auth_user@localhost identified by ‘mypassword';
flush privileges;