change web root apache mac OS X

后端 未结 7 1965
执念已碎
执念已碎 2020-12-30 01:34

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

相关标签:
7条回答
  • 2020-12-30 01:43

    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}"

    0 讨论(0)
  • 2020-12-30 01:48

    I came across the similar question as you, the httpd.conf under /private/etc/apache2/ defines the DocumentRoot as /Library/Webserver/Documents. But that directory doesn't work!

    Instead,the DocumentRoot which actually works is /usr/htdocs! Weird!

    0 讨论(0)
  • 2020-12-30 01:50

    Apache has several files with the same name httpd.conf

    The "oficial" path is in /usr/local/etc/httpd/httpd.conf

    0 讨论(0)
  • 2020-12-30 01:51

    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:)

    0 讨论(0)
  • 2020-12-30 01:54

    I ran into this problem: Once you change the root of web server to somewhere other than the default (/Library/WebServer/Documents), you need setup virtual host, otherwise, localhost will not work, and you will get:
    403 Forbidden error
    You can refer to this link for details on how to set it up:
    http://coolestguidesontheplanet.com/set-virtual-hosts-apache-mac-osx-10-10-yosemite/

    Also make sure the following line is in the configuration file for the web directory if your Max is running OS X 10.10:
    Require all granted

    For your reference, I just remind you if this ever happens to you.

    0 讨论(0)
  • 2020-12-30 02:02

    I went to /etc/apache/users/saad.conf and added the virtual host in this form "www.x.dev" to the top of my virtual hosts list. this temporarily fixed the problem. hope this helps

    0 讨论(0)
提交回复
热议问题