summaryrefslogtreecommitdiff
path: root/docs/manual/howto/public_html.xml
blob: fbcef0fb7f09715180599abc44790c3815c3b7ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
<!-- $LastChangedRevision$ -->

<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<manualpage metafile="public_html.xml.meta">
<parentdocument href="./">How-To / Tutorials</parentdocument>

  <title>Per-user web directories</title>

<summary>
<p>On systems with multiple users, each user can be permitted to have a
    web site in their home directory using the <directive
    module="mod_userdir">UserDir</directive> directive. Visitors
    to a URL <code>http://example.com/~username/</code> will get content
    out of the home directory of the user "<code>username</code>", out of
    the subdirectory specified by the <directive
    module="mod_userdir">UserDir</directive> directive.</p>
<p>Note that, by default, access to these directories is <strong>not</strong>
    enabled. You can enable access when using <directive module="mod_userdir"
    >UserDir</directive> by uncommenting the line</p>
    <example>
      #Include conf/extra/httpd-userdir.conf
    </example>
    <p>in the default config file <code>conf/httpd.conf</code>, and adapting the <code
    >httpd-userdir.conf</code>
    file as necessary, or by including the appropriate directives in a
    <code>Directory</code> block within the main config file.</p>
</summary>

<seealso><a href="../urlmapping.html">Mapping URLs to the Filesystem</a></seealso>

  <section id="related">
    <title>Per-user web directories</title>
    <related>
      <modulelist>
        <module>mod_userdir</module>
      </modulelist>
      <directivelist>
        <directive module="mod_userdir">UserDir</directive>
        <directive module="core">DirectoryMatch</directive>
        <directive module="core">AllowOverride</directive>
      </directivelist>
    </related>
    </section>

    <section id="userdir">
    <title>Setting the file path with UserDir</title>

    <p>The <directive module="mod_userdir">UserDir</directive>
    directive specifies a directory out of which per-user
    content is loaded. This directive may take several different forms.</p>

    <p>If a path is given which does not start with a leading slash, it is
    assumed to be a directory path relative to the home directory of the
    specified user. Given this configuration:</p>

    <highlight language="config">UserDir public_html</highlight>

    <p>the URL <code>http://example.com/~rbowen/file.html</code> will be
    translated to the file path
    <code>/home/rbowen/public_html/file.html</code></p>

    <p>If a path is given starting with a slash, a directory path will be
    constructed using that path, plus the username specified. Given this
    configuration:</p>

    <highlight language="config">UserDir /var/html</highlight>

    <p>the URL <code>http://example.com/~rbowen/file.html</code> will be
    translated to the file path <code>/var/html/rbowen/file.html</code></p>

    <p>If a path is provided which contains an asterisk (*), a path is used
    in which the asterisk is replaced with the username. Given this
    configuration:</p>

    <highlight language="config">UserDir /var/www/*/docs</highlight>

    <p>the URL <code>http://example.com/~rbowen/file.html</code> will be
    translated to the file path
    <code>/var/www/rbowen/docs/file.html</code></p>

    <p>Multiple directories or directory paths can also be set.</p>

    <highlight language="config">UserDir public_html /var/html</highlight>

    <p>For the URL <code>http://example.com/~rbowen/file.html</code>,
    Apache will search for <code>~rbowen</code>. If it isn't found,
    Apache will search for <code>rbowen</code> in <code>/var/html</code>. If
    found, the above URL will then be translated to the file path
    <code>/var/html/rbowen/file.html</code></p>

  </section>

  <section id="redirect">
    <title>Redirecting to external URLs</title>
    <p>The <directive module="mod_userdir">UserDir</directive> directive can be
      used to redirect user directory requests to external URLs.</p>

    <highlight language="config">UserDir http://example.org/users/*/</highlight>

    <p>The above example will redirect a request for
    <code>http://example.com/~bob/abc.html</code> to
    <code>http://example.org/users/bob/abc.html</code>.</p>
  </section>

  <section id="enable">
    <title>Restricting what users are permitted to use this
    feature</title>

    <p>Using the syntax shown in the UserDir documentation, you can restrict
    what users are permitted to use this functionality:</p>

    <highlight language="config">UserDir disabled root jro fish</highlight>

    <p>The configuration above will enable the feature for all users
    except for those listed in the <code>disabled</code> statement.
    You can, likewise, disable the feature for all but a few users by
    using a configuration like the following:</p>

    <highlight language="config">
      UserDir disabled<br />
      UserDir enabled rbowen krietz
    </highlight>

    <p>See <directive module="mod_userdir">UserDir</directive>
    documentation for additional examples.</p>

  </section>

  <section id="cgi">
  <title>Enabling a cgi directory for each user</title>

   <p>In order to give each user their own cgi-bin directory, you can use
    a <directive module="core" type="section">Directory</directive>
    directive to make a particular subdirectory of a user's home directory
    cgi-enabled.</p>

    <highlight language="config">
&lt;Directory /home/*/public_html/cgi-bin/&gt;
    Options ExecCGI
    SetHandler cgi-script
&lt;/Directory&gt;
    </highlight>

    <p>Then, presuming that <code>UserDir</code> is set to
    <code>public_html</code>, a cgi program <code>example.cgi</code>
    could be loaded from that directory as:</p>

    <example>
    http://example.com/~rbowen/cgi-bin/example.cgi
    </example>

    </section>

    <section id="htaccess">
    <title>Allowing users to alter configuration</title>

    <p>If you want to allows users to modify the server configuration in
    their web space, they will need to use <code>.htaccess</code> files to
    make these changes. Ensure that you have set <directive
    module="core">AllowOverride</directive> to a
    value sufficient for the directives that you want to permit the users
    to modify. See the <a href="htaccess.html">.htaccess tutorial</a> for
    additional details on how this works.</p>

  </section>

</manualpage>