I have configured virtual host on Ubuntu 20.04.3 LTS, but it's not working.
Firstly created dir using:
sudo mkdir -p /var/www/domain1.com/public_html
Then created index.html file inside it:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Welcome to domain1.com</title>
</head>
<body>
<h1>Success! domain1.com home page!</h1>
</body>
</html>
to avoid permission issues, I ran this command:
sudo chown -R www-data: /var/www/domain1.com
Then inside /etc/apache2/sites-available I have created a config file:
/etc/apache2/sites-available/domain1.com.conf
And putted this code into it
<VirtualHost *:80>
ServerName domain1.com
ServerAlias www.domain1.com
ServerAdmin [email protected]
DocumentRoot /var/www/domain1.com/public_html
<Directory /var/www/domain1.com/public_html>
Options -Indexes +FollowSymLinks
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/domain1.com-error.log
CustomLog ${APACHE_LOG_DIR}/domain1.com-access.log combined
</VirtualHost>
Then ran this command:
sudo a2ensite domain1.com
Then restarted apache using command:
sudo systemctl restart apache2
Then Tested configuration:
sudo apachectl configtest
and got output as Syntax OK
but when I visit domain1.com in browser, getting "This site can’t be reached" error.
You've configured Apache to special case any requests it recieves for
domain1.comYou haven't:
(Or done a local hack with something like a
hostsfile).