Apache by default serves files from the Document root i.e.
/Library/WebServer/Documents/
But what if you want your custom folder to serve webfiles. This tutorial walks you through the complete process.
Create a new folder at the root level of your account and name it 'www' for example. Now this folder we want to use as the web-serving directory for our account.
Launch Terminal found at Applications/Utilities/ and execute the following commands
cd /etc/apache2/users
To change to the user directory
To find your username execute the following in the terminal
whoami
For using nano to create a new file by the name of 'username.conf' where username is what is shown by the above command
sudo nano username.conf
Now add the below mentioned code to the newly created 'username.conf' file
<Directory "/Users/username/www/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Change permissions of the file by
sudo chmod 644 username.conf
To reflect the changes restart apache by
sudo apachectl restart
Now to view files from the custom webroot either go to
http://localhost/~username/
or
http://127.0.0.1/~username/
depending on your configuration.
0 Comment(s)