# Enable UserDir in Apache24



## selhan (May 13, 2014)

Hi, according to some research I was trying to enable the user directory in Apache in order to allow users to have access to their public_html directory or http://www.mywebpage.com/~user.

In my httpd.conf file I uncommented this line:

```
# User home directories
Include etc/apache24/extra/httpd-userdir.conf
```

This is what I have by default in /usr/local/etc/apache24/extra/httpd-userdir.conf:

```
# Settings for user home directories
#
# Required module: mod_authz_core, mod_authz_host, mod_userdir

#
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.  Note that you must also set
# the default access control for these directories, as in the example below.
#
UserDir public_html

UserDir disabled root toor daemon operator bin tty kmem games news man sshd
smmsp mailnull bind unbound proxy _pflogd _dhcp uucp pop auditdistd www hast nobody

#
# Control access to UserDir directories.  The following is an example
# for a site where these directories are restricted to read-only.
#
<Directory "/home/*/public_html">
    AllowOverride FileInfo AuthConfig Limit Indexes
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    Require method GET POST OPTIONS
</Directory>
```

And when I restart Apache, I get this error:

```
Performing sanity check on apache24 configuration:
AH00526: Syntax error on line 10 of /usr/local/etc/apache24/extra/httpd-userdir.conf:
Invalid command 'UserDir', perhaps misspelled or defined by a module not included in the server configuration
```

Can anyone tell me how to fix this error?

The OS is freeBSD FreeBSD 10.


----------



## fonz (May 13, 2014)

selhan said:
			
		

> ```
> # User home directories
> Include etc/apache24/extra/httpd-userdir.conf
> ```


I'm not an Apache expert, but is that path correct? Perhaps it ought to be */usr/local/*etc/apache24/extra/httpd-userdir.conf or something along those lines. Which might depend on exactly where the file httpd-userdir.conf is located.


----------



## selhan (May 13, 2014)

Hey @fonz, the paths are supposed to be good, since I did copy and paste them (not typing) directly from the files, but it is a good point anyway.

Well, I tried with a different path as your suggestion, but I got the same error.


----------



## SirDice (May 14, 2014)

Did you perhaps turn the option off?


```
USERDIR=on: Mapping of requests to user-specific directories
```


----------



## usdmatt (May 14, 2014)

It's complaining that the UserDir directive is invalid. Are you sure you haven't commented out the part of httpd.conf where it loads the `userdir` module?

This is from Apache 2.2 but I expect 2.4 will have a similar module to provide the UserDir functionality:

```
LoadModule userdir_module libexec/apache22/mod_userdir.so
```


----------



## DutchDaemon (May 14, 2014)

Does `httpd -M` produce mod_authz_core, mod_authz_host, mod_userdir? According to your configuration those are all required:


```
# Required module: mod_authz_core, mod_authz_host, mod_userdir
```

In Apache 2.2 only mod_userdir is required.


----------



## selhan (May 15, 2014)

@DutchDaemon, those mod_ules_ are uncommented by default in httpd.conf*.*


----------



## selhan (May 15, 2014)

Yes @usdmatt , I'm getting this error exactly after I uncommented this line: 
	
	



```
Include etc/apache24/extra/httpd-userdir.conf
```


----------



## DutchDaemon (May 16, 2014)

Again:



> Does `httpd -M` produce mod_authz_core, mod_authz_host, mod_userdir?


----------



## selhan (May 19, 2014)

Yes.


----------



## DutchDaemon (May 20, 2014)

Then all I can suggest is that you scan your configuration files meticulously for stray characters (like a comma or a control character) that may have been left in there after editing. Open them in an editor that you do not normally use. If necessary, back up your files and make a fresh installation of Apache, and work from that.


----------



## nethead (Jan 1, 2015)

Uncomment the line:

```
LoadModule userdir_module libexec/apache24/mod_userdir.so
```
Up at the top where all the modules are in httpd.conf.


----------



## Kevin Butski (Jul 2, 2015)

You need to uncomment two lines in the /usr/local/etc/apache24/http.conf file.


```
LoadModule userdir_module libexec/apache24/mod_userdir.so

# User home directories
Include etc/apache24/extra/httpd-userdir.conf
```


----------

