问题
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
回答1:
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.
回答2:
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"
回答3:
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
回答4:
Change below path in httpd.conf file to your setup. This will fix the issue.
Define SRVROOT "C:\Apache24"
ServerRoot "${SRVROOT}"
回答5:
I would think that ServerRoot needs to be absolute. Use something like "/apache/docroot"
回答6:
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.
回答7:
Use the drive letter with forward slashes to get started (c:/apache/...).
回答8:
- 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"
- Open up apache\conf\httpd.conf with any text editor
- Scroll down until line 30-40
- You will find a code like this:
ServerRoot "xampp\apache"
- 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"
- It should look somehow like this:
ServerRoot "D:\XAMPP\apache"
- 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
回答9:
Run "setup_xampp.bat/.sh" and then Delete "\" at the end, so your ServerRoot should be like "C:.....\apache" NO "C:.....\apache\"
回答10:
Make sure your ServerRoot
in httpd.conf points correctly to the Apache path. Otherwise you will see this message for every further module.
回答11:
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.
回答12:
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.
回答13:
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
回答14:
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
来源:https://stackoverflow.com/questions/14548768/apache-could-not-be-started-serverroot-must-be-a-valid-directory-and-unable-to