Skip to content

Commit b847682

Browse files
authored
Merge pull request #4690 from evansharp/develop
Add information for apache mod_userdir
2 parents a5d604d + 5fa4159 commit b847682

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

user_guide_src/source/installation/running.rst

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,72 @@ e.g., ``apache2/conf/extra/httpd-vhost.conf``::
129129
If your project folder is not a subfolder of the Apache document root, then your
130130
<VirtualHost> element may need a nested <Directory> element to grant the web server access to the files.
131131

132+
With mod_userdir (shared hosts)
133+
--------------------------------
134+
135+
A common practice in shared hosting environments is to use the Apache module "mod_userdir" to enable per-user Virtual Hosts automatically. Additional configuration is required to allow CodeIgniter4 to be run from these per-user directories.
136+
137+
The following assumes that the server is already configured for mod_userdir. A guide to enabling this module is available `in the Apache documentation <https://httpd.apache.org/docs/2.4/howto/public_html.html>`_.
138+
139+
Because CodeIgniter4 expects the server to find the framework front controller at ``/public/index.php`` by default, you must specify this location as an alternative to search for the request (even if CodeIgniter4 is installed within the per-user web directory).
140+
141+
The default user web directory ``~/public_html`` is specified by the ``UserDir`` directive, typically in ``/apache2/mods-available/userdir.conf`` or ``/apache2/conf/extra/httpd-userdir.conf``::
142+
143+
UserDir public_html
144+
145+
So you will need to configure Apache to look for CodeIgniter's public directory first before trying to serve the default::
146+
147+
UserDir "public_html/public" "public_html"
148+
149+
Be sure to specify options and permissions for the CodeIgniter public directory as well. A ``userdir.conf`` might look like::
150+
151+
<IfModule mod_userdir.c>
152+
UserDir "public_html/public" "public_html"
153+
UserDir disabled root
154+
155+
<Directory /home/*/public_html>
156+
AllowOverride All
157+
Options MultiViews Indexes FollowSymLinks
158+
<Limit GET POST OPTIONS>
159+
# Apache <= 2.2:
160+
# Order allow,deny
161+
# Allow from all
162+
163+
# Apache >= 2.4:
164+
Require all granted
165+
</Limit>
166+
<LimitExcept GET POST OPTIONS>
167+
# Apache <= 2.2:
168+
# Order deny,allow
169+
# Deny from all
170+
171+
# Apache >= 2.4:
172+
Require all denied
173+
</LimitExcept>
174+
</Directory>
175+
176+
<Directory /home/*/public_html/public>
177+
AllowOverride All
178+
Options MultiViews Indexes FollowSymLinks
179+
<Limit GET POST OPTIONS>
180+
# Apache <= 2.2:
181+
# Order allow,deny
182+
# Allow from all
183+
184+
# Apache >= 2.4:
185+
Require all granted
186+
</Limit>
187+
<LimitExcept GET POST OPTIONS>
188+
# Apache <= 2.2:
189+
# Order deny,allow
190+
# Deny from all
191+
192+
# Apache >= 2.4:
193+
Require all denied
194+
</LimitExcept>
195+
</Directory>
196+
</IfModule>
197+
132198
Testing
133199
-------
134200

0 commit comments

Comments
 (0)