Where do I save my HTML and PHP files when I am using a local server on my Mac (OS X 10.6 Snow Leopard)
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/Web开发者_如何学PythonServer/Documents. Still other sources say that I should save my files into an Apache folder? What's the right answer?
Thanks!
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.
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.
For MacOS 10.10.5 (Yosemite)
You can save file at /Application/XAMPP/htdocs/
as webroot
精彩评论