Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find a virtual host listening on port 80.... Please add a virtual host for port 80

My web server is set up like this:

  • AWS EC2 Linux AMI
  • Apache 2.4
  • PHP 7
  • MySQL

Certbot is giving me an error like this when I try to run it:

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've looked at other answers people posted on their blogs etc... but they were were not specifically for the EC2 Linux AMI or were made more complicated than they need be.

Most of them seem to have something to do with /sites-available or enabled... but the main .conf file already has a line in it that points to additional .conf files. No need to add a line there.

like image 823
Adam Winter Avatar asked Jan 01 '20 00:01

Adam Winter


1 Answers

This all assumes that you have Apache 2.4 installed and are trying to install Certbot. Make sure A record is set to your IP address in DNS.

cd /etc/httpd/conf.d
sudo nano yourDomainName.conf

Paste, edit, and save the following:

<VirtualHost *:80>
    ServerName yourDomainName.com
    DocumentRoot /var/www/html
    ServerAlias www.yourDomainName.com
    ErrorLog /var/www/error.log
    CustomLog /var/www/requests.log combined
</VirtualHost>

.

sudo service httpd restart  

And with this you should see the virtual host:

httpd -D DUMP_VHOSTS  

To install certbot:

cd ~/downloads
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
sudo certbot-auto --apache --debug
like image 141
Adam Winter Avatar answered Sep 16 '22 12:09

Adam Winter