Error "Web server configuration test failed"
Symptoms
When changing site settings in the ispmanager panel, the following error message appears:
Web server configuration test failed <error details>
(nginx: configuration file /etc/nginx/nginx.conf test failed)
Causes
The error occurs when checking the syntax of the Nginx web server configuration file. It usually occurs due to manual changes made in the configuration files of the web server itself or a virtual host (site configuration file).
Solution
PLEASE NOTE!
If you don’t find the solution to your problem in this manual, please perform the initial diagnostics listed in the "Other errors" chapter and write to ispmanager support with the outcome of the diagnostics.
If the IP address being listened to is wrong
If an invalid IP address is set for web server listening, the panel will return the following error:
Web server configuration test when saving a file
'/etc/nginx/vhosts/<user_name>/<site_name>.conf' failed:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx:
[emerg] bind() to <ip-адрес:порт> failed (99: Unknown error) nginx: configuration file /etc/nginx/nginx.conf test failed
If so, pay attention to which address and port the error points to. Then, check which file uses that address and port.
You can do so with the "grep" utility:
grep -r <ip-address:port> /etc/nginx/*
Also, check for the IP address on the server's network interface:
ip a | grep <ip-address:port>
If the address is missing, the Nginx web server will not run the configuration with that address – either change the IP address in the configuration files or add an IP address on the interface.
When there’s a certificate file path error
If an invalid path to the certificate file has been set, the panel will return the following error:
Web server configuration test when saving a file
'/etc/nginx/vhosts/<username>/<site-name>.conf' failed:
nginx: [emerg] cannot load certificate "/var/www/httpd-cert/<username>/<site-name>_le1.crtca":
BIO_new_file() failed (SSL: error:02001002:system library:
fopen:No such file or directory:fopen('/var/www/httpd-cer/<username>/<site-name>_le1.crtca','r')
error:2006D080:BIO routines:BIO_new_file:no such file) nginx:
configuration file /etc/nginx/nginx.conf test failed
The error occurs when the path to the certificate is set incorrectly or the certificate file does not exist in the specified path.
Check whether the certificate files exist in the specified path:
ls -la /var/www/httpd-cert/<username>/<site-name>
Also, check which file specifies the path to these files:
grep -r <site-name>_le /etc/nginx/vhosts/*
If no such file exists, remove all directives that reference the file, run a configuration test with the nginx -t
command, and retry certificate issuance if the test was successful.
If the syntax error "directive is not allowed" occurs
If the syntax error is "directive is not allowed", the panel will return the following format error:
Web server configuration test when saving a file
'/etc/nginx/vhosts/<username>/<site-name>.conf' failed:
nginx: [emerg] "<directive-name>" directive is not allowed here in
/etc/nginx/vhosts/<username>/<site-name>.conf:
85 nginx: configuration file /etc/nginx/nginx.conf test failed
If so, the error indicates that a directive is in the incorrect location. For example, the server
directive is set inside the location
directive, which is a superior directive and should be specified inside location
.
To fix this error, you need to check the structure of the configuration file and set the directives correctly.
When the syntax error "duplicate directive" occurs
If the syntax error is "duplicate directive", the panel will return the following format error:
Web server configuration test when saving a file
'/etc/nginx/vhosts/<username>/<site-name>.conf' failed:
nginx: [emerg] "<path-to-directive>" directive "<directive-name>" directive is duplicate in
/etc/nginx/vhosts/<username>/<site-name>.conf:
85 nginx: configuration file /etc/nginx/nginx.conf test failed
Web server configuration test when saving a file
<location_directive><directive_name><user_name>/<site_name>.
If so, the error indicates that there is a duplicate directive in one of the sections of the configuration file, e.g., the gzip
directive was marked twice in the location
section.
To fix this error, check which section is specified for the <directive_location>
location in the error text and eliminate duplicate directives.
Other errors.
If there is any syntax error other than those listed in this article, the panel will return a format error:
Web server configuration test when saving a file
'/etc/nginx/vhosts/<username>/<site-name>.conf' failed:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: [emerg] <error-details>
/etc/nginx/vhosts/<username>/<site-name>.conf:
85 nginx: configuration file /etc/nginx/nginx.conf test failed
The cause of such an error may be a typo or incorrect settings.
To fix such an error, use a text editor to open the configuration file specified in the error and check the syntax of the line specified in <error_details>
. If changes have been made to the configuration manually, undo them.
Then, perform a syntax check using the nginx -t
command, first running it without any additional parameters and then specifying the path to the problematic configuration file:
nginx -t /etc/nginx/vhosts/<username>/<site-name>.conf
Moreover, to compare the configuration of the problem site and the default configuration, you can create a blank site with a similar PHP version and mode of operation.
PLEASE NOTE!
There is no guarantee that the panel and web servers will run correctly if configuration changes have been made manually.