I have just installed Apache 2.2.17, and I am using it for the first time.
Now when I try to start the server using the command service httpd start
it gives me the message:
httpd: Could not reliably determine the server’s fully qualified domain name, using ::1 for ServerName
Now I think I have to set ServerName and the IP address as I search through Google. But I don’t know in which file I have to set.
How can I fix this problem?
crmpicco
16.7k26 gold badges134 silver badges210 bronze badges
asked May 2, 2011 at 10:46
sudo vim /etc/apache2/httpd.conf
- Insert the following line at the httpd.conf:
ServerName localhost
- Just restart the Apache:
sudo /etc/init.d/apache2 restart
answered Nov 22, 2011 at 16:00
Douglas MirandaDouglas Miranda
1,0291 gold badge7 silver badges3 bronze badges
4
I was NOT getting the ServerName wrong. Inside your VirtualHost configuration that is causing this warning message, it is the generic one near the top of your httpd.conf which is by default commented out.
Change
#ServerName www.example.com:80
to:
ServerName 127.0.0.1:80
answered Oct 9, 2013 at 9:54
zzapperzzapper
4,7435 gold badges48 silver badges45 bronze badges
Under Debian Squeeze;
- Edit Apache2 conf file : vim /etc/apache2/apache2.conf
- Insert the following line at the apache2.conf: ServerName localhost
- Restart Apache2: apache2ctl restart or /etc/init.d/apache2 restart
Should work fine (it did solve the problem in my case)
tks noodl for the link on the different layouts.
answered Apr 23, 2012 at 9:26
Bernard SfezBernard Sfez
1,3292 gold badges15 silver badges18 bronze badges
0
sudo nano /etc/apache2/httpd.conf
- search for a text
ServerName
in nano editor<Ctrl + W>
- Insert the following line at the httpd.conf:
ServerName localhost
- Just restart the Apache:
sudo /usr/sbin/apachectl restart
answered Oct 8, 2017 at 23:35
Another option is to ensure that the full qualified host name (FQDN) is listed in /etc/hosts.
This worked for me on Ubuntu v11.10 without having to change the default Apache configuration.
answered May 15, 2012 at 18:47
Lars NordinLars Nordin
2,7701 gold badge22 silver badges25 bronze badges
0
» To solve this problem You need set ServerName.
1: $ vim /etc/apache2/conf.d/name
For example set add ServerName localhost or any other name:
2: ServerName localhost
Restart Apache 2
3: $ service apache restart
For this example I use Ubuntu 11.10.1.125″
answered Apr 12, 2019 at 5:15
FQDN means the resolved name over DNS. It should be like «server-name.search-domain».
The warning you get just provides a notice that httpd can not find a FQDN, so it might not work right to handle a name-based virtual host. So make sure the expected FQDN is registered in your DNS server, or manually add the entry in /etc/hosts
which is prior to hitting DNS.
answered Jul 11, 2013 at 0:42
shawnzhushawnzhu
7,2434 gold badges35 silver badges51 bronze badges
If you are using windows there is something different sort of situation
First open c:/apache24/conf/httpd.conf
.
The Apache folder is enough not specifically above path
After that you have to configure httpd.conf file.
Just after few lines there is pattern like:
#Listen _____________:80
Listen 80
Here You have to change for the localhost
.
You have to enter ipv4 address for that you can open localhost.
Refer this video link and after that just bit more.
Change your environment variables:
In which you have to enter path:
c:apache24/bin
and
same in the SYSTEM variables
If any query feel free to ask.
answered Jul 14, 2018 at 9:28
ankitankit
111 bronze badge
Two things seemed to do it for me:
- Put all aliases for 127.0.0.1 in /etc/hosts in a single line (e.g.
127.0.0.1 localhost mysite.local myothersite.local
- Set
ServerName
in my httpd.conf to0.0.0.0
(localhost or 127.0.0.1 didn’t work for me)
Editing /etc/hosts got rid of long response times and setting the ServerName got rid of OP’s warning for me.
answered Jun 23, 2015 at 15:02
Benjamin BojkoBenjamin Bojko
5531 gold badge7 silver badges14 bronze badges
who are still couldnt resolve the problem and using mac then follow this
1.goto the root folder /
- cd usr/local/etc/apache2/2.4
3.sudo nano httpd.conf
4.change #servername to ServerName 127.0.0.1:8080 press ctrl+o,+return+ctrl x
5.then restart the server apachectl restart
answered Feb 10, 2017 at 6:02
If you are using windows, remove comment on these lines and set them as:
Line 227 : ServerName 127.0.0.1:80
Line 235 : AllowOverride all
Line 236 : Require all granted
Worked for me!
Boendal
2,4961 gold badge23 silver badges36 bronze badges
answered Dec 20, 2019 at 19:47
2
Here’s my two cents. Maybe it’s useful for future readers.
I ran into this problem when using Apache within a Docker container. When I started a container from an image of the Apache webserver, this message appeared when I started it with docker run -it -p 80:80 my-apache-container
.
However, after starting the container in detached mode, using docker run -d -p 80:80 my-apache-container
, I was able to connect through the browser.
answered Apr 2, 2020 at 19:58
MC EmperorMC Emperor
22.4k15 gold badges80 silver badges130 bronze badges
I am using ubuntu 22.04
I installed the apache2 at the location ‘/usr/local/apache2’
I just edited the ‘/usr/local/apache2/conf/httpd.conf’ file.
run the following commands
cd /usr/local/apache2/conf
sudo nano httpd.conf
find this comment
#ServerName www.example.com:80, in my case it is at line 197
after that add this
ServerName localhost
don’t modify anything else in this file!
Thank you!
answered Sep 21, 2022 at 6:28
Try to do it.
hostnamectl set-hostname youfirstdomain.com
vi /etc/hosts
add this line
0.0.0.0 youfirstdomain.com
Instead of 0.0.0.0 put your IP address of the server
sudo systemctl restart apache2
answered Apr 14 at 12:43
Had the following error, it could be due to permissions, had restarted apache as root and it worked!
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
answered Jun 2 at 18:07
26 сентября, 2020 12:02 пп
27 856 views
| Комментариев нет
LAMP Stack
Эта серия мануалов поможет вам предотвратить или устранить самые распространенные ошибки, которые возникают при работе с веб-сервером Apache.
Каждый мануал в этой серии включает описание распространенных ошибок Apache, связанных с конфигурацией, сетью, файловой системой или привилегиями.
Ошибка конфигурации Apache «AH00558: Could not reliably determine the server’s fully qualified domain name» возникает, когда в настройках Apache нет глобальной директивы ServerName. Сообщение в основном предназначено для информирования, и сама по себе ошибка AH00558 не помешает правильной работе Apache.
В этом мануале вы узнаете, как применить алгоритм, описанный в руководстве Устранение общих ошибок Apache, чтобы обнаружить AH00558. Мы также поможем вам установить директиву ServerName, чтобы устранить эту ошибку.
Примечание: Если вы уже определили, что на вашем сервере Apache появляется ошибка AH00558, вы можете пропустить разделы по поиску неполадок и сразу перейти к последнему разделу этого мануала, чтобы установить глобальную директиву ServerName.
Поиск ошибки с помощью systemctl
Первый шаг при устранении AH00558 – это проверить статус Apache с помощью systemctl. Вывод systemctl часто содержит всю информацию, необходимую для исправления ошибки.
В дистрибутивах Ubuntu и Debian запустите следующую команду, чтобы проверить статус Apache:
sudo systemctl status apache2.service -l --no-pager
В CentOS, Fedora и других системах, производных от RedHat, используйте эту команду:
sudo systemctl status httpd.service -l --no-pager
Флаг -l выводит все содержимое строки без сокращений (без замены длинных строк многоточием (…)). Флаг –no-pager выводит весь лог на ваш экран, не вызывая инструмент less, который показывает только один экран контента за раз.
Вы должны получить такой вывод:
apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Wed 2020-07-29 14:30:03 UTC; 33min ago
Process: 34 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 46 (apache2)
Tasks: 55 (limit: 2344)
CGroup: /system.slice/apache2.service
├─46 /usr/sbin/apache2 -k start
├─47 /usr/sbin/apache2 -k start
└─48 /usr/sbin/apache2 -k start
Jul 29 14:30:03 68e2cf19f3f1 systemd[1]: Starting The Apache HTTP Server...
Jul 29 14:30:03 68e2cf19f3f1 apachectl[34]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
Jul 29 14:30:03 68e2cf19f3f1 systemd[1]: Started The Apache HTTP Server.
Обратите внимание на выделенную строку, содержащую сообщение об ошибке AH00558. По сути, она говорит вам, что Apache не смог найти валидную директиву ServerName в своем конфигурационном файле, поэтому он будет использовать первый обнаруженный IP-адрес. В данном примере это внешний IP-адрес сервера: 172.17.02. В вашем случае IP-адрес может быть другим, это также может быть человекочитаемое DNS-имя.
Если ваш вывод systemctl предлагает вам любое автоматически определяемое значение IP-адреса или хоста, перейдите к последнему разделу этого руководства, чтобы установить глобальную директиву ServerName и решить проблему (этот раздел поможет установить для Apache безопасное значение ServerName по умолчанию, используя IP-адрес localhost: 127.0.0.1).
Если в выходных данных systemctl не указано значение, которое можно использовать для директивы ServerName, в следующем разделе этого мануала мы расскажем, как исследовать логи systemd с помощью journalctl для поиска информации о AH00558.
Устранение ошибки с помощью journalctl
Чтобы проверить логи systemd для Apache, воспользуйтесь командой journalctl. При вызове journalctl есть два особых флага, которые помогут вам найти определенные сообщения среди других записей.
Первый флаг, который нужно добавить к journalctl – это флаг –since today. он ограничит вывод команды только теми записями, которые были зарегистрированы в логе с 00:00:00 текущего дня. Использование этой опции поможет ограничить объем выведенных записей, которые вам придется изучить при поиске ошибок.
Второй флаг, который мы советуем использовать, – это опция –no-pager, которую вы применили в systemctl. Она сразу выводит весь лог на экран.
В системах Ubuntu и Debian выполните следующую команду:
sudo journalctl -u apache2.service --since today --no-pager
В CentOS, Fedora и других RedHat-подобных системах используйте эту команду:
sudo journalctl -u httpd.service --since today --no-pager
Если на вашем сервере Apache есть ошибка AH00558, просмотрите вывод journalctl и найдите такую строку:
-- Logs begin at Wed 2020-07-29 14:30:02 UTC, end at Wed 2020-07-29 14:45:03 UTC. --
. . .
Jul 29 14:30:03 68e2cf19f3f1 systemd[1]: Starting The Apache HTTP Server...
Jul 29 14:30:03 68e2cf19f3f1 apachectl[34]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
Jul 29 14:30:03 68e2cf19f3f1 systemd[1]: Started The Apache HTTP Server.
Вторая строка вывода – это сообщение об ошибке AH00558. Строка содержит внешний IP-адрес сервера, который Apache автоматически определяет и устанавливает по умолчанию во время выполнения. Получив это сообщение как подтверждение ошибки AH00558, вы можете перейти к настройке глобальной директивы ServerName для решения проблемы.
В следующем разделе мы расскажем, как диагностировать ошибку AH00558 с помощью команды apachectl.
Поиск ошибки с помощью apachectl
Ошибка AH00558 может быть обнаружена с помощью утилиты Apache apachectl. Она может перехватывать подобные сообщения перед перезагрузкой или перезапуском Apache, и вам не придется искать ошибки в логах systemctl и journalctl.
Чтобы проверить конфигурацию Apache на наличие ошибки AH00558, выполните следующую команду:
sudo apachectl configtest
Вы должны получить следующий вывод, если на вашем сервере действительно есть ошибка AH00558:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
Syntax OK
Как и в предыдущих разделах этого мануала, в которых для поиска сообщений AH00558 использовались systemctl и journalctl, здесь важно найти строку, содержащую сообщение AH00558. Еще раз обратите внимание, что IP-адрес (172.17.0.2) у вас может отличаться.
В следующем разделе мы поможем установить директиву ServerName для устранения сообщений об ошибках AH00558.
Установка глобальной директивы ServerName
Чтобы устранить ошибку AH00558, необходимо добавить директиву ServerName в конфигурацию Apache. Apache использует директиву ServerName для сопоставления входящих HTTP-запросов с IP-адресом или именем DNS хоста (с помощью директив VirtualHost) для обработки запросов нескольких сайтов, размещенных в рамках одного сервера.
В сообщении об ошибке отмечается, что также нужно установить глобальную директиву ServerName. С ее помощью Apache сможет корректно обрабатывать входящие запросы, которые не сопоставляются с VirtualHost, не выдавая при этом дополнительных ошибок.
Для максимальной совместимости с различными конфигурациями Apache используйте для вашей глобальной директивы ServerName значение 127.0.0.1. При необходимости вы можете использовать другой IP-адрес или DNS-имя, соответствующее конфигурации вашего сервера, но безопаснее всего использовать 127.0.0.1.
В системах Ubuntu и Debian откройте файл /etc/apache2/apache2.conf с правами root:
sudo nano /etc/apache2/apache2.conf
Добавьте в конец файла строку ServerName 127.0.0.1:
. . .
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
ServerName 127.0.0.1
В CentOS, Fedora и других системах RedHat откройте файл /etc/httpd/conf/httpd.conf с правами root:
sudo nano /etc/httpd/conf/httpd.conf
Добавьте строку ServerName 127.0.0.1 в конец файла:
. . .
# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf
ServerName 127.0.0.1
Сохраните и закройте файл, когда закончите.
После добавления директивы ServerName в конфигурацию запустите apachectl, чтобы проверить ошибки в обновленной конфигурации веб-сервера.
sudo apachectl configtest
Если apachectl не обнаружила ошибок в конфигурации, вы увидите:
Syntax OK
Теперь вы можете перезапустить Apache, используя соответствующую команду systemctl restart для вашего дистрибутива Linux.
В системах Ubuntu и Debian запустите:
sudo systemctl restart apache2.service
В системах CentOS, Fedora и RedHat используйте эту команду:
sudo systemctl restart httpd.service
После перезапуска Apache сообщение об ошибке AH00558 больше не будет отображаться в ваших логах. Вы можете убедиться, что сообщения исчезли, выполнив любую из трех команд systemctl, journalctl или apachectl, которые мы использовали ранее в этом руководстве.
Заключение
В этом мануале вы познакомились с ошибкой AH00558: Could not reliably determine the server’s fully qualified domain name. Хотя эти сообщения не препятствуют запуску Apache, их можно устранить, установив глобальную директиву ServerName.
Вы узнали, как искать сообщения об ошибках AH00558 с помощью команд systemctl, journalctl и apachectl и как отредактировать конфигурацию Apache в различных дистрибутивах Linux, чтобы эти сообщения больше не отображались.
Если вы хотите узнать больше о том, как Apache использует директивы ServerName, обратитесь к документации Apache.
Tags: Apache, apachectl, CentOS, Debian, Fedora, journalctl, systemctl, Ubuntu
I have just installed Apache 2.2.17, and I am using it for the first time.
Now when I try to start the server using the command service httpd start
it gives me the message:
httpd: Could not reliably determine the server’s fully qualified domain name, using ::1 for ServerName
Now I think I have to set ServerName and the IP address as I search through Google. But I don’t know in which file I have to set.
How can I fix this problem?
crmpicco
16.7k26 gold badges134 silver badges210 bronze badges
asked May 2, 2011 at 10:46
sudo vim /etc/apache2/httpd.conf
- Insert the following line at the httpd.conf:
ServerName localhost
- Just restart the Apache:
sudo /etc/init.d/apache2 restart
answered Nov 22, 2011 at 16:00
Douglas MirandaDouglas Miranda
1,0291 gold badge7 silver badges3 bronze badges
4
I was NOT getting the ServerName wrong. Inside your VirtualHost configuration that is causing this warning message, it is the generic one near the top of your httpd.conf which is by default commented out.
Change
#ServerName www.example.com:80
to:
ServerName 127.0.0.1:80
answered Oct 9, 2013 at 9:54
zzapperzzapper
4,7435 gold badges48 silver badges45 bronze badges
Under Debian Squeeze;
- Edit Apache2 conf file : vim /etc/apache2/apache2.conf
- Insert the following line at the apache2.conf: ServerName localhost
- Restart Apache2: apache2ctl restart or /etc/init.d/apache2 restart
Should work fine (it did solve the problem in my case)
tks noodl for the link on the different layouts.
answered Apr 23, 2012 at 9:26
Bernard SfezBernard Sfez
1,3292 gold badges15 silver badges18 bronze badges
0
sudo nano /etc/apache2/httpd.conf
- search for a text
ServerName
in nano editor<Ctrl + W>
- Insert the following line at the httpd.conf:
ServerName localhost
- Just restart the Apache:
sudo /usr/sbin/apachectl restart
answered Oct 8, 2017 at 23:35
Another option is to ensure that the full qualified host name (FQDN) is listed in /etc/hosts.
This worked for me on Ubuntu v11.10 without having to change the default Apache configuration.
answered May 15, 2012 at 18:47
Lars NordinLars Nordin
2,7701 gold badge22 silver badges25 bronze badges
0
» To solve this problem You need set ServerName.
1: $ vim /etc/apache2/conf.d/name
For example set add ServerName localhost or any other name:
2: ServerName localhost
Restart Apache 2
3: $ service apache restart
For this example I use Ubuntu 11.10.1.125″
answered Apr 12, 2019 at 5:15
FQDN means the resolved name over DNS. It should be like «server-name.search-domain».
The warning you get just provides a notice that httpd can not find a FQDN, so it might not work right to handle a name-based virtual host. So make sure the expected FQDN is registered in your DNS server, or manually add the entry in /etc/hosts
which is prior to hitting DNS.
answered Jul 11, 2013 at 0:42
shawnzhushawnzhu
7,2434 gold badges35 silver badges51 bronze badges
If you are using windows there is something different sort of situation
First open c:/apache24/conf/httpd.conf
.
The Apache folder is enough not specifically above path
After that you have to configure httpd.conf file.
Just after few lines there is pattern like:
#Listen _____________:80
Listen 80
Here You have to change for the localhost
.
You have to enter ipv4 address for that you can open localhost.
Refer this video link and after that just bit more.
Change your environment variables:
In which you have to enter path:
c:apache24/bin
and
same in the SYSTEM variables
If any query feel free to ask.
answered Jul 14, 2018 at 9:28
ankitankit
111 bronze badge
Two things seemed to do it for me:
- Put all aliases for 127.0.0.1 in /etc/hosts in a single line (e.g.
127.0.0.1 localhost mysite.local myothersite.local
- Set
ServerName
in my httpd.conf to0.0.0.0
(localhost or 127.0.0.1 didn’t work for me)
Editing /etc/hosts got rid of long response times and setting the ServerName got rid of OP’s warning for me.
answered Jun 23, 2015 at 15:02
Benjamin BojkoBenjamin Bojko
5531 gold badge7 silver badges14 bronze badges
who are still couldnt resolve the problem and using mac then follow this
1.goto the root folder /
- cd usr/local/etc/apache2/2.4
3.sudo nano httpd.conf
4.change #servername to ServerName 127.0.0.1:8080 press ctrl+o,+return+ctrl x
5.then restart the server apachectl restart
answered Feb 10, 2017 at 6:02
If you are using windows, remove comment on these lines and set them as:
Line 227 : ServerName 127.0.0.1:80
Line 235 : AllowOverride all
Line 236 : Require all granted
Worked for me!
Boendal
2,4961 gold badge23 silver badges36 bronze badges
answered Dec 20, 2019 at 19:47
2
Here’s my two cents. Maybe it’s useful for future readers.
I ran into this problem when using Apache within a Docker container. When I started a container from an image of the Apache webserver, this message appeared when I started it with docker run -it -p 80:80 my-apache-container
.
However, after starting the container in detached mode, using docker run -d -p 80:80 my-apache-container
, I was able to connect through the browser.
answered Apr 2, 2020 at 19:58
MC EmperorMC Emperor
22.4k15 gold badges80 silver badges130 bronze badges
I am using ubuntu 22.04
I installed the apache2 at the location ‘/usr/local/apache2’
I just edited the ‘/usr/local/apache2/conf/httpd.conf’ file.
run the following commands
cd /usr/local/apache2/conf
sudo nano httpd.conf
find this comment
#ServerName www.example.com:80, in my case it is at line 197
after that add this
ServerName localhost
don’t modify anything else in this file!
Thank you!
answered Sep 21, 2022 at 6:28
Try to do it.
hostnamectl set-hostname youfirstdomain.com
vi /etc/hosts
add this line
0.0.0.0 youfirstdomain.com
Instead of 0.0.0.0 put your IP address of the server
sudo systemctl restart apache2
answered Apr 14 at 12:43
Had the following error, it could be due to permissions, had restarted apache as root and it worked!
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
answered Jun 2 at 18:07
Posted:
05 Aug, 20
Updated:
14 Dec, 21
by Antoniy Yushkevych
1 Min
When attempting to install an Apache web server on Windows server you may face a very common error. You will encounter this problem when you will try to install and set up the latest versions of Apache. The error AH00558 requires you to set the ‘ServerName’ directive globally.
Before fixing the problem here’s a preview of the error that you will see on your screen.
AH00558: httpd.exe: Could not reliably determine the server's fully qualified domain name, using fe80::7077:eaf3:2440:24a1. Set the 'ServerName' directive globally to suppress this message
How to solve the Apache error AH00558:
To solve this we should determine the server name in Apache config file.
Apache config file is located in C:\Apache24\conf\httpd.conf
1. open C:\Apache24\conf\httpd.conf
with notepad or any other text editor.
2. search for this line in config file «#ServerName
www.example.com:80
«
3. uncomment this line by removing # from the first of line and edit as below
ServerName 127.0.0.1
4. save the file and exit
This will definitely solve the problem. You can check it yourself: run apache by running httpd.exe.
If it worked let us know your thoughts in the comments below. For the full guide on setting up Apache, check our «Full Apache installation guide» from here.
https://monovm.com/blog/how-to-install-apache-on-windows/
Перейти к содержимому
Однажды после установки и настройки Apache2 в Ubuntu Server 20.04 я заметил следующую ошибку в логах /var/log/apache2/error.log:
AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1. Set the ‘ServerName’ directive globally to suppress this message
При этом директива ServerName была указана для сайтов настроенных в /etc/apache2/sites-enabled, но не указана глобально как написано в ошибке.
Поэтому для решения ошибки, я открыл основной файл конфигурации Apache2:
nano /etc/apache2/apache2.conf
И после # Global configuration, указал:
Потом проверил корректность конфигурации:
И применил конфигурацию:
Либо можно перезапустить apache2:
После этого ошибка была решена.
Смотрите другие мои статьи на тему Apache2