PDA

View Full Version : Apache on Mac OS X




jammer08
Jul 23, 2006, 09:06 PM
Hello, I am trying to host a website on a Macbook. I will be using the Macbook as a dedicated server for my company. I have started personal web sharing in system preferences, and have added the pages to the "Sites" folder... The issue is, when I try to access the website from a computer other than the host, it says I do not have permission to view the page -- how to I go about fixing this? Any help would be greatly appreciated.

Thanks-
Justin



panoz7
Jul 23, 2006, 09:20 PM
You need to have the files in the webserver folder. Its found in library/webserver/documents. I think the sites folder is just for iWeb stuff... i've never used it so I'm not positive though.

jammer08
Jul 23, 2006, 09:31 PM
You need to have the files in the webserver folder. Its found in library/webserver/documents. I think the sites folder is just for iWeb stuff... i've never used it so I'm not positive though.

I will try that - Thank you! :)

mkrishnan
Jul 23, 2006, 09:38 PM
If you put something in the sites folder in your home directory, it's supposed to show up in http: // your IP address or DN or local hostname / ~ your user name

It's not for iWeb -- it existed before iWeb did. But you have to have your firewall settings set up so that the requesting computer can see it. If I open my firewall on my iMac for instance, I can see the sites folder from my Axim or iBook, but I can't see it from the extranet, because there's another firewall on my router, right?

panoz7
Jul 23, 2006, 09:56 PM
If you put something in the sites folder in your home directory, it's supposed to show up in http: // your IP address or DN or local hostname / ~ your user name

It's not for iWeb -- it existed before iWeb did. But you have to have your firewall settings set up so that the requesting computer can see it. If I open my firewall on my iMac for instance, I can see the sites folder from my Axim or iBook, but I can't see it from the extranet, because there's another firewall on my router, right?

Ok... just figured the ~name thing out. What's the point though? Its slightly more convenient to stick stuff in the sites folder, but other then that I see no advantage and its a real pain to have to type in the ~USERNAME thing, especially if you have a strange username.

The firewall has never given me trouble on the internal network. I've never had to turn it off. Maybe the sites folder is different and is safe-gaurded more?

SC68Cal
Jul 23, 2006, 10:11 PM
Ok... just figured the ~name thing out. What's the point though? Its slightly more convenient to stick stuff in the sites folder, but other then that I see no advantage and its a real pain to have to type in the ~USERNAME thing, especially if you have a strange username.

The firewall has never given me trouble on the internal network. I've never had to turn it off. Maybe the sites folder is different and is safe-gaurded more?

you can configure Apache to change the default directory to your ~ Sites folder

mkrishnan
Jul 23, 2006, 10:14 PM
The firewall has never given me trouble on the internal network. I've never had to turn it off. Maybe the sites folder is different and is safe-gaurded more?

If you turn Apache on via OS X (i.e. in System Preferences) it automatically opens the associated port on the Firewall. If you have the OS X firewall up, Port 80 absolutely must be open for a webserver to work. No exceptions, really.... You either have to let OS X do it or do it yourself.

As far as the ~username... the idea is like any other managed Unix system -- different users can have different web pages. It isn't always called sites, but having a folder within the user folder is the standard way of doing things in Unix.... This way a user does not need to play with root level files. To which they ought not have write access to begin with. Which is the way it should be. ;)

If you have a domain name, you can always map it onto ~yourusername just as easily as the root.

But in the end, both folders belong to Apache, and there is only one Apache instance. There's nothing special about either folder... just make sure permissions and accessibility are all set up properly.

jammer08
Jul 24, 2006, 12:04 AM
now i am really confused -- i have my htm files in the webserver folder. i have the port (80) open, and when i go to my ip address i get the apache page... when i go to my ip/~user i get a message saying i dont have privelege to view this page... the firewall on the macbook is off and the port on my router's firewall is open :confused: :confused: :confused:

jammer08
Jul 24, 2006, 12:13 AM
BTW-- i have my domain pointed to my ip address. either way i access it (via domain or ip address) i get a permissions error.

