Archive

Archive for October, 2007

Happy Birthday To Me

October 13th, 2007 11 comments

I thought of writing some witty script that would tell you I’ve become a year older, but I thought I’d just do it in english. Yes, today I turn twenty-eight years old.. wow.

Also, and even better news, is today is also my two-year wedding anniversary. Best two years ever and even better to come. Love you Catherine. ;)

I will, of course, be unreachable today. Try to catch me on Monday if you need anything.

If you’d like to get me something awesome for my special day you can do one of the following:

  • Squash an Ubuntu bug on Launchpad
  • Share an Ubuntu CD with a friend and help them install it
  • Dedicate some time and bandwidth today to sharing Ubuntu CD images
Categories: News Tags:

How To Install VirtualBox Open Source Edition on Ubuntu 7.10

October 12th, 2007 12 comments

UPDATE: Install VirtualBox on Ubuntu 9.10 “Karmic Koala”

This tutorial has Jeff Schroeder and Aaron Toponce to thank for their tips and prodding to try VirtualBox again. Thanks guys… now if one of us can just document simpler proper network bridging we’d be in good shape!

I’ve previously written on how to install VMware Server on Ubuntu 7.10, install VMware Server on Ubuntu 7.04 and install VMware Tools, but installing VirtualBox has a few of its own benefits. One, it is actually Open Source / Free Software whereas VMware is freeware. This is very important to a lot of people, myself included. When possible I prefer to run the “Free Stuff” vs the lock-in, trade-secrets, we-don’t-get-how-open-source-can-save-us stuff. VirtualBox will do that for us. It has also been found that VirtualBox can be faster than VMware Server in many cases. I haven’t done any direct side-by-side comparisons, but many of the articles that I have read refer to this. If anyone is able to do some direct testing I would be interested in hearing about it.

Installing VirtualBox Open Source Edition

Update: If you are running the final release of Ubuntu 7.10 “Gutsy Gibbon” you can cut down these steps as a pack of the modules are already built.  Use the following:

sudo aptitude install virtualbox-ose virtualbox-ose-modules-generic

You can now skip to step #3 below.

One of the benefits of running the Open Source Edition is that we get to compile it for our machines. This should lead to a bit better performance and, again, we’ll be rid of the binary blobs. We’ll need to install the following:

sudo aptitude install virtualbox-ose build-essential linux-headers-generic

We’ll then use module-assistant to prepare the kernel modules for our Virtualbox installation:

  1. sudo m-a prepare
  2. sudo m-a a-i virtualbox-ose
  3. sudo usermod -G vboxusers -a username (your username)
  4. sudo chmod 666 /dev/vboxdrv (this is only done to avoid a logout/login for the group-change to take effect)

You are now ready to launch VirtualBox. You can launch it from the command line using the virtualbox command.

I will be writing a few follow-up posts on configuring bridged networking and guest-additions for better performance within the guests.

If you’re not familiar, currently the NAT setup in VirtualBox means that your guest machines can get out, but nothing else can connect in. To use this viably for any type of guest-based-server we need bridging. I’ll be hacking together some steps for that soon.

Categories: virtualization Tags:

Ubuntu 7.10 “Gutsy Gibbon” Release Candidate Available – “Suitable for testing by any user”

October 11th, 2007 2 comments

The Ubuntu team is proud to announce the Release Candidate for version 7.10 of Ubuntu, Kubuntu, Edubuntu, Gobuntu, and Xubuntu codenamed “Gutsy Gibbon”. The Release Candidate includes installable live Desktop CDs, server images,
alternate text-mode installation CDs, and an upgrade wizard for users of the current stable release.

We consider this release candidate to be complete, stable, and suitable for testing by any user.

The final release of version 7.10 is scheduled for 18 October 2007 and will be supported for 18 months on both desktops and servers. Users requiring a longer support lifetime on servers may choose to continue using Ubuntu 6.06 LTS, with security support until 2011, rather than upgrade to 7.10.

