Configuration
- Create a folder to hold your sites, or choose an existing folder
- Typical example would be: ~/Sites ( /Users/{username}/Sites/ )
- Open or create apache configuration file for given user
- vi /etc/apache2/users/{username}.conf
- Note: there are many options, will try to describe them later
<Directory "/Users/{username}/Sites">
addlanguage en .en
LanguagePriority en fr de
ForceLanguagePriority Fallback
Options Indexes MultiViews FollowSymLinks
Require all granted
AllowOverride All
Order allow,deny
Allow from all
</Directory>
- Modify you virtual hosts
- vi /etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot /Users/{username}/Sites/
ServerName localhost
ErrorLog "/private/var/log/apache2/localhost-error_log"
CustomLog "/private/var/log/apache2/localhost-access_log" common
</VirtualHost>
- Modify User Dir configuration
- vi /etc/apache2/extra/httpd-userdir.conf
- Make sure 'UserDir' is set to your dir, for example 'Sites"
- Uncomment: Include /private/etc/apache2/users/*.conf
UserDir Sites
#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
Include /private/etc/apache2/users/*.conf
<IfModule bonjour_module>
RegisterUserSite customized-users
</IfModule>
- Configure apache modules in /etc/apache2/httpd.conf
- Uncomment the modules
- Make sure to uncomment the 2 files we are including, user dir and virtual hosts
LoadModule deflate_module libexec/apache2/mod_deflate.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
Include /private/etc/apache2/extra/httpd-userdir.conf
Include/private/etc/apache2/extra/httpd-vhosts.conf
- Restart apache server - sudo apachectl restart
- Make sure apache is working - http://localhost/
- Test apache for local user - http://localhost/~{username}/
No comments:
Post a Comment