Change htdocs path in XAMPP

Here in this example, I am showing you to change the php project directories path from /opt/lampp/htdocs to /var/www

1) Open file /opt/lampp/etc/httpd.conf and change following line

DocumentRoot "/opt/lampp/htdocs"
to
DocumentRoot "/var/www"

2) Now search following line in same file (/opt/lampp/etc/httpd.conf)
and change

# This should be changed to whatever you set DocumentRoot to.
<Directory "/opt/lampp/htdocs">

to
# This should be changed to whatever you set DocumentRoot to. <Directory "/var/www">
(Above line is commented, it has been mentioned to find directive easily)

3) Restart the XAMPP.

4) If virtual hosts have been defined, change the path in /opt/lampp/etc/extra/httpd-vhosts.conf too.
Otherwise above steps will not work.

or if you want to remove virtual hosts, just comment following line in /opt/lampp/etc/httpd.conf
# Include etc/extra/httpd-vhosts.conf
5) Restart the XAMPP.

6) After following above process, if it throws php code in browser.
Uncomment following line in the file /opt/lampp/etc/httpd.conf
Include etc/extra/httpd-xampp.conf
This line should not be commented. It means there should be no Hash '#' symbol at start of the line.

7) If it gives Internal Server Error or Server Error.
Comment following line in the file /opt/lampp/etc/httpd.conf
# Include etc/extra/httpd-vhosts.conf
& Restart the XAMPP.

4 comments:

  1. thank you for this great guide but i want to ask you...i did it fine but i cant make the httdoc/index.php to work on my /var/www even if i copied it...its a php default of xampp that contains some options and settings concerning your apache and mysql in a webpage style!

    ReplyDelete
    Replies
    1. If it is still trying to open http://localhost/xampp, clear the cache of your browser. If you open http;//localhost, it shows error "Something is wrong with the XAMPP installation :-(", it is fine. Put your index.php in your new htdocs directory and now open http://localhost/index.php, it should work fine.

      Delete
  2. Hello! thank you for your answer and by the way gratz for the quality of your posts on the blog! you have some really helpful and cool tips :D
    well i cleared cache on my mozilla but i am getting the same error
    Object not found!

    The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

    If you think this is a server error, please contact the webmaster.
    Error 404

    My xampp point directory folder is now /var/www and i have one htdocs copy from the original folder from /opt/lampp that contains the index.php

    ReplyDelete
    Replies
    1. Take a look at the procedure, it is really simple.
      https://sites.google.com/site/linuxamination/linuxamination-12-04-13-a.mpeg
      Once you modify the file httpd.conf and restart the xampp, localhost starts reading files from new defined directory.

      Delete

Related Posts Plugin for WordPress, Blogger...