Change XAMPP's htdocs web root folder to another one
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!
Related videos on Youtube
Comments
-
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 error403
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
usingXAMPP
.So everythig works fine if the folder remains the original
/opt/lampp/htdocs
.How can I change it correctly?
-
Eliah Kagan over 11 yearsCan you edit this to provide some details explaining how to do that?
-
saji89 over 11 yearsWhere is
NTFS format
told in the question? Also the rest of the answer does not seem to answer the OP's question. -
nmrony almost 9 yearsnot understandable what he tried to explain just in one line
-
Jos over 5 yearsMore instructions would be very helpful.