Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

So I've enabled PHP on my Mac OS X 10.5 (Leopard), and it's working great so long as:

1) I place the file in the ~/Sites directory
2) I use the http://localhost/~user/example.php URL instead of the file:///Users/user/Sites/example.php

I presume this is because unless both of those conditions are true, Apache is not involved, and thus neither is PHP. So is there any way to remove either of those conditions? (Well, really the latter, because the first is a symptom of the second)

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Apache only serves pages from within it's DocumentRoot and all files will be relative to that. If you desire, though I strongly advise against it, you could change DocumentRoot to / and thus serve all files, but you would have to give Apache read access.

As for the file: protocol, that tells your browser, etc. how to access the file in question. file: tells it to look for it as a file in the file system. http: tells it to request it with the HTTP protocol (the one that Apache serves by default on port 80). There are others you could use also, but this tells the client how it should request the file. In a browser, the default is usually HTTP on port 80. To change that would depend on the client that you use to access the file.

If what you want is to run a PHP file without a web server, that is possible. There should be a command line version which you can pass the file as a parameter: php /Users/user/Sites/example.php

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.