Serverroot must be a valid directory 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:WindowsSystem32, 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 Apache24confhttpd.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.

Пытаюсь установить локальный веб-сервер для теста сайта.

В httpd.conf ServerRoot указан как С:/server/apache, однако, при попытке установить httpd.exe в консоли выпадает ошибка:

httpd.exe: Syntax error on line 39 of
C:/server/apache/conf/httpd.conf: ServerRoot must be a valid directory

что, очевидно, указывает на невалидный путь, однако, я не могу понять почему. Пожалуйста, укажите на мою ошибку.

0 / 0 / 0

Регистрация: 24.05.2014

Сообщений: 12

1

18.04.2016, 19:05. Показов 8046. Ответов 3


Студворк — интернет-сервис помощи студентам

При выполнении команды запуска в cmd апач не запускается. При выполнении команды httpd : Syntax error on line 36 of C:/Server/web/apache/conf/httpd.conf : ServerRoot must be a valid directory. Вот та самая строчка ServerRoot “C:/Server/web/apache”. При всем при этом не идет запись в логи. Что делать чтобы запустился не пойму . Прикрепляю на всякий файлик с настройками и ссылку где их брал. Помогите разобраться в чем ошибка.
https://habrahabr.ru/post/203012/#anchor02



0



Почетный модератор

Эксперт HTML/CSSЭксперт PHP

16842 / 6720 / 880

Регистрация: 12.06.2012

Сообщений: 19,967

18.04.2016, 20:30

2

Кавычки поменяйте на нормальные



1



0 / 0 / 0

Регистрация: 24.05.2014

Сообщений: 12

19.04.2016, 17:59

 [ТС]

3

Эта проблема решилась. Спасибо. Появилась новая не запускается MySQL . пишет что служба не запустилась .Ошибок службе найти не удалось.



0



Почетный модератор

Эксперт HTML/CSSЭксперт PHP

16842 / 6720 / 880

Регистрация: 12.06.2012

Сообщений: 19,967

19.04.2016, 21:34

4

смотрите в логах, mail.log или error.log в mail, смотря как у вас там



0



Понравилась статья? Поделить с друзьями:
  • Server ошибка 1036
  • Server was unable to process request ошибка
  • Server returned invalid response altstore ошибка
  • Server reset connection cisco packet tracer ошибка
  • Server is full ошибка