Wednesday, January 13, 2010

Linux CLI - Webserver Apache - /etc/httpd/httpd.conf

In the terminal.

backup your config
sudo cp /etc/httpd/httpd.conf /etc/httpd/httpd.conf.bak

then edit the file
sudo vi /etc/httpd/httpd.conf

and find the line
DocumentRoot "/Library/WebServer/Documents"

Change to what you want the new httpd root to be.
In your case
DocumentRoot "/Users/newmedia/websites/"

then edit the line
Directory "/Library/WebServer/Documents"
to
Directory "/Users/newmedia/websites"

Also I change this line purely outta good practice

ServerSignature On
to
ServerSignature Off

After editing the httpd.conf you should verify it for any errors in the Terminal by typing:

sudo apachectl configtest

Enter your password and let it run. If it finds any errors it will say so. Otherwise it will say: Syntax OK

To restart apache (the web server) without going to System Preferences you can type in the Terminal:

sudo apachectl graceful

No comments:

Post a Comment