Monthly Archives: September 2011

wordpress permalink

I finally got around to configuring Permalinks in WordPress! Some of you might laugh but based on my server configuration I had to do a little bit of research, configuring Permalinks in WordPress on a Parallels Plesk system requires a few minor modifications to the vhost which is hosting the WordPress Blog.

1) The first step is to check the directory of your vhost, you want to check for the .htaccess file:

ls -la /var/www/vhosts/<vhost-name>/conf

2) In my case the .htaccess file was not there, so I had to create it

touch /var/www/vhosts/<vhost-name>/conf/.htaccess

3) Make sure you change permissions on the file

chown root:apache /var/www/vhosts/<vhost-name>/conf/.htaccess

4) Edit the file accordingly, add the lines WordPress tells you to under “Settings –> Permalink.”

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

5) Now you need to reconfigure the individual vhost

/usr/local/psa/admin/sbin/websrvmng –reconfigure-vhost –vhost-name=<vhost-name>

Or the new way Parallels Plesk requires you to do it (the above one works but you receive and warning: WARNING: You are using obsolete option, use corresponding option of httpdmng). See this post by Bryan White

 /usr/local/psa/admin/bin/httpdmng –reconfigure-domain skrakes.com

6) Test your WordPress Blog, the Permalink should now be working!

rsync script using ssh

This is my quick and dirty How To rsync script using SSH!

I have created the below script which will use rsync to backup a single local directory to a single directory on a remote server. If you have not used rsync then I need to point out that this script will remove any files on the remote server if they are not located on the local server. This means that if you delete or move a file from the local directory rsync will do the same for the remote backup directory. rsync has some very cool features and can be setup for a variety of different backup needs.

In addition I have created a log file of the rsync process. If there is an error you will be able to diagnose the problem by reviewing the log. I have also programmed the rsycn script to remove the log file after 7 days, you can easily increase or decrease the number of days required.

Please also note that the below rsycn script assumes that you have already installed your public and private keys on the local and remote computers/servers. If you do not know how to do this then check out my How To for: Secure Copy – without a password (pass on password with SCP).

#!/bin/bash
##########################################
# CREATED BY BRENDAN SKOREYKO            #
# WEB: www.skrakes.com                   #
# PURPOSE: RSYNC SINGLE DIRECTORY        #
# FILENAME: rsync-remote.bsh             #
##########################################

TIMESTAMP=`date +%Y%m%d_%H%M`
# YYYYMMDD_HHMM (TIMESTAMP)
DELDATE=`date +%Y%m%d --date="7 days ago"`
# YYYYMMDD (DELDATE)

LOGDIR=/home/<user-name>/log
LOG=/home/<user-name>/log/${TIMESTAMP}_rsync_htdocs.log

REMOTE_DEST_HOST=<myserver.com>
## PLACE THE DNS OR IP ADDRESS OF THE REMOTE BACKUP SERVER HERE
REMOTE_DEST_PORT=<port-number, if applicable>
## I CHANGED MY DEFAULT SSH PORT FOR SECURITY REASONS, AT LEAST ON VERY SENSITIVE SERVERS. I ALSO DISABLE ROOT LOGIN!!!
REMOTE_DEST_USR=<user-name>
## REMOTE USER NAME

# SOURCE DIRECTORIE ON LOCAL SERVER
SRC_DIR="/home/<user-name>/Music"

# DESTINATION DIRECTORIE ON REMOTE SERVER
DEST_DIR="/backup/<user-name>/"

# CREATE FUNCTION TO REMOVE LOG FILES OLDER THAN X NUMBER OF DAYS
function RemoveLogs
{
for i in $( ls $LOGDIR ); do
fname=`echo $i | grep -E '^[0-9]{8}\_[0-9]{4}\_rsync\.log$' | cut -d'_' -f1`
if [[ $fname != '' && $fname < $DELDATE ]]; then
echo REMOVE $i >> $LOG
rm -rfv $LOGDIR/$i >> $LOG
else
echo DO NOT REMOVE $i >> $LOG
fi
done
}

# BEGIN RSYNC
echo -e "Starting rsync to $REMOTE_DEST_HOST...\n" >> $LOG 2>&1
# RECURSIVE RSYNC
rsync -varz -e "ssh -p $REMOTE_DEST_PORT" --delete $SRC_DIR [email protected]$REMOTE_DEST_HOST:$DEST_DIR >> $LOG 2>&1
# END RSYNC
echo -e "\nEnding rsync to $REMOTE_DEST_HOST..." >> $LOG 2>&1
# CALL REMOVELOGS FUNCTION AND CLEANUP OLD LOG FILES
RemoveLogs

If you have any questions, comments or concerns please post them! I would like to point out that this is a “quick and dirty rsync script to backup a single directory to a remote server.”