Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Can't get web server to work!

Can't get web server to work!
Thread Tools
ibook_steve
Moderator
Join Date: Oct 2001
Location: San Jose, CA
Status: Offline
Reply With Quote
Jan 31, 2013, 08:18 PM
 
It's annoying enough that Apple removed the web sharing GUI setting. But I can't get my local web server working at all, even after following a number of tutorials such as this one:

https://discussions.apple.com/docs/DOC-3083

I can't even see the "It works!" page in /Library/WebServer/Documents.

I've tried messing with permissions but it just doesn't work, and I want to test pages I'm creating. Any ideas or things I should try or check?

Thanks,
Steve
Celebrating 10 years and 4000 posts on MacNN!
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Feb 1, 2013, 04:01 AM
 
1) Are you seeing any error messages when you sudo apachectl restart ?
2) Are you seeing any error messages being logged to your log files?
     
ibook_steve  (op)
Moderator
Join Date: Oct 2001
Location: San Jose, CA
Status: Offline
Reply With Quote
Feb 1, 2013, 06:10 PM
 
No errors when I restart the server, but my logs show for servers called "dummy-host.example.com". Now I noticed that listed in the Web sharing preference pane you can install following those tutorials (Web Sharing in OS X Mountain Lion) as "Local web sites" but I couldn't change it.

In the error_log, I get errors that "/usr/docs/dummy-host.example.com does not exist".

Could this be part of my problem?

I also get errors: client denied by server configuration: /usr/docs

But there is no /usr/docs directory.

Steve
Celebrating 10 years and 4000 posts on MacNN!
     
Waragainstsleep
Posting Junkie
Join Date: Mar 2004
Location: UK
Status: Offline
Reply With Quote
Feb 2, 2013, 03:43 PM
 
What does the apache config file say is the root folder for site documents?
I have plenty of more important things to do, if only I could bring myself to do them....
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Feb 2, 2013, 04:33 PM
 
If you are wanting to serve files out of the Sites folder in your home directory you'll need to enable the userdir module, and make sure your URL parts start with "~username/" Otherwise, you'll need to make sure that the document root specified by Apache exists (which seems like it is /usr/docs/dummy-host.example.com), and that your web files you wish to access reside there. If you are wanting to access multiple sites you will need to setup virtualhosts.

Also make sure that if you are using the domain "dummy-host.example.com" that this domain resolves to your local IP. One easy way to do that is to setup an entry in /etc/hosts to point to 127.0.0.1.
     
ibook_steve  (op)
Moderator
Join Date: Oct 2001
Location: San Jose, CA
Status: Offline
Reply With Quote
Feb 4, 2013, 02:27 PM
 
Originally Posted by Waragainstsleep View Post
What does the apache config file say is the root folder for site documents?
It's set to:

DocumentRoot "/Library/WebServer/Documents"

though I tried changing it to my Sites folder and that didn't work either.

Steve
Celebrating 10 years and 4000 posts on MacNN!
     
ibook_steve  (op)
Moderator
Join Date: Oct 2001
Location: San Jose, CA
Status: Offline
Reply With Quote
Feb 4, 2013, 02:32 PM
 
Here's my hosts file. Maybe I screwed this up somehow. Why is this so complicated?:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost

# VIRTUAL HOST START
127.0.0.1 localhost
127.0.0.1 mysite.local
# VIRTUAL HOST STOP
Celebrating 10 years and 4000 posts on MacNN!
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Feb 4, 2013, 04:48 PM
 
Originally Posted by ibook_steve View Post
It's set to:

DocumentRoot "/Library/WebServer/Documents"

though I tried changing it to my Sites folder and that didn't work either.

Steve

Can you be more specific about what isn't working? Is the Apache process running? What URL are you using to access your site? What are you seeing in your logs when you try to access your site? When you restart your web server what are you seeing in your logs?

Have you thought about installing your own Apache version via Homebrew or Macports?
     
ibook_steve  (op)
Moderator
Join Date: Oct 2001
Location: San Jose, CA
Status: Offline
Reply With Quote
Feb 4, 2013, 05:58 PM
 
OK, I finally got it working!

I gave up on my httpd.conf file. I replaced it with the one in the "original" directory. That got my localhost "It works!" site working from /Library/Webserver/Documents. I have no idea what was wrong with my httpd.conf file, unless it had something to do with the upgrade from Lion to Mountain Lion last year (which from some Googling could be the case).

Then, the only problem I had was a permissions problem according to the error log, but I didn't know where since I had set my Sites directory to 777. But I learned from here ((13)Permission denied | Dreaming Of Beetles) that you have to have 755 permissions all the way down, not just on my Sites folder. Well going up the directory chain, my user folder (/Users/<my short name>) had permissions set to 750 for some reason. When I changed this to 755, boom!

I kept commented out the use of virtual hosts in httpd.conf since I don't need to run multiple sites, just the one that I'm testing.

But it's finally working!! Yay! Hope this helps others.

Steve
Celebrating 10 years and 4000 posts on MacNN!
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 03:32 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,