Thursday, 6 March 2014

Link Apache Web Server Root Directory to Home Directory on Raspberry Pi

When Apache2 is installed on Raspberry Pi, the www directory (the root directory of the web server), is configured as /var/www

You need to use sudo to write to files in this directory. You can configure another directory to be the root directory of the web server by modifying the Apache configuration files but I used a quick and dirty way to link it to my home directory

first install apache2
sudo apt-get install apache2

stop apache
sudo /etc/init.d/apache2 stop

delete the apache www directory
sudo rm -rf /var/www

create the www directory in /home/pi
mkdir /home/pi/www

create the symbolic link to /home/pi
sudo ln -s /home/pi/www/ /var/www

Create an index.html file in /home/pi/www
vim /home/pi/www/index.html

<html>
</body>
test
</body>
</html>

Start Apache
sudo /etc/init.d/apache2 start

Check that the webserver works in the browser

No comments:

Post a Comment