Serverroot must be a valid directory apache ошибка

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

The most common problem DevOps developers and system administrators encounter when they install Apache on Windows is the ServerRoot Must be a Valid Directory error. Fortunately, this exception is easily fixed.

When you install Apache’s HTTP Server with a distribution such as XAMPP, Bitnami’s LAMP or even the basic ZIP file download from the Apache Lounge, the expectation is that the software will be installed into the computer’s root directory.

Yes, as surprising as that sounds, a standard build of the Apache Web Server on Windows expects the binaries to be installed directly to the root of C:\ .  Install the software anywhere else, and when you run the httpd.exe file the ServerRoot Must be a Valid Directory error appears.

ServerRoot must be a valid directory

The following three strategies, ranked from easiest to hardest, solve Apache’s ServerRoot Must be a Valid Directory error:

  1. Copy the Apache installation files to the C:\ root drive
  2. Change the SRVROOT variable in the httpd.conf file to point to your custom installation directory
  3. Run the software configuration file that comes packaged with your distribution

Copy the files to root

If you copy the folder into which Apache was installed to the root directly, the httpd.exe file will run without error. This is the easiest fix — but it’s also the least pragmatic. Installing software into the root of C:\ is an anti-pattern. On many systems, developers do not have the rights required to copy files directly into the root of the C:\ drive.

But if you want a quick fix to the Apache ServerRoot error, this is it.

Update ServerRoot in httpd.conf

The setting that defines the location of Apache’s ServerRoot is in the httpd.conf, which is located in Apache’s conf directory.

You can edit this file and specify your custom installation root. Save the file and restart the server and Apache’s Valid ServerRoot Directory error will disappear.

ServerRoot must be a valid directory fix

To eliminate the Apache ServerRoot must be a valid directory error, simply update the ServerRoot variable in the httpd.conf file.

Custom configuration files

Some distributions of the Apache Web Server come with a post-installation configuration file that updates all of the property files Apache uses when it runs.

The basic Apache Lounge installation doesn’t come with a post-installation program, but all Bitnami stacks that include an Apache Web Server do.

HTTP Apache 2.4 ServerRoot Error Fix

Avoid Apache ServerRoot errors by customizing the corresponding property in the httpd.conf file.

Valid HTTP directory error solved

For Bitnami stacks, running this post-configuration file is especially important. These stacks often wire additional software into their environment, such as NoSQL databases, a Tomcat server and language interpreters. Complex distributions such as XAMPP or Bitnami’s LAMP likely come with custom dashboards — use these to control the lifecycle of the installed software. Some of the more polished distributions eliminate the need to start and stop Apache at the command line.

Hopefully these steps solve your ServerRoot Must be a Valid Directory errorOnce the fix is in, you’ll have no problems hosting and uploading files to Apache.

If you have any other insights on how to fix the error, please share them with me on Twitter.

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

Error Message

Syntax error on line 39 of c:……. .conf/httpd.conf: ServerRoot must be a valid directory.

ServerRoot must be a valid directory

What I am trying to do

I am trying to run a new install of Apache under Windows 10.

Solution

Edit the \Apache24\conf\httpd.conf file.
At line 39 and ensure that the path to the folder where your installation is. (i.e. where you unzipped the downloaded file).

before_httpd.conf

Before – when we had an error

In my case, I extracted the downloaded file to the c:\dev directory so the change needed is highlighted below.

after_httpd.conf
After the edit

How to test

Now try to run Apache again – by running the httpd.exe command from the command prompt. If you get a cursor sitting on the next line with no error, then you are okay, and can test it by opening a browser and going to: http://localhost

Rationale

  • The default installation of Apache (2.4 in my example) expects that it is installed in the c:\Apache24 directory.
  • If you download the file and don’t extract it from the root of the c:\ drive then you will see this error.
  • The SRVROOT shows “/Apache24” as the folder – whereas on Windows you would normally expect to see “c:\Apache24” for a folder.

Request to visitors

Click “Like” if this helped and I’ll post more like this that may help you, or others in the future.
Feedback welcomed on style/format etc.

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

This question is related to
apache
httpd.conf

The answer is


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.


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»


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

Define SRVROOT "C:\Apache24"   
ServerRoot "${SRVROOT}"

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

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.


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


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.


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


  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


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

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


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


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


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.


Понравилась статья? Поделить с друзьями:
  • Server ошибка 1036
  • Server returned invalid response altstore ошибка
  • Server reset connection cisco packet tracer ошибка
  • Sea of thieves ошибка службы игры недоступны lavenderbeard
  • Server board s5520hc коды ошибок