Change XAMPP's htdocs web root folder to another one

174,216

Solution 1

Open /opt/lampp/etc/httpd.conf change nobody and nogroup

<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User nobody
Group nogroup
</IfModule>

to your username and your group

Solution 2

Had the same issue and here is what i did:

Run this command to stop xampp:

sudo /opt/lampp/lampp stop

Open /opt/lampp/etc/httpd.conf

Change your_folder to the folder you wanna use

 DocumentRoot "/home/username/your_folder"
 <Directory "/home/username/your_folder">

Change User & Group value from daemon to:

User nobody
Group nogroup

set chmod to your_folder with this command

sudo chmod 777 /home/username/your_folder

Save the file and start xampp with this command:

sudo /opt/lampp/lampp start

Open your browser and enter this url:

http://localhost/your_folder/

Done, hope this helps.

Solution 3

The problem was on user group type in httpd.conf file which must be set to staff and then I don't need to change the folder permissions on the folder i'd like to use as web root.

Solution 4

You can create a symbolic link

ln -s /home/username/public_html/ /opt/lampp/yoursymlink 

with your username "~username" as symbolic link so you can keep the same URL location

localhost/~username for files like if your were using default Apache server and not XAMPP.

Solution 5

If you are doing this so that you can create files in htdocs folder then Just navigate to opt/lampp and then open in terminal and write

sudo chmod 777 htdocs/

Thats it!

Share:
174,216

Related videos on Youtube

vitto
Author by

vitto

I'm a UX/UI developer, located in Italy

Updated on September 18, 2022

Comments

  • vitto
    vitto over 1 year

    I'm trying to change the XAMPP's web root default directory /opt/lampp/htdocs to another one like /home/me/Dropbox/public_html without success.

    I've edited the file /opt/lampp/etc/httpd.conf

    # old line: DocumentRoot "/opt/lampp/htdocs"
    DocumentRoot "/home/me/Dropbox/public_html"
    
    #...etc...
    
    # old line: <Directory "/opt/lampp/htdocs">
    <Directory "/home/me/Dropbox/Work/public_html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    # etc...
    

    I've did this as said in this article: Using Ubuntu One to synchronise htdocs?

    Then I've restarted Apache and I've got a permission error 403 on every page I've called with the web browser.

    So I've changed folder and files permission to 755.

    I've did this as said in this article:
    What file permissions should I set on web root?

    The problem still remains the same, I have the 403 error on every page I try to reach with the web browser.

    I have the same problem on a Mac using XAMPP.

    So everythig works fine if the folder remains the original /opt/lampp/htdocs.

    How can I change it correctly?

  • Eliah Kagan
    Eliah Kagan over 11 years
    Can you edit this to provide some details explaining how to do that?
  • saji89
    saji89 over 11 years
    Where is NTFS format told in the question? Also the rest of the answer does not seem to answer the OP's question.
  • nmrony
    nmrony almost 9 years
    not understandable what he tried to explain just in one line
  • Jos
    Jos over 5 years
    More instructions would be very helpful.