how to change xampp htdocs directory in OSX?

77,649

Solution 1

solved by editing httpd.conf

I have got this working. As per http://www.acwolf.com/blog/2009/February/xampp-virtual-hosts-mac, in OSX it is necessary to make two changes to httpd.conf, first, uncomment

#Include /Applications/xampp/etc/extra/httpd-vhosts.conf

and second, change the user from nobody to the username you use to log into OSX. You may also need to delete your browser's cache.

Solution 2

Open the following file in a text editor.

/Applications/XAMPP/xamppfiles/etc/httpd.conf

Search for "DocumentRoot", if the line below has a # in front of it than it's commented remove it and change the path between the quote

DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"

Now search for the line below and change the path between the quotes to your needs.

<Directory "/Applications/XAMPP/xamppfiles/htdocs">

NOTICE: Paths similar to ~/ won't work use the absolute path.

Solution 3

Other than the answers mentioned above, I also had to change the line in XAMPP/xampfiles/etc/httpd.conf where it mentions username. the default was set to daemon and I changed it to my username; so there was no permission problem.

Solution 4

If you forward to a directory in your user root, then:

DocumentRoot "/Users/<your username here>/Sites"
<Directory "/Users/<your username here>/Sites">
Share:
77,649

Related videos on Youtube

jela
Author by

jela

Updated on January 21, 2022

Comments

  • jela
    jela over 2 years

    I want to change XAMPP's htdocs directory. I followed the instructions to create a virtual host from this question:

    Make XAMPP/Apache serve file outside of htdocs

    this works fine on Windows 7, however when I try it on OSX, going to mysite.local just loads the xampp splash screen (mysite.local/xampp/index.html). I have restarted the web server. My virtual host declared in httpd-vhosts.conf is:

    <VirtualHost *:80>
    
    DocumentRoot Users/username/Documents/sitename.com
    
    ServerName sitename.localhost
    
    <Directory Users/username/Documents/sitename.com>
    
    Order allow,deny 
    Allow from all
    
    </Directory>
    
    • Arturo Molina
      Arturo Molina about 11 years
      The link provided does not seem to work anymore. I found an another article describing the process and also mentions that you need to edit your computer's hosts file: f6design.com/journal/2012/03/11/…
    • poitroae
      poitroae almost 11 years
      Where did you change the user? @jela
    • Gianluca Ghettini
      Gianluca Ghettini over 10 years
      where did you change the user?
    • Robin F.
      Robin F. about 7 years
      search for "User deamon" and change it to your username - most likely you can get your username it with the whoami command
  • Primoz Rome
    Primoz Rome about 11 years
    If you only change these two setting it won't work. I am trying to change document root my self, but without success for now. Followed above edit, but didn't work for me either.
  • risnandar
    risnandar over 10 years
    i can solve that problem with this answer. You also have to uncomment the first line to make it work. Mine is using XAMPP Osx 1.8.2-2
  • Mahmoud Fayez
    Mahmoud Fayez over 10 years
    You will lose the phpMyAdmin in that case !
  • Daniel Harris
    Daniel Harris over 10 years
    Make sure that your new root folder exists because if it doesn't, Apache won't start.
  • SumNeuron
    SumNeuron about 7 years
    Im using MacOS Sierra and this causes an Access Forbidden thing to show...
  • Robin F.
    Robin F. about 7 years
    @SumNeuron search for the "User deamon" within your httpd.conf and change it to your os user. you can get the os user with help of the whoami command. (I guess you figured that out by now but I hope it helps others)
  • Harish Kumar
    Harish Kumar almost 4 years
    use this to make it work. replace user name - stackoverflow.com/a/32963665/2444716