Avoid giving 777 permissions

Just a quick post for me to remember the following workflow of commands:

sudo find . -type d -exec chmod 755 {} \;
sudo find . -type f -exec chmod 644 {} \;
sudo chgrp -R www-data .
sudo chmod -R g+w .
2010-06-28 [, , ]
View Comments

Redirecting Apache traffic to a maintenance page

Here’s a simple solution to redirect users to a maintenance page in Apache. This rewrite rule can stay in your config (<VirtualHost> or .htaccess) all the time; all that you need to enable it is to create the file maintenance.html.

The first rewrite condition checks to see if the file exists, and only if it does, will it redirect all traffic to it. The second rewrite condition is there to prevent an infinite loop, by only redirecting traffic to files other than maintenance.html.

RewriteEngine On

RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{REQUEST_FILENAME} !/maintenance.html
RewriteRule ^.*$    /maintenance.html [L]
2010-05-03 [, , ]
View Comments

Apache, PHP and MongoDB on Mac OS X 10.6 Snow Leopard

MongoDB (from “humongous”) is a scalable, high-performance, open source, schema-free, document-oriented database.

There’s a lot of buzz brewing about it, so I wanted to give it a try with PHP on my development Mac. The following is how I went about installing Apache, PHP and MongoDB on Snow Leopard. You must have installed the Xcode developer tools (found on the Snow Leopard install DVD) and MacPorts for this to all work.

(more…)

mod_rewrite and Mac OS X Personal Web Sharing

It was very frustrating installing a fresh WordPress on my Mac and finding that the permalinks didn’t work. Turns out the default Apache settings for personal web sharing on OS X disable .htaccess overriding.

sudo mate /etc/httpd/users/yourusername.conf

Now you’ll want to enable Apache to follow symbolic links:

Options Indexes MultiViews FollowSymLinks

And to allow .htaccess overriding:

AllowOverride All

The file should then look like:

<Directory "/Users/yourusername/Sites/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Now in System Preferences, stop and start ‘Personal Web Sharing’. Things should work perfectly now.

Subversion 1.4.0 from source via Apache 2.2 on Ubuntu Dapper

This howto assumes you’ve already followed my Building Apache 2.2 from source article.

Now we’re going to install Subversion 1.4.0 from source so that it can be access via Apache with authentication.

(more…)

Building Apache 2.2 from source for Ubuntu Dapper

Two reasons you might want to do this.

  1. You want to host a Rails application using Mongrel via Apache and mod_proxy_balancer.
  2. You’re studying in a Website administration module for your 3rd year Software Engineering degree :)

Seriously though, if you don’t want to use mod_proxy_balancer, just do a normal apt-get install of Apache 2 and you’ll be fine. mod_proxy_balancer is only available for Apache 2.2, and currently, that’s not available from the Ubuntu repositories via apt-get.

This article only covers installing Apache 2.2 – I’ll write another one for getting Subversion and PHP working shortly afterwards.

(more…)

Ubuntu Dapper Web Server How-to

It’s finally here, my updated how-to on how to get Ubuntu Dapper up and running as a home web server. Perfect for hosting those small web sites and blogs. My original Ubuntu 5.10 web server how-to is still available.

This updated version is very similar to the 5.10 how-to, however, there are a few changes required. The following changes have been made:

  • Setting up the Multiverse and Universe repositories
  • The packages to install Ruby
  • Setting a symbolic link for Ruby
  • Updating rubygems
  • Clearing the rubygems cache

Other than those, the rest of the how-to is the same as the Breezy how-to.

(more…)