colocolo
Jul 24, 2006, 12:16 AM
now i am really confused -- i have my htm files in the webserver folder. i have the port (80) open, and when i go to my ip address i get the apache page... when i go to my ip/~user i get a message saying i dont have privelege to view this page... the firewall on the macbook is off and the port on my router's firewall is open :confused: :confused: :confused:

Do not despair :)

There are two possible causes for this:

1.- Permissions have changed on sites folder.

To fix this, select the Sites folder, Get info (either from the File menu, cmd-I or right click-> get info) and then make sure that everyone has read access on the tab Ownership & Permissions. Make sure Others have Read Only access or you'll be in for some big security risk for your site!


2.- You do not have an index.html file and Apache is not configured to list folder contents.

Solution: Put up an index.html page inside your Sites folder, and see if you can access it. If you can, just make sure you rename your homepage! Way easier than fiddling with /etc/httpd/httpd.conf file if you are not used to it.


Good luck!

jammer08
Jul 24, 2006, 12:23 AM
Do not despair :)

There are two possible causes for this:

1.- Permissions have changed on sites folder.

To fix this, select the Sites folder, Get info (either from the File menu, cmd-I or right click-> get info) and then make sure that everyone has read access on the tab Ownership & Permissions. Make sure Others have Read Only access or you'll be in for some big security risk for your site!


2.- You do not have an index.html file and Apache is not configured to list folder contents.

Solution: Put up an index.html page inside your Sites folder, and see if you can access it. If you can, just make sure you rename your homepage! Way easier than fiddling with /etc/httpd/httpd.conf file if you are not used to it.


Good luck!


I have checked folder permissions, and yes, everyone has read rights. I actually had moved my pages to the WebServer folder. I do have an index.html file in the WebServer folder.. still saying no permissions.

colocolo
Jul 24, 2006, 12:29 AM
Justin,

either the folder /Library/WebServer/Documents doesn't have read permissions, OR (and i think this might be it) your index.html file doesn't have the right permissions set. check that index.html does have read access to everyone.

By the way, this is not a firewall issue. The message is the standard one from Apache.

jammer08
Jul 24, 2006, 12:33 AM
Justin,

either the folder /Library/WebServer/Documents doesn't have read permissions, OR (and i think this might be it) your index.html file doesn't have the right permissions set. check that index.html does have read access to everyone.

By the way, this is not a firewall issue. The message is the standard one from Apache.


You were correct!! -- the index file did not have read permissions for others. THANK YOU very much! :)

colocolo
Jul 24, 2006, 12:35 AM
You were correct!! -- the index file did not have read permissions for others. THANK YOU very much! :)

No problem ;)

By the way, you might want to check permissions on your images folder/files as they present the same issue :D

jammer08
Jul 24, 2006, 12:35 AM
should i leave all of the apache pages in the WebServer folder? also, what is the difference between the Sites folder, and the WebServer folder?

SC68Cal
Jul 24, 2006, 12:36 AM
Don't forget to turn your firewall back on.

jammer08
Jul 24, 2006, 12:36 AM
No problem ;)

By the way, you might want to check permissions on your images folder/files as they present the same issue :D

Thanks! :D

jammer08
Jul 24, 2006, 12:39 AM
Don't forget to turn your firewall back on.

I did, thank you. :)

SC68Cal
Jul 24, 2006, 12:40 AM
If you want the Apache webserver to serve up a different directory, use terminal

cd /etc/httpd
cp httpd.conf httpd.conf.bak (back up the original file)
nano httpd.conf

Inside that configuration file under section 2:

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
</change/this/to/whatever/you/want>

And a few lines below that:

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/change/this/to/what/you/changed/above">

jammer08
Jul 24, 2006, 12:42 AM
If you want the Apache webserver to serve up a different directory, use terminal

cd /etc/httpd
cp httpd.conf httpd.conf.bak (back up the original file)
nano httpd.conf

Inside that configuration file under section 2:

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
</change/this/to/whatever/you/want>

And a few lines below that:

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/change/this/to/what/you/changed/above">

Do you recommend doing that instead of deleting all of the apache pages in the default directory?

