nginx: [emerg] "auth_basic" directive is duplicate in /www/server/panel/vhost/nginx/phpmyadmin.conf:14
nginx: configuration file /www/server/nginx/conf/nginx.conf test failed

 

The error message you're seeing indicates that there's a duplicate "auth_basic" directive in your Nginx configuration file, specifically within the file located at /www/server/panel/vhost/nginx/phpmyadmin.conf on line 14. This is causing the configuration test to fail, preventing Nginx from starting or reloading the configuration.

Here's how you can resolve this issue:

Locate and Edit the Configuration File: Access the file /www/server/panel/vhost/nginx/phpmyadmin.conf. You will need appropriate permissions to edit this file.

Identify the Duplicate Directive: Search for the auth_basic directive. There should be two instances of this directive since it's reported as a duplicate.

Remove or Comment Out the Duplicate: Decide which instance of the auth_basic directive is needed (based on your authentication configuration requirements) and either remove or comment out the other one. To comment out a line in Nginx configuration, simply add a # at the beginning of the line.

Check the Configuration: After making changes, save the file. Then, run nginx -t to test the configuration. This command checks the syntax of the configuration file and reports any errors.

Reload Nginx: If the test is successful, reload Nginx to apply the changes. You can do this by running sudo systemctl reload nginx on most systems.

Verify Operation: Finally, ensure that your changes haven't affected the normal operation of your services, such as phpMyAdmin in this case.

Remember, it's always a good practice to make a backup of the configuration file before making any changes. This way, you can easily revert back in case something goes wrong.

您看到的错误消息表明您的 Nginx 配置文件中存在重复的“auth_basic”指令,特别是位于第 14 行 /www/server/panel/vhost/nginx/phpmyadmin.conf 的文件中。这会导致 配置测试失败,导致 Nginx 无法启动或重新加载配置。

以下是解决此问题的方法:

找到并编辑配置文件:访问文件 /www/server/panel/vhost/nginx/phpmyadmin.conf。 您将需要适当的权限才能编辑此文件。

识别重复指令:搜索 auth_basic 指令。 该指令应该有两个实例,因为它被报告为重复项。

删除或注释掉重复项:决定需要哪个 auth_basic 指令实例(根据您的身份验证配置要求),然后删除或注释掉另一个实例。 要注释掉 Nginx 配置中的一行,只需在该行的开头添加一个 # 即可。

检查配置:进行更改后,保存文件。 然后,运行 nginx -t 来测试配置。 此命令检查配置文件的语法并报告任何错误。

重新加载 Nginx:如果测试成功,则重新加载 Nginx 以应用更改。 您可以通过在大多数系统上运行 sudo systemctl reload nginx 来完成此操作。

验证操作:最后,确保您的更改没有影响您的服务(例如本例中的 phpMyAdmin)的正常运行。

请记住,在进行任何更改之前备份配置文件始终是一个好习惯。 这样,如果出现问题,您可以轻松恢复。

 

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。