Saturday, April 13, 2013

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.

2 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