Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change web root apache mac OS X

Tags:

I cant change my web root in apache, for some reason it points to /Sites/folder1/folder2 instead of it pointing to /Sites. I configured and change my apache <Directory "/Users/saad/Sites"> and DocumentRoot /Users/saad/Sites restarted my apachectl and still nothing.

like image 217
saadlulu Avatar asked Jan 13 '12 13:01

saadlulu


People also ask

Where is my Apache root directory on Mac?

The document root for your apache server, by default, is "Sites" in your home directory. That's not the root folder. Root is http://localhost/ . The folder you're refering to is located at http://localhost/~User/ .

Is Apache installed on Mac by default?

Apache and php comes pre installed in mac OS Big Sur, You will just need to activate them using terminal. To start apache type the following command in the terminal and run. You need to write “sudo” before the actual command. We use sudo, which stands for “super-user do,” to run apps with higher rights.


2 Answers

I just meet this problem, too. I need to change the DocumentRoot and point it to my customised directory, which used for saving image files.

Berkay is right, you need edit a bit on your apache httpd.config file, but besides that, you need to do one more change, otherwise the WebSharing won't be able to turn on again.

  1. Open your httpd.config by your favorite editor (Probably need to do this if you haven't change the permission access to this file)

    • sudo chmod 666 httpd.conf
    • Open httpd.config, and start editing.
    • sudo chmod 644 httpd.conf, when it's finished, proceed to step 2 (change it back to original permisson access)
  2. Find DocumentRoot "/Library/WebServer/Documents", and change it to DocumentRoot "/Users/leiwang/Sites" or any other folders you want to.

  3. One important thing is, you need to give the Read/Write permission to the folder you specified.

    • sudo chmod -R 747 foldername

Hope it helps:)

like image 92
David_Wang Avatar answered Oct 05 '22 10:10

David_Wang


there is a documentroot property in the /etc/apache2/httpd.conf on osx. so we can easily change the path like this;

DocumentRoot "{YOUR_ROOT_PATH}"

like image 30
Berkay Avatar answered Oct 05 '22 09:10

Berkay