8

I am learning PHP and MySQL and just set up a local server on my Mac Snow Leopard. The different components work (PHP work, MySQL works from the terminal, and Apache is set up.

Where should I save my HTML and PHP files? Some sources say /users/[my username]/sites/. Other sources say /MacHD/Library/WebServer/Documents. Still other sources say that I should save my files into an Apache folder? What's the right answer?

Thanks!

Andy
  • 83
  • 1
  • 1
  • 3

3 Answers3

4

The main http://localhost/ webroot is at /MacHD/Library/WebServer/Documents

Your Sites folders will be accessible at http://localhost/~username/

If you install a new Apache or other webserver (e.g. via MacPorts, Fink, or some other method.) you'll need to refer to the documentation to discover the webroot, httpdocs & htdocs are common defaults.

Avoid using something like MAMP, if you actually prefer to know exactly what is on your system, if you don't care about the nuts and bolts, an all-in-one like that could be useful, YMMV.

ocodo
  • 29,401
  • 18
  • 105
  • 117
  • Yep, XAMPP is good for a quick all in one solution. I think it definitely pays off to build your own server suite, when you get comfortable enough to do so, more lightweight HTTPD's are available instead of Apache, and in general it's great educational experience to make a server/db/scripting language setup work from scratch. – ocodo Jan 31 '11 at 02:39
1

While this isn't exactly the answer you are looking for, I have been using MAMP PRO for a while now and it has greatly simplified my local development experience.

While you might not want to pay for the pro version out of the gate, the regular will definitely get you started and give you most of the basic tools you will need to get server-side development rolling on your mac. Including phpmyadmin, mysql, php, apache and allow you to point the webroot of mamp at any directory you choose, so you can utilize a project directory inside your home directory.

But again, Slomojo 's is definitely a more 'correct' answer.

Community
  • 1
  • 1
jondavidjohn
  • 61,812
  • 21
  • 118
  • 158
  • Yep I agree with Slomojo that getting this to work from scratch is a great educational experience (esp because I'm just a business guy at a start-up and want to know how to talk to the engineers :). That said, I may eventually go with MAMP. Do I need uninstall anything before I install MAMP? Will it conflict with what I currently have? I followed the instructions here to get MySQL and Apache set up: http://stackoverflow.com/questions/1293484/easiest-way-to-activate-php-and-mysql-on-mac-os-10-6-snow-leopard/1301328#1301328 – Andy Jan 31 '11 at 03:03
0

For MacOS 10.10.5 (Yosemite)

You can save file at /Application/XAMPP/htdocs/ as webroot

Pankaj
  • 7,908
  • 6
  • 42
  • 65