22

How can i change the root directory of the currently installed wampserver to some other directory.

  • I reread this question because of the answers you are getting differ so much and I am a bit confused. Are you trying to use another version of WAMP (software install) in another directory or change the directory where the website is? – closetnoc Jan 24 '18 at 16:57
  • The fact you accepted an answer answers my question. Cheers!! – closetnoc Jan 25 '18 at 16:56
7

Edit the httpd.conf file and/or the vhosts.conf file for the site wish to change. The Directory directive will let you specify where the files for this site are to be located.

For more info on httpd.conf see: http://httpd.apache.org/docs/2.2/configuring.html

And specifically: http://httpd.apache.org/docs/2.2/mod/core.html#directory

| improve this answer | |
  • I had a few syntax errors in my vhosts.conf (using \ instead of / in DocumentRoot paths) and the apache service wouldn't start. Basically WAMP doesn't tell you if you edited something wrong (syntax errors don't show up in log files), so I used httpd.exe -n wampapache64 -t to check and correct these errors (more details about this and port changing in here). – Armfoot Jun 5 '17 at 10:24
13

For wamp 2.5 on Windows, use a text editor, e.g. notepad++ to edit c:\wamp\bin\apache\apache2.4.9\conf\httpd.conf

  1. Change DocumentRoot "c:/wamp/www" to DocumentRoot "c:/my/new/path" (Note slash direction). This will change the location where files are served from (~Line 230).
  2. Change <Directory "c:/wamp/www"> to <Directory "c:/my/new/path"> (Note slash direction). This applies permissions from the old directory to the new one (~Line 252).
  3. Copy all content from c:\wamp\www to your new directory (c:\my\new\path), including index.php
  4. Edit c:\my\new\path\index.php and change line 40 $server_dir = "../"; to $server_dir = "C:/wamp/"; This changes the location where config files etc. for wamp are read from. Change $suppress_localhost = false; to correct projects links (~Line 30).
| improve this answer | |
  • 1
    Thanks for this, I simply did steps 1 and 2 which was enough to get the localhost working. – Sverrir Sigmundarson Aug 25 '15 at 21:22
  • 1
    No problem @SverrirSigmundarson, the last two steps steps are so you can have the familiar wamp launch page with links to phpmyadmin and your project folders etc. – danialk Aug 26 '15 at 22:02
  • 1
    Better done by creating Virtual Hosts – RiggsFolly Jun 15 '17 at 13:37
5
  1. Click on Green Wamp Icon (Taskbar right Notification Icons) > Apache > httpd.conf > Replace all ${INSTALL_DIR}/www with your directory. Take care to use / instead of \
  2. Click on Green Wamp Icon > Apache > httpd-vhosts.conf > Replace again the existing "www"-Directory with yours
  3. Click on Green Wamp Icon > "Restart All Services"

(Tested on Windows 10, Wampserver 3.0.6 64 Bit)

| improve this answer | |
  • Better and correct answer than above one – T.Todua Oct 7 '19 at 7:47
3

I found these simple steps helping,

  1. Click on WampServer icon in taskbar

  2. Select Apache > httpd.conf from the pullup

  3. Search for the term “DocumentRoot”

  4. Change the DocumentRoot path to your custom directory

  5. Search for your DocumentRoot path

  6. again same procedure

  7. Save your changes and “Restart All Services”

| improve this answer | |
  • I have tried that but I get the Permission denied when I try to surf to localhost – user44905 Sep 20 '14 at 9:35
  • @Max did you check whether there is any htaccess file in your new directory or project – Prasanth K C Sep 21 '14 at 8:46
2

After doing the above, you can also change the: in the of wamp directory (wampmanager.ini, wampmanager.conf).

php.ini my.ini

Save your changes and close Wampserver.

| improve this answer | |
  • 2
    I tried doing this, but found that it got overwritten upon wamp restart. You can fix it for good by editing the $wwwDir variable in wamp/scripts/config.inc.php – Kevin Somers-Higgins Feb 6 '14 at 20:08
1

I tried doing this, but found that it got overwritten upon wamp restart. You can fix it for good by editing the $wwwDir variable in wamp/scripts/config.inc.php

| improve this answer | |
0

And there is some more to do (WAMP version 3.0.6, 64bit) to avoid some other error-messages do following changes to the wamp/scripts/config.inc.php:

Change all relative-paths to absolute-paths, like "../"-entries to eg. "c:/wamp64/"

from

$configurationFile = '../wampmanager.conf'

to

$configurationFile = 'c:/wamp64/wampmanager.conf';

If 'c:/wamp64/' is your install-dir. Helped me a lot. Somewhere devs did a mess there ..

| improve this answer | |
0

If the only thing that joesk needs is to have its www directory on another disk, you just have to create a virtual host using http://localhost/add_vhost.php?lang=english

| improve this answer | |
  • The OP is asking how to modify the configuration to point to another location. The OP has not asked about creating a new site or anything about another disk. The answer is to edit the configuration files and how. Your answer does not answer the question. – closetnoc Jan 23 '18 at 20:00
  • I agree with closetnoc. This answer doesn't appear to address how to change the setting for the www directory. – Stephen Ostermiller Jan 23 '18 at 20:52
0

You might better to create "Symlink" of the www folder from any place, without any need to change WAMP config.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.