Before installing or upgrading to Ubuntu 7.10 please read https://wiki.ubuntu.com/GutsyReleaseNotes

About The Release Candidate
—————————
The purpose of the Release Candidate is to solicit one last round of testing before the final release. Here are ways that you can help:

  • Upgrade from Ubuntu, Kubuntu, or Edubuntu 7.04 to the Release Candidate by following the instructions given above.
  • Participate in installation testing using the Release Candidate CD images, by following the testing and reporting instructions at http://wiki.ubuntu.com/Testing/ISO

Desktop highlights
——————

  • Compiz Fusion: This innovative compositing window manager enables 3-D desktop effects that let users work with, and see, their desktops in completely new ways.
  • Printer installation: In GNOME, printers are automatically configured for use as soon as they are connected.
  • Free Flash support with Gnash: Ubuntu 7.10 leads the pack with a preview of this Flash browser plugin. Although still actively in development and not yet fully supported by Ubuntu, Gnash gives a glimpse into the future of free Flash, bringing partial Flash support to 64-bit desktop systems.
  • Automated Firefox plugin installation: Beyond the addition of Gnash, Firefox in Ubuntu now supports automatic installation of popular plugins through the standard Ubuntu package repositories, for a richer web-browsing experience with the integrated security support of the rest of the Ubuntu system.

Server highlights
—————–

  • AppArmor: This easy-to-deploy kernel technology limits the resources an application is allowed to access and can be used to provide an added layer of protection against undiscovered security vulnerabilities in applications.
  • Pre-configured installation options: Mail Server, Print Server, Database Server, and File Server options join existing LAMP and DNS options for pre-configured installations, easing the deployment of common server configurations.

Edubuntu highlights
——————-

  • Faster thin clients: Thin clients have been sped up significantly through the use of compressed images.
  • Updated login manager: The thin-client login manager has been completely reworked, with themes for all Ubuntu flavors, support for autologin, and optional unencrypted graphics transport for improved performance on slower hardware.

Kubuntu highlights
——————
As well as the above desktop highlights, the following new features are specific to KDE users:

  • Dolphin file manager: This updated file manager gives Ubuntu users a glimpse of the upcoming KDE 4.
  • Strigi desktop search: Another pillar of KDE 4 available now in Kubuntu.
  • Restricted-manager: Kubuntu 7.10 includes a KDE front-end for easy nstallation of proprietary drivers, complementing the existing GNOME front-end.

Please see https://wiki.kubuntu.org/GutsyGibbon/RC/Kubuntu for details.

Gobuntu highlights
——————
Gobuntu 7.10 is the debut full release of the Ubuntu version that is composed entirely of open source non-restricted software. For experienced linux enthusiasts, Gobuntu will act as the test bed for developing a user-friendly operating system with no compromise in terms of the open source philosophy.

This initial release comes without any software from the restricted component, and with artwork for usplash and the isolinux CD bootloader.

The full release notes can be found at http://www.ubuntu.com/testing/710rc

To Get the Ubuntu 7.10 Release Candidate CD
——————————

To perform a new installation or try out 7.10 “live” from CD, download the Ubuntu 7.10 Release Candidate (choose the mirror closest to you):

Europe:
http://se.releases.ubuntu.com/7.10 (Sweden)
http://nl.releases.ubuntu.com/7.10 (The Netherlands)
http://ftp.snt.utwente.nl/pub/linux/ubuntu-releases/7.10 (The Netherlands)
http://ie.releases.ubuntu.com/7.10 (Ireland)
http://it.releases.ubuntu.com/7.10 (Italy)
http://gb.releases.ubuntu.com/7.10 (Great Britain)
http://de.releases.ubuntu.com/7.10 (Germany)
http://fr.releases.ubuntu.com/7.10 (France)

Asia/Pacific:
http://tw.releases.ubuntu.com/7.10 (Taiwan)
http://mirror.optus.net/ubuntu-releases/7.10 (Australia)

Africa:
http://za.releases.ubuntu.com/7.10 (South Africa)

North America:
http://ca.releases.ubuntu.com/7.10 (Canada)
http://releases.ubuntu.com/7.10 (United States)

South America:
http://br.releases.ubuntu.com/7.10 (Brazil)

Rest of the world:
http://releases.ubuntu.com/7.10 (Great Britain)

Please download using Bittorrent if possible. For more information about using Bittorrent, see:
https://help.ubuntu.com/community/BitTorrent

Upgrading from Ubuntu 7.04
————————–
To upgrade from Ubuntu 7.04 to Ubuntu 7.10 Release Candidate, follow these instructions:
https://help.ubuntu.com/community/GutsyUpgrades

Feedback and Helping
——————–
If you would like to help shape Ubuntu to better meet your future needs, take a look at the list of ways you can participate at http://www.ubuntu.com/community/participate/

Your comments, bug reports, patches, and suggestions will help turn this release into the best release of Ubuntu ever. Please report bugs through the Launchpad bug tracker:

https://bugs.launchpad.net/ubuntu/gutsy/+bugs

If you have a question, or if you think you may have found a bug but aren’t sure, first try asking on the #ubuntu IRC channel on FreeNode, on the Ubuntu Users mailing list, or on the Ubuntu forums:
http://lists.ubuntu.com/mailman/listinfo/ubuntu-users
http://www.ubuntuforums.org/

Categories: News Tags:

How To Configure PXE (Network) Booting on Ubuntu For Network Based Installations

October 11th, 2007 18 comments

Previously I outlined how to install Ubuntu over the network using a netboot install CD or USB image. This tutorial takes it a step further and allows you to boot your machine from the network environment and select from a list of what you would like to install. This comes to the same end result as the previous tutorial (an installed machine without having to burn a CD), but doesn’t require the boot CD or USB image.

This will take more work and should also be considered intermediate to advanced. Please read through the tutorial in its entirety before diving in, researching any aspects of the tutorial you’re not familiar with prior to attempting these steps.

Requirements

There are a few things that we’ll need in order to set this up. These are outlined below:

The way that these services will be used, as a quick overview, is that the DHCP server will listen for and assign IP addresses for machines on the local network. The TFTP server will hand a small kernel and ramdisk image to the client as it boots from the network environment and the contents of the Ubuntu CD will be used to install, being shared over the web via the Apache server. This is, again, an extension of the previous tutorial on network-based installations, this simply removes the need for a CD or USB image to boot the machine.

DHCP Setup

First of all we’ll install the DHCP server to initially hand out the IP addresses and point to the network boot images:

sudo aptitude install dhcp3-server

Now that we have the DHCP server installed there are a few small changes we need to make to the core configuration. Full detail on DHCP configuration is outside of the scope of this tutorial, but this should give you enough to achieve the goal of this tutorial.

We’ll first edit the DHCP configuration file, normally found in /etc/dhcp.conf:

sudo vim /etc/dhcp.conf

We’ll add two lines into this file outlining the address of the TFTP server (probably the same machine) and the path to the pxelinux.0 file we want to hand off to the client machines.

next-server 192.168.0.254 (the IP address of your DHCP/TFTP server)

filename "/tftpboot/pxelinux.0";

After we have made these changes we need to restart the DHCP server. We can do this using the command:

sudo /etc/init.d/dhcpd restart

Apache Setup

We need to export the contents of the CD over the web so that the network based installer can find them for use with deb. For this we’ll install apache. The base configuration should be enough for what we need here. Further details on configuring Apache are outside of the scope of this tutorial.

sudo aptitude install apache2

CD Image Contents

We’ll need to extract the contents of the CD onto the DHCP/TFTP server so that we can access the packages and the installer kernel. We can locally mount and copy the CD contents using these commands:

