Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

flan0000

macrumors newbie
Original poster
Oct 26, 2003
6
0
cardfiff, wales
hi,

quick question:

I want to change the the default webserver address /Library/Webserver/Documents to /Users/newmedia/websites/

I know that i need to edit the /etc/httpd/httpd.conf file in the terminal, but have no idea other than opening it up....:confused:

any ideas? - the reason i'm doing this is for better access across the network for updating/adding new projects for viewing on our intranet.

cheers

steve
 

edesignuk

Moderator emeritus
Mar 25, 2002
19,232
2
London, England
Do you have BBEdit? It's dead easy to open up hidden system files owned by root if you do, otherwise I have no idea.

In BBEdit, you just go File > Open Hidden (or something like that ;))
 

bbarnhart

macrumors 6502a
Jan 16, 2002
824
1
From the Finder, you can press shift-apple-G and then enter /etc and it will bring up that hidden directory. Then you can drag that httpd.conf to BBEdit or something else.

FYI: /etc is actually a symbolic link to /private/etc.
 

RoadKill

macrumors regular
Dec 4, 2003
101
1
LONDON UK
It's really easy.

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"

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

restart httpd and away you go

good luck
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
More

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
 

stcanard

macrumors 65816
Oct 19, 2003
1,485
0
Vancouver
Okay, I'd make one extra suggestion:

Use a named host in a seperate config file. Thay way you don't get burned next time apache is upgraded.

First off make sure that the last line in /etc/httpd/httpd.conf is:

Include /private/etc/httpd/users/*.conf

It should be there by default. Then create a file in /private/etc/httpd/users called "customconfig.conf" (really whatever you want to call it). Add the following to that file:

<NameVirtualHost>
ServerName myservername <- choose a severname you want here
DocumentRoot "/Users/newmedia/websites"
<NameVirtualHost>

Now, you're almost done. If you only want these sites accessible from your computer, add the following to /etc/hosts:

127.0.0.1 myservername

If other people need to access it, you need myservername added to the DNS for the area.

Now, from a webbrowser if you go to http://myservname apache will automatically use /Users/newmedia/websites. You can also put any server customizations in there, and test them out without affecting your main server, and if the main httpd.conf gets blown away your customization is unaffected.

It's a technique I use all the time when working on multiple sites.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.