Apache2 Virtualhost setup
Table of Contents
After installing apache server on your machine you can access the server from the IP of machine
To access the same server from a register domain:
sudo nano /etc/apache2/sites-available/thebigocommunity.org.conf
Create a file here /etc/apache2/sites-available/ name [your_domain_name].conf
With contents:
<VirtualHost *:443>
ServerAdmin admin@example.com
DocumentRoot /var/www/html
ServerName thebigocommunity.org
ServerAlias www.thebigocommunity.org
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/thebigocommunity.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/thebigocommunity.org/privkey.pem
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
This content is for ssl enabled site.
Similar to this.
Here :80 is for http
Once you have a virtual host file that meets your requirements, you can use the tools included with Apache to transition it into live websites. To create a symbolic link in the sites-enabled directory to an existing file in the sites-available directory, issue the following command. Make sure to replace your_domain with the name of your own virtual host site configuration file:
sudo a2ensite your_domain
Error
Invalid command ‘SSLEngine’, perhaps misspelled or defined by a module not included in the server configuration
Dec 08 11:39:06 atulya systemd[1]: Starting apache2.service - The Apache HTTP Server...
Dec 08 11:39:06 atulya systemd[1]: Started apache2.service - The Apache HTTP Server.
Dec 08 11:39:50 atulya systemd[1]: Reloading apache2.service - The Apache HTTP Server...
Dec 08 11:39:50 atulya apachectl[32205]: AH00526: Syntax error on line 7 of /etc/apache2/sites-enabled/thebigocommunity.org.conf:
Dec 08 11:39:50 atulya apachectl[32205]: Invalid command 'SSLEngine', perhaps misspelled or defined by a module not included in the server configuration
Dec 08 11:39:50 atulya apachectl[32202]: Action 'graceful' failed.
Dec 08 11:39:50 atulya apachectl[32202]: The Apache error log may have more information.
Dec 08 11:39:50 atulya systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
Dec 08 11:39:50 atulya systemd[1]: Reload failed for apache2.service - The Apache HTTP Server.
sudo a2enmod ssl
Considering dependency setenvif for ssl: