Making public_html Work in Ubuntu 8.04 with Apache2

Filed Under (Web Development) by manatarms on 20-01-2009

Tagged Under : , ,

Ever wanted each user on your server to have their own web directory? I wanted users on my server to have access to the public_html directory in their home directory so that they could display content at http://www.mydomain.com/~USERNAME. How do you do this?

  1. Edit /etc/apache2/apache2.conf
  2. Find the section that looks like this:
  3. 1
    2
    3
    4
    5
    6
    7
    8
    
    #UserDir is now a module
    #UserDir public_html
    #UserDir disabled root
     
    #<Directory /home/*/public_html>
    #	AllowOverride FileInfo AuthConfig Limit
    #   Options Indexes SymLinksIfOwnerMatch IncludesNoExec
    #</Directory>
  4. Make it look like this:

    1
    2
    3
    4
    5
    6
    7
    8
    
    #UserDir is now a module
    UserDir public_html
    #UserDir disabled root
     
    <Directory /home/*/public_html>
    	AllowOverride FileInfo AuthConfig Limit
    	Options Indexes SymLinksIfOwnerMatch IncludesNoExec
    </Directory>

  5. Sit back and relish in your own glory knowing that you have just accomplished something done today!

How did I figure this out? Click here.

Password Protect a Directory in Apache 2

Filed Under (Web Development) by manatarms on 29-12-2008

Tagged Under : ,

For anyone who wants to do this, the steps are as follows:

  • Edit /etc/apach2/sites-available/default
  • Look for the line “AllowOverride” in the section <Directory /var/www>
  • Change the line from “AllowOverride None” to “AllowOverride All”
  • Change to the directory you wish to password protect
  • Create a .htaccess file. The contents of mine is shown below. The only truly important line is AuthUserFile. This parameter should contain the path to the file containing your usernames/passwords. You should be able to figure out what everything else is on your own.
  • Create the .htpasswd file in the directory of your choosing with the following command:
1
sudo htpasswd -c /path/to/.htpasswd username

My .htaccess file:

1
2
3
4
5
6
7
AuthUserFile /var/www/path/to/site/.htpasswd
AuthName "Please Log In"
AuthGroupFile /dev/null
AuthType Basic
<Limit GET POST PUT>
    Require valid-user
<Limit>

Apache Compiler Error

Filed Under (Web Development) by on 12-09-2007

Tagged Under : ,

While upgrading Apache on Mac OS X 10.4 I got the following error:

Cannot use an external APR-util with the bundled APR

The solution – Add this to configure options:

–with-included-apr