24

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?

SharpC
  • 115
vitto
  • 443
  • I can't find the opt folder, is it inside of another folder or something? I've already searched almost the whole xampp installation folder and can't find it, please help :( –  May 07 '13 at 17:51
  • I've did it on a Ubuntu distribution, maybe are you using another distro? Starting from the root folder / I'll find the opt folder. – vitto May 08 '13 at 06:59

9 Answers9

18

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

hellocatfood
  • 3,379
5

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.

Exil
  • 545
1

Had the same problem under linux 18.3. None of the above worked exactly as described, but the following combination did:

In the file /opt/lampp/etc/httpd.conf I made the following changes:

Replace:

    <IfModule unixd_module>
    User daemon 
    Group daemon
    </IfModule>

by:

    <IfModule unixd_module>
    User myusername 
    Group myusername
    </IfModule>

and further down replace:

    DocumentRoot "/opt/lampp/htdocs"
    <Directory "/opt/lampp/htdocs">

by

    DocumentRoot "/home/myusername/webdir" 
    <Directory "/home/myusername/webdir"

Thereby, "myusername" is my linux username, and "webdir" is the directory name in my home directory where the php-files are stored.

In the terminal, stop lampp before saving the file, start again. In the browser localhost will then point to "webdir".

Michal
  • 11
1

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.

baptx
  • 477
1

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.

vitto
  • 443
1

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!

user260214
  • 103
  • 8
0

Just solved it following the steps bellow:

  1. First install xampp by following steps

    $ sudo cd Downloads && sudo chmod a+x ./your-downloaded-xampp-file.run && sudo ./your-downloaded-xampp-file.run
    
  2. Change file owner of /opt/lampp directory. username should be the username of your new documentroot folder ownername

    sudo chown -hR  username:root /opt/lampp
    
  3. edit /opt/lampp/etc/httpd.conf

    sudo gedit /opt/lampp/etc/httpd.conf
    
  4. edit your document root path to mounted windows documentroot and the following lines

    <IfModule unixd_module>
       User nobody
       Group nogroup
    </IfModule>
    
  5. restart xampp. And you will find forbidden error has gone

Braiam
  • 67,791
  • 32
  • 179
  • 269
Nur Rony
  • 262
  • 3
  • 14
-1

In NTFS format you can't set folder permissions. Open /opt/lampp/etc/httpd.conf.

Edit
User computerName
Group computerName

And after that you can access the symbolic links in htdocs.

jokerdino
  • 41,320
  • 1
    Where is NTFS format told in the question? Also the rest of the answer does not seem to answer the OP's question. – saji89 Oct 22 '12 at 09:02
-2

Just make an index file on your new htdocs folder.

Eliah Kagan
  • 117,780