45

I'm using xampp portable server and I'm having some trouble with Apache http server, it says "ServerRoot must be a valid directory"

Command line output:

Please close this command only for Shutdown
Apache 2 is starting ...
httpd.exe: Syntax error on line 35 of K:/../../../xampp/apache/conf/httpd.conf: ServerRoot must be a valid directory

Apache could not be started

I checked the line 35 of xampp/apache/conf/httpd.conf and it was:

ServerRoot "/xampp/apache"

Which doesn't exist. My folders are:

K:/../../../xampp/apache/conf     <- where the httpd.conf is
K:/../../../xampp/apache/         <- the server root
K:/../../../xampp/apache/modules  <- where server modules are

If i change (at line 35) to

ServerRoot ".."

It says:

Please close this command only for Shutdown
Apache 2 is starting ...
httpd.exe: Syntax error on line 65 of K:/../../../xampp/apache/conf/httpd.conf: Cannot load modules/mod_access_compat.so into server: Unable to find the specified module

Apache could not be started

I checked, and modules/mod_access_compat.so exists, so i can't figure out how to fix it.

Any help will be appreciated

Roman C
  • 49,761
  • 33
  • 66
  • 176
BackSlash
  • 21,927
  • 22
  • 96
  • 136

14 Answers14

92

Just run setup_xampp.bat from shell (shell from XAMPP control panel)and the paths should be set automatically for the portable version of XAMPP for windows. It has worked for me.

Bostjan
  • 936
  • 7
  • 6
29

navigate to httpd.conf file in conf direcotry in Apache24 or whatever apache file you have.

Go to ServerRoot= ".." line and change the value to the path where apache is located like "C:\Program Files\Apache24"

Guru
  • 2,739
  • 1
  • 25
  • 27
  • I thought you're not supposed to install XAMPP in program files due to permissions issues in Windows? – Eoin Jan 20 '17 at 12:09
  • Also if you're directory is something like a 'd:\Apache24', dont forget to make changes at all places in httpd.conf. There are many changes where it refers to c:\Apache24 by default. – Ashish Goyal May 09 '18 at 11:58
4

If you open an editor and jump to the exact line shown in the error message (within the file httpd.conf), this is what you'd see:

#LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule auth_form_module modules/mod_auth_form.so

The paths to the modules, e.g. modules/mod_actions.so, are all stated relatively, and they are relative to the value set by ServerRoot. ServerRoot is defined at the top of httpd.conf (ctrl-F for ServerRoot ").

ServerRoot is usually set absolutely, which would be K:/../../../xampp/apache/ in your post.

But it can also be set relatively, relative to the working directory (cf.). If the working directory is the Apache bin folder, then use this line in your httpd.conf:

ServerRoot ../

If the working directory is the Apache folder, then this would suffice:

ServerRoot .

If the working directory is the C: folder (one folder above the Apache folder), then use this:

ServerRoot Apache

For apache services, the working directory would be C:\Windows\System32, so use this:

ServerRoot ../../Apache
Pacerier
  • 86,231
  • 106
  • 366
  • 634
4

Change below path in httpd.conf file to your setup. This will fix the issue.

Define SRVROOT "C:\Apache24"   
ServerRoot "${SRVROOT}"
NightOwl888
  • 55,572
  • 24
  • 139
  • 212
Dhiraj Surve
  • 310
  • 2
  • 5
2

Make sure your ServerRoot in httpd.conf points correctly to the Apache path. Otherwise you will see this message for every further module.

Examples:

  • /etc/apache2/apache2 for Linux
  • "C:\Program Files\Apache24" for Windows
Greg Wozniak
  • 5,209
  • 3
  • 26
  • 29
1

I would think that ServerRoot needs to be absolute. Use something like "/apache/docroot"

souser
  • 5,868
  • 5
  • 35
  • 50
1

If you use an actuall version there is a "setup_xampp.bat/.sh" script in the root directory. The path has to be absolute but the script changes all needed paths to your current location.

0x126
  • 166
  • 2
  • 8
1

Use the drive letter with forward slashes to get started (c:/apache/...).

hcupro
  • 11
  • 1
1
  1. Navigate to your XAMPP directory, you will find a folder called apache, open it, then copy its path, my path is "D:\Hacking Tools 2\Programs\XAMPP V2\apache"
  2. Open up apache\conf\httpd.conf with any text editor
  3. Scroll down until line 30-40
  4. You will find a code like this: ServerRoot "xampp\apache"
  5. Now, change it to be the apache directory, as I said in Step #1, my path is "D:\Hacking Tools 2\Programs\XAMPP V2\apache", so, my code will be ServerRoot "D:\Hacking Tools 2\Programs\XAMPP V2\apache"
  6. It should look somehow like this: ServerRoot "D:\XAMPP\apache"
  7. Now go back to the XAMPP main directory and run xampp_start.exe

It worked for me, if it doesn't work for you, just comment with the error value after opening the xampp_start.exe

Ziad Amerr
  • 163
  • 1
  • 14
1

Run "setup_xampp.bat/.sh" and then Delete "\" at the end, so your ServerRoot should be like "C:.....\apache" NO "C:.....\apache\"

gusanare
  • 11
  • 1
1

Below solved. I have wrongly given the bin /directory/, so faced the issue:

if you installed apache at C:/httpd-2.4.41-o102s-x64-vc14-r2/Apache24
then the modules are at.. C:/httpd-2.4.41-o102s-x64-vc14-r2/Apache24/modules

So, the file           C:/httpd-2.4.41-o102s-x64-vc14-r2/Apache24/conf/httpd.conf
should have
       Define SRVROOT "C:/httpd-2.4.41-o102s-x64-vc14-r2/Apache24/"

Hope that helps

Manohar Reddy Poreddy
  • 25,399
  • 9
  • 157
  • 140
1

That for changing directory of the XAMPP. So you have to change the Directory as well as ServerRoot "E:/xampp/apache"

DocumentRoot "E:/xampp/htdocs"


<Directory "E:/xampp/htdocs">


ScriptAlias /cgi-bin/ "E:/xampp/cgi-bin/"


<Directory "E:/xampp/cgi-bin">
    AllowOverride All
    Options None
    Require all granted
</Directory>

I also facing same problem for changing My laptop. thanks

Amranur Rahman
  • 1,061
  • 17
  • 29
0

I checked the line 35 of xampp/apache/conf/httpd.conf and it was:

ServerRoot "/xampp/apache"

Which doesn't exist. ...

Create the directory, or change the path to the directory that contains your hypertext documents.

Lee Goddard
  • 10,680
  • 4
  • 46
  • 63
0

I had this exact same problem with Xampp portable on Windows 10 Home. I went through all the suggestions and none worked. I did get it working with Windows Firewall Settings and an error on my part.

My pen drive was labelled Drive E on my laptop and Drive F on my Desktop. Once I corrected that using disk partition and changed the drive letter to E for my desktop to windows asked for access for the firewall and everything clicked.

The steps to correct the drive letter were: 1. Hit the windows key and type Partition, "create and format harddisks partitions" should be at the top, hit enter 2. Find the drive you are looking for at the top panel and click on it. 3. Right click on it and select change drive letter and path, click okay 4. Now try to start xampp control panel and start Apache and Mysql 5. if you get the windows firewall click allow.

I can't say this will work but it did for me and is what I added to this discussion. I also think it might have been just the firewall did not allow the oither drive letter.

Kelly
  • 31
  • 1
  • 9