sudo mkdir /var/www/html/ubuntu7.10 (or, if you're going to export multiple versions select something more unique)

sudo mount -o loop CD.iso /mnt

sudo cp -a /mnt/* /var/www/html/ubuntu.710

PXELinux Setup

Now that the DHCP server knows where the tftp server is and the path to the file that it should direct clients to we need to configure the PXE end of things, which is what allows us to boot a kernel over the network or select from a list of kernels to boot over the network.

Relative to the location of the pxelinux.0 file we can make a directory for the distribution/version that we want to boot. For example we might want to install Ubuntu 7.10 so we’d create a folder U7.10, or ubuntu7.10–something to specify what version and variant this will hold.

sudo mkdir /tftboot/ubuntu7.10

We then need to copy the network-based installer kernel and initrd.gz into the newly created folder:

sudo cp /var/www/html/ubuntu7.10/install/netboot/ubuntu-installer/i386/{linux, initrd.gz} /tftboot/ubuntu7.10/

We now need to build the file that will list what is available and how to select it from a (optional) list.

pxelinux.cfg/default

We’ll now move into the /tftpboot/pxelinux.cfg directory and edit the file “default”. If this file doesn’t exist that is OK, we’ll create one.

sudo vim /tftpboot/pxelinux.cfg/default

We’ll now make a list of the boot options that might be available on this network booting system:

default 0

prompt 1

display msgs/boot.msg

# begin list of available boot options

label ubuntu7.10

kernel ubuntu7.10/linux

append initrd=ubuntu7.10/initrd.gz

This file basically outlines that a list will be presented to the user booting over the network, which we’ll create in the next step, and defines what will be loaded for each menu item.

pxelinux.cfg/msgs/boot.msg

We’ll now create a file that will give a display of the different boot options available. Your setup may only have one option outlined for installation, others might have three, four, five–a dozen different versions and variations available to install. We’ll create a list here outlining what is available and what option to enter to select the option.

This file can be something as simple as:

ubuntu7.10 - Select this to install Ubuntu 7.10

kubuntu7.10 - Select this to install Kubuntu 7.10

ubuntu7.04 - Select this to install Ubuntu 7.04

kubuntu7.04 - Select this to install Kubuntu 7.10

…etc. Creating a list such as this after having repeated the above steps for each version and variant you want to make available and you should be ready to go. One thing to note is that the boot option entered at the list prompt should match the label defined in the pxelinux.cfg/default file.

Starting The Installer

You should now be ready to install your machine by booting and instructing your machine to boot from the network. If you have trouble booting to either of those devices you might check your BIOS settings to see that one of them takes priority over the main hard drive.

You’ll be presented with a very basic menu when the netboot installer loads.

To install only the base system type ’server’, then ENTER.

For the default installation, press ENTER.

The default installation is suitable for most desktop or laptop systems.

Navigate through the installer as normal but watch for the step entitled:

Choose a mirror of the Ubuntu archive

At this step we will tell the installer to use a custom repository, in this case being the locally shared CD contents we set up previously.

Instead of selecting your country in this step go up to the first option listed: (pg-up to the top)

enter information manually

I don’t think the option of entering custom information is very intuitive so I missed this the first few times through. Watch for this step. If you are given a prompt offering us.archive.ubuntu.com or CC.archive.ubuntu.com you’ve gone too far!

The next step will prompt you for the hostname or IP address of the server you will be installing from. This is the IP address of the server you copied the CD contents and installed Apache to.

After the hostname or IP is entered the installer will prompt you for the path to the publicly shared contents. If you closely followed these steps the default entry of /ubuntu/ should work. If you copied your CD contents into a folder other than /ubuntu/ you’ll need to update this accordingly.

At this point navigate through the installer as normal and enjoy what should be faster installation speeds as network-based is usually faster than CD-based.

As I mentioned before. This should be considered more technical in nature than many of my previous tutorials. Best of luck, and enjoy network based booting and installation!

Categories: Installation Tags:

Refresh The Katapult Launcher in Kubuntu

October 10th, 2007 8 comments

After posting my previous tutorial on Manually Installing Firefox I noticed that the Katapult Launcher in Kubuntu was not aware of my newly installed application. Apparently you need to refresh Katapult before it’ll see the changes. For those of you that use Katapult this little trick might be handy.. and for those of you that don’t use Katapult you’re really missing out. This is one of the apps that I really like in KDE that gnome doesn’t really have.

Refreshing the Katapult Launcher

Refreshing Katapult to be aware of newly installed applications can be done in just a few quick steps:

  1. Hit “Alt-Space” to bring up the Katapult Launcher
  2. Hit “Ctrl-C” and select “Configure Katapult
  3. Click “Save” without making any changes

Your newly installed applications will now be launchable from within Katapult. Katapult ftw!

Categories: KDE Tags:

Ubuntu 7.10 “Gutsy” Supporting Install-Time Encryption

October 9th, 2007 15 comments

So I’ve spent the last few evenings building a local Ubuntu repository mirror for localized network installations.  While installing a machine today I noticed a new option within the partitioner.  Encryption!  The installer now lets you select partitions to be installed as encrypted, and also a guided partitioner that will create encrypted LVM partitions.

I’ve played with the features a bit since I found it and this is something I’ll definitely be using!  Encrypted root, swap, etc.  The only thing that is unencrypted is the /boot partition, which is required for the boot process pre-unencrypting.

So far, in my continued testing, Ubuntu 7.10 “Gutsy” is shaping up very nicely.  For any of you that have been putting off updating you have nothing to be afraid of.  It’s been working great for me so far and the more people we can get finding and reporting bugs for the next week the better it’ll get before final.

Categories: Ubuntu Tags:

Manually Installing The Latest Firefox in Kubuntu : A Cleaner Installation

October 9th, 2007 27 comments

So I’ve decided that Konqueror is just not the web browser that some people want it to be. Call me spoiled / ruined for having spent so much time on Firefox, but I just can’t use it to be as productive as I want to be so I’ve installed Firefox on my Kubuntu installation. For those of you that are in similar situations keep reading and find out how to manually install Firefox within KDE.

Now, I am perfectly aware that I can download and install the Firefox package simply and easily using Adept or aptitude. I have one very key reason why I don’t want to do it this way. I don’t want the pile of gnome dependencies that come with it. If I’m going to run KDE I want to run a clean KDE, and adding GTK clutter is not on my agenda. So, manually installing Firefox is nearly as easy and makes for a much cleaner installation in my mind.

Installing Firefox Manually

Update: I found in some additional testing that using the following command *just* installed Firefox and none of the other packages so.. you take your pick: (I normally use aptitude to install which installed optional packages as well).

sudo apt-get install firefox

OR

  1. Download the latest version of Firefox from the Mozilla web page. Save this file to disk.
  2. sudo tar -C /opt/ -zxvf firefox-*.tar.gz
  3. sudo aptitude install libstdc++5
  4. sudo ln -s /opt/firefox/firefox /usr/local/bin/firefox
  5. sudo vim ~/.local/share/applications/firefox.desktop

Put the following content into the newly created file:

[Desktop Entry]
Comment=Firefox Web Browser
Exec=firefox
GenericName=Web Browser
Icon=/opt/firefox/icons/mozicon128.png
Name=Firefox
Path=
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=

Done. You should now be able to launch Firefox either from the command line (firefox) or from your KDE menu within the Internet section. When a new release of Firefox comes out you should simply be able to repeat steps #1 and #2 and you’re done. I will be running Firefox as my default browser on Kubuntu and using this method I don’t have to deal with the gnome dependencies cluttering things up!

Categories: Web Development Tags:

How To Install Ubuntu Locally Over The Network

October 8th, 2007 22 comments

I spent some time this week figuring out the requirements for installing Ubuntu locally over the network. Ubuntu has netboot installers which are more than happy to go find a public repository mirror for you, but how about installing over the LAN using the contents of the CD as the repository? Well, if you’re interested in fast installations and no longer burning CDs this tutorial is for you. You should note that this tutorial is considered intermediate to advanced so please read through the entire contents before you continue and research any steps you’re not familiar with before diving in.

Requirements

This tutorial does not outline PXE boot based installation information. That is for an upcoming tutorial. This simply outlines installing the contents of the CD over the network. In order to do this we’ll need a few basic things:

  1. CD image
  2. Apache
  3. netboot installer

The way that each of these requirements will be used is that we’ll copy the contents of the CD to a web-accessible share on Apache and then boot the machine-to-be-installed via the netboot installer (CD or USB based options available here).

  1. Download the .iso image for the ubuntu version and variant that you want, saving it to disk (alternate, not desktop!).
  2. Install apache “sudo aptitude install apache2” *
  3. netboot installer image i386 64bit (compatible for use with any alternate install image in step #1)

* The configuration of apache is beyond the scope of this tutorial but a basic installation should provide enough core functionality to allow us to continue with the installation.

Preparing the CD for installation

We’ll need to unpack the contents of the downloaded CD .iso file. The way I generally do this is using these commands:

sudo mkdir /var/www/ubuntu/ sudo mount -o loop /path/to/.iso /mnt sudo cp -a /mnt/* /var/www/ubuntu/

If you’re not familiar with the above commands we’re first creating a directory called ubuntu within our apache web-accessible directory. We’re then locally “loop” mounting the CD image to the location /mnt. Finally we’re copying the contents of the CD to our new directory.

Preparing the Installer

We’ll now need a netboot installer created. This is a very minimal installation CD that can be used to install any other Ubuntu image. For example one copy of this netboot installer will allow you to install previous, current and (most likely) future releases of Ubuntu as long as you have access to the web-accessible CD image or public repository. So, although above I promised no more burning CDs you will actually need to burn just *one* more. Also, this netboot installer image is available for CD or USB image if you prefer one over the other (I prefer USB). Hopefully you’ve already followed step #3 of the Requirements section and you have either the mini.iso or the boot.img.gz file downloaded. To prepare either of those for use do follow these steps: mini.iso (CD)

  • (gnome) insert a writable disk into your machine, right-click mini.iso and select “Write to disk”.
  • (KDE) insert a writable disk into your machine, right-click mini.iso and select “Actions > Write CD image with K3B”

boot.img.gz (USB) You’ll first need to uncompress this file before you can write the image to disk:

gunzip boot.img.gz

insert a USB device that you’ll use as your boot device. ALL DATA WILL BE WIPED TO MAKE IT BOOTABLE. You can use the ‘dmesg’ command to see what device your USB was detected as (sdb, sdc, etc). We’ll then write the contents of the image to the device using dd:

dd if=boot.img of=/dev/sdX (where X is the device detected with dmesg, sdb, etc)

Starting The Installer

You should now be ready to install your machine by booting either the CD or via the USB you’ve created. If you have trouble booting to either of those devices you might check your BIOS settings to see that one of them takes priority over the main hard drive. If you are using the boot.img on a USB you will want to remove this device when you are prompted with the language selection menu. This will help avoid conflicts with drives-to-be-installed, where to install the Boot Loader, etc. You’ll be presented with a very basic menu when the netboot installer loads.

To install only the base system type 'server', then ENTER. For the default installation, press ENTER.

The default installation is suitable for most desktop or laptop systems. Navigate through the installer as normal but watch for the step entitled:

Choose a mirror of the Ubuntu archive

At this step we will tell the installer to use a custom repository, in this case being the locally shared CD contents we set up previously. Instead of selecting your country in this step go up to the first option listed: (pg-up to the top)

enter information manually

I don’t think the option of entering custom information is very intuitive so I missed this the first few times through. Watch for this step. If you are given a prompt offering us.archive.ubuntu.com or CC.archive.ubuntu.com you’ve gone too far! The next step will prompt you for the hostname or IP address of the server you will be installing from. This is the IP address of the server you copied the CD contents and installed Apache to. After the hostname or IP is entered the installer will prompt you for the path to the publicly shared contents. If you closely followed these steps the default entry of /ubuntu/ should work. If you copied your CD contents into a folder other than /ubuntu/ you’ll need to update this accordingly. At this point navigate through the installer as normal and enjoy what should be faster installation speeds as network-based is usually faster than CD-based. As usual if you have any questions feel free to leave a comment. It should be noted, again, that this tutorial is probably considered intermediate to advanced so you may not want to undertake this if you’re a n00b.

Categories: Installation Tags:

Sinking Deeper – Continued Impressions of Kubuntu

October 7th, 2007 5 comments

Well I am a bit pleasantly surprised to say that I’m very much enjoying my time in KDE right now. There are some bugs, as is to be expected, but for the most part I’m continuing to be very productive and I’m learning a lot. I think some of you were right to mention that perhaps I should until the final release. There have been about a dozen bugs that I’ve submitted for Kubuntu 7.10 beta, but on the bright side hopefully many of those will be squished by final.

I have installed Kubuntu 7.04 inside VirtualBox (expect VirtualBox tutorials very soon!). Kubuntu 7.04 seems a little more polished but, again, I’m blaming the beta status of 7.10 for the “issues”.

The few things that I still miss are:

  • Tomboy. I’ve tried KNotes and Basket but the one is too light and the other too heavy. Tomboy seemed just right.
  • System Monitor Applet. I tried the applet in KDE but I didn’t think it was as well organized or easy-to-read.

Thanks again to all the continued comments in relation to a shift to KDE. I appreciate all the feedback and its making my experience a better one. Hopefully all of your contributions will make for some good KDE specific tutorials soon.

Categories: KDE Tags:

Limiting Access to Websites/Directories with .htaccess

October 6th, 2007 8 comments

This post is not so much a tutorial as my own notes on restricting access with .htaccess files and apache. As has been the case with many of my previous tutorials, the basis is writing the steps down so I can refer to them later. Turns out making notes public on a blog is a good idea. In any event, this will outline restricting access to directories on a user-level with .htaccess.

Create the .htaccess file

To limit access to a directory we need to create a .htaccess file where we will outline the restrictions for the location. Any folder within your publicly accessible web page can have its own custom .htaccess file. note: some shared hosting companies do not allow custom .htaccess restrictions for individual sites. You may need to check with your host on this.

Within your .htaccess file you would include something along these lines:

# sample .htaccess file
AuthName "Private Website"
AuthType basic
AuthUserFile /path/to/.htpasswd
require user username (optional)

In the above sample config “Private Website” can be any message you want displayed to the user when trying to authenticate to that page. /path/to/.htpasswd is what we will work on next in generating usernames and hashed passwords for authentication. require user username can limit access to only those users listed.

Create the .htpasswd file

In the .htaccess file we’ve outlined a path/to/.htpasswd file which we need to also create. It is a good idea to keep this file in a non web-accessible location. For example, if your web root is /var/www/html/ you might put the .htpasswd file in /var/www/.htpasswd. This way it is not accessible publicly and limits the chances of someone being able to get a hold of and attempt to break your hashed passwords for access.

To populate the .htpasswd file we’ll use the command htpasswd. To initially create the file we’d use:

htpasswd -cm /var/www/.htpasswd user-one

The -c will initially create the file. The -m will md5 encrypt the passwords for additional security. The htpasswd command will prompt you for a password.

To add additional users to your .htpasswd access list use:

htpasswd -m /var/www/.htpasswd user-two

Be careful not to use the -c option when adding additional users as this will recreate the file and overwrite previous entries.

Once these two files are in place access to the folder containing the .htaccess file will be limited to only those users listed within the .htpasswd file and require authentication via a password. This is great for sharing web accessible files with only certain users, creating private folders, etc.

If your host allows custom .htaccess file creation but does not provide you access to the htpasswd command you can try to generate your .htpasswd file using an apache installation on a local machine and copying the resulting files over.

Categories: Web Development Tags: ,