colocolo
Jul 24, 2006, 12:51 AM
Do you recommend doing that instead of deleting all of the apache pages in the default directory?

There is no benefit on doing that. If you really want to save all your info, just copy all the files and save it somewhere on your HD.
Unless you have a particular reason to do so, just keep the standard web folder schema.

The difference between the Webserver and the sites folder is, in short, that the webserver folder is your computer's web site. The sites folders are independet for each user of the machine (hence the ~username after the ip address).

If you want to maintain your site on your sites folder (so you dont need root permissions for every single update), just put this code on your index.html on your webserver folder:

<script>
location.href="~username";
</script>

There are tons of alternative ways of doing this (using headers, remapping at http.conf) but I feel this is the easiest way while you get your site admin experience.

jammer08
Jul 24, 2006, 12:57 AM
There is no benefit on doing that. If you really want to save all your info, just copy all the files and save it somewhere on your HD.
Unless you have a particular reason to do so, just keep the standard web folder schema.

The difference between the Webserver and the sites folder is, in short, that the webserver folder is your computer's web site. The sites folders are independet for each user of the machine (hence the ~username after the ip address).

If you want to maintain your site on your sites folder (so you dont need root permissions for every single update), just put this code on your index.html on your webserver folder:

<script>
location.href="~username";
</script>

There are tons of alternative ways of doing this (using headers, remapping at http.conf) but I feel this is the easiest way while you get your site admin experience.

This machine will be dedicated to hosting just this one website, so i just assume leave it in the WebServer folder -- shouldn't be too hard to keep track of.

Again, thank you for your help.

Wince99
Jul 24, 2006, 08:20 AM
This machine will be dedicated to hosting just this one website, so i just assume leave it in the WebServer folder -- shouldn't be too hard to keep track of.

Again, thank you for your help.

Why did you choose a laptop as a dedicated web server? Wouldn't it be less expensive to put a mac mini on the task?

:rolleyes:

caveman_uk
Jul 24, 2006, 09:33 AM
Why did you choose a laptop as a dedicated web server? Wouldn't it be less expensive to put a mac mini on the task?

I'm glad I wasn't the only thinking this....

SC68Cal
Jul 24, 2006, 10:52 AM
I'm glad I wasn't the only thinking this....

I wasn't going to say anything.

jammer08
Jul 24, 2006, 12:15 PM
okay, i have everything going great now... but now i have come accross an issue... i need serval forms on my site and i have them set up -- all ready to go, but when you try to submit the form online you get an error... do i need some sort of mail server or something?? all help is sincerely appreciated.

jammer08
Jul 25, 2006, 07:10 PM
okay, i have everything going great now... but now i have come accross an issue... i need serval forms on my site and i have them set up -- all ready to go, but when you try to submit the form online you get an error... do i need some sort of mail server or something?? all help is sincerely appreciated.

exabytes18
Jul 25, 2006, 10:54 PM
A Windows :eek: or Linux box might have been better.
1. They are cheaper.
2. Windows and Linux can run Apache and MySQL significantly faster than a Mac.

jammer08
Jul 25, 2006, 10:56 PM
A Windows :eek: or Linux box might have been better.
1. They are cheaper.
2. Windows and Linux can run Apache and MySQL significantly faster than a Mac.

Really?? Is there a substancial difference in speed? -- Also, what is MySQL?

exabytes18
Jul 25, 2006, 11:25 PM
Really?? Is there a substancial difference in speed? -- Also, what is MySQL?

I'm looking for some current benchmarks..... I'll report back soon.

MySQL is an open source database that is widely used for websites. It is easy to use and highly scalable.

jammer08
Jul 25, 2006, 11:32 PM
I'm looking for some current benchmarks..... I'll report back soon.

MySQL is an open source database that is widely used for websites. It is easy to use and highly scalable.

Thanks!

exabytes18
Jul 25, 2006, 11:52 PM
Ok. According to anandtech.com (http://www.anandtech.com/mac/showdoc.aspx?i=2520&p=5),
on actual servers (i.e. xServes and comparable Linux boxes) the Linux box will serve 10 times more requests than the Mac. I don't know how well Apple optimized Apache for Intel yet and such, but it looks like performance should be alright for a small site with few page views per second.

jammer08
Jul 26, 2006, 12:12 AM
Ok. According to anandtech.com (http://www.anandtech.com/mac/showdoc.aspx?i=2520&p=5),
on actual servers (i.e. xServes and comparable Linux boxes) the Linux box will serve 10 times more requests than the Mac. I don't know how well Apple optimized Apache for Intel yet and such, but it looks like performance should be alright for a small site with few page views per second.

Wow.. That is quite a difference!.. but it should be fine for what I am using it for.. do you know how to get forms to submit on a site?

exabytes18
Jul 26, 2006, 12:23 AM
Wow.. That is quite a difference!.. but it should be fine for what I am using it for.. do you know how to get forms to submit on a site?

Yeah. What do you want to do with the information in the forms?

jammer08
Jul 26, 2006, 12:31 AM
Yeah. What do you want to do with the information in the forms?

submit contact information.

exabytes18
Jul 26, 2006, 12:34 AM
submit contact information.

But like... store the information in a database... or calculate everything on the webpage itself.... or something else.

jammer08
Jul 26, 2006, 12:48 AM
But like... store the information in a database... or calculate everything on the webpage itself.... or something else.

I want the info taken from the form to be sent to me via email.

exabytes18
Jul 26, 2006, 01:05 AM
I want the info taken from the form to be sent to me via email.

The easy way is to just use <form action="mailto:email@address.com" ....>.

This leaves your email address exposed, requires the client to have their mail app setup properly, and lacks any nice formatting.

The proper way to do it is to have some scripting language (PHP, ASP, etc) get the information from the forms, verify it isn't a bunch of BS and then send you an email. Pretty easy.

jammer08
Jul 26, 2006, 02:46 PM
The easy way is to just use <form action="mailto:email@address.com" ....>.

This leaves your email address exposed, requires the client to have their mail app setup properly, and lacks any nice formatting.

The proper way to do it is to have some scripting language (PHP, ASP, etc) get the information from the forms, verify it isn't a bunch of BS and then send you an email. Pretty easy.


Yeah that (bold) is what I am trying to do. I do not want it to go through the viewer's email client, I want the sever to send it. I have the form set up, I do not need it to verify anything, but how do I script it to send the info out via email? :confused:

jeremy.king
Jul 26, 2006, 04:04 PM
[/B]

Yeah that (bold) is what I am trying to do. I do not want it to go through the viewer's email client, I want the sever to send it. I have the form set up, I do not need it to verify anything, but how do I script it to send the info out via email? :confused:

Two suggestions since its your company.

1) get a hosting account
2) Hire someone who knows what they are doing. Nobody here is going to walk you through programming in PHP/JSP/Ruby/etc...

This will save you headaches and time.

exabytes18
Jul 26, 2006, 06:26 PM
Two suggestions since its your company.

1) get a hosting account
2) Hire someone who knows what they are doing. Nobody here is going to walk you through programming in PHP/JSP/Ruby/etc...

This will save you headaches and time.

Agreed. This is what should have been done in the first place.

jammer08
Jul 26, 2006, 11:32 PM
Agreed. This is what should have been done in the first place.

What's a good hosting company?

exabytes18
Jul 27, 2006, 01:30 AM
What's a good hosting company?

Search macrumors for reviews of web hosts, Google around, research, select one that appeals to your needs, and don't get scammed. ;) I started out with the basic package from bravenet.com (nothing wrong with them), and then figured it was cheaper for me to host it on my desktop computer. That's about all the advice I can offer up.

Let us know what you find.

jammer08
Jul 28, 2006, 01:45 AM
Search macrumors for reviews of web hosts, Google around, research, select one that appeals to your needs, and don't get scammed. ;) I started out with the basic package from bravenet.com (nothing wrong with them), and then figured it was cheaper for me to host it on my desktop computer. That's about all the advice I can offer up.

Let us know what you find.

Anyone have an experience with BlueHost?