Unable to find a virtual host listening on port 80

Hi,
After a fresh installation of Centos7 and httpd, I checked if I can see the test page and it was fine.
As I ran certbot --apache, I see this message

Performing the following challenges:
http-01 challenge for test.scu.ac.ir
Cleaning up challenges
Unable to find a virtual host listening on port 80 which is currently needed for Certbot to prove to the CA that you control your domain. Please add a virtual host for port 80.

I see some discussions on the web about that. But I can not find a clear answer for that. How can I fix that?

Hi @mahmoodn

create a vHost with that domain name.

What says

apachectl -t

to list your vHosts?

Perhaps find your default vHost, then you have a template to create a vHost with

ServerName test.scu.ac.ir

I tried to define a virtualhost but failed.

[root@test httpd]# ls -l /var/www/html/
total 4
-rw-r--r--. 1 apache apache   0 Apr 13 23:55 error.log
-rw-r--r--. 1 apache apache 159 Apr 13 23:50 index.html
[root@test httpd]# cat sites-enabled/sample.virtual.conf
<VirtualHost *:80>
    ServerName test.scu.ac.ir
    ServerAlias example.com
    DocumentRoot /var/www/html
    ErrorLog /var/www/html/error.log
    CustomLog /var/www/html/requests.log combined
</VirtualHost>
[root@test httpd]# systemctl stop httpd
[root@test httpd]# systemctl start httpd
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

In /var/log/messages, I see

Apr 13 23:59:40 test systemd: Starting The Apache HTTP Server...
Apr 13 23:59:41 test systemd: httpd.service: main process exited, code=exited, status=1/FAILURE
Apr 13 23:59:41 test kill: kill: cannot find process ""
Apr 13 23:59:41 test systemd: httpd.service: control process exited, code=exited status=1
Apr 13 23:59:41 test systemd: Failed to start The Apache HTTP Server.
Apr 13 23:59:41 test systemd: Unit httpd.service entered failed state.
Apr 13 23:59:41 test systemd: httpd.service failed.

also journalctl shows

-- Unit httpd.service has begun starting up.
Apr 14 00:00:30 test.scu.ac.ir systemd[1]: httpd.service: main process exited, code=exited, status=1/FA
Apr 14 00:00:30 test.scu.ac.ir kill[7137]: kill: cannot find process ""
Apr 14 00:00:30 test.scu.ac.ir systemd[1]: httpd.service: control process exited, code=exited status=1
Apr 14 00:00:30 test.scu.ac.ir systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has failed.
--
-- The result is failed.
Apr 14 00:00:30 test.scu.ac.ir systemd[1]: Unit httpd.service entered failed state.
Apr 14 00:00:30 test.scu.ac.ir systemd[1]: httpd.service failed.
Apr 14 00:00:30 test.scu.ac.ir polkitd[4541]: Unregistered Authentication Agent for unix-process:7130:2
lines 2106-2152/2152 (END)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.