WordPress and jQuery Masonry setup with floating images

The Masonry jQuery plugin is an easy way to stack divs in a nice grid without the usual problem with CSS floats – e.g divs with different heights will not look good beside each other.

In a recent project a client wanted WordPress thumbnails stacked in this way. I first added some code to functions.php in order to set widths and heights to the selected thumbnails. Continue reading

Ultimate .htaccess rewrite tutorial with 301 redirects

So, over the last couple of weeks I have moved several sites to new locations and publishing platforms which demands some redirects unless you wanna be a SEO killer. The examples below are mostly URLs with query strings which I either want to hide or make prettier. The fourth and fifth examples are quite useful when you want to create human readable URLs for APIs or web services.

Updated 22 November 2011.

Continue reading

Shell script: create virtual hosts with PHP/fastCGI (mod_fcgi)

UPDATES:

Version 1.1 – June 20 2011

  • Added  ”FcgidMaxRequestLen 1000000000” to virtual host settings in order to get the WordPress Flash based image uploader to work. The default value in fcgid caused it to throw a “HTTP Error” when crunching the images.
  • Commented out the Apache directive “ServerAlias” which in previous version defaulted to *.example.com. That of course might cause problems when setting up both root domain and sub domains on the same server. Feel free to uncomment or add custom aliases.
  • Moved the ports.conf tip from script echo to comments at the end.

Continue reading

Shell script – install LAMP with dependencies for PHP/mod_fcgi

This script is intended for fresh Linux installs to provide support for the LAMP stack running with mod_fcgid instead of the default mod_php Apache module.

UPDATES:

Version 1.1 – August 18 2011

  • Added apt-get update to refresh package list
  • Added MySQL server
  • Added php5-gd library (to comply with Drupal 7 requirements)
  • Added PDO MySQL driver (to comply with Drupal 7 requirements)
  • Moved specific php.ini extensions and fixes to separate custom.ini file
  • Added restart of proftpd Continue reading

Custom WordPress Varnish VCL v1

Over the last couple of days I’ve been struggling with getting my dev WordPress environment set up with Varnish (2.1.3) Out of the box with minimal config it provides great speed and hitrate but zero functionality together with the cookie-laden WordPress. So far I have tested a bunch of VCL:s found online but here’s my take (based on practically every nice example found out there). Continue reading

Webmin – Hetzner VPS Debian 6 LAMP + fastcgi + php5 + apache

This tutorial applies to servers preconfigured with LAMP (Debian 6, Apache 2, Mysql 5, PHP 5.2). If the LAMP stack is not installed, it’s pretty straightforward to install the respective components via apt-get install. Since the image I’m using has Webmin preinstalled I use it to quickly get started. Continue reading

Automount a volume in Fedora

To automatically mount a specified volume each time you boot into Fedora, edit the following file:

/etc/fstab

Add the following line  at the end depending on volume and mount point:

/dev/sdb1 /var/hda/files/

Save and exit.

(If the volume is formatted with NTFS, use the following syntax instead)

/dev/sdb1 /var/hda/files/ ntfs-3g defaults 0 0

Mount a drive or volume to use with Amahi home server

How to mount a drive or volume to be accessible by Amahi home server:

First you need to find out what the volume is called within Fedora. To list the drives recognized by the system type the following in terminal:

ls /dev/sd*

Let’s say you want to mount the volume named “sdb1″, then use:

mount /dev/sdb1 /var/hda/files/myvolume

If the volume you want to mount is an NTFS drive, instead use:

mount -t ntfs /dev/sdb1 /var/hda/files/myvolume

Note that you may need to change priviligies on the mounted drive if you want to download directly from Amahi or copy to it over the network.

When you’ve mounted the volume in /var/files/ you only need to specify the name you gave it to add it as a share in Amahi share settings.

If you want to mount the volume automatically when you boot, read Automount a volume in Fedora.