To set up virtual host
-create a project directory
Step 1 — Create a conf file
Copy 000-default.com.conf
to create a new file in /etc/apache2/sites-available
:
$ cd /etc/apache2/sites-available
$ sudo cp 000-default.com.conf example.com.conf
-include that directory to sites available using <directoryname>.conf file- sudo nano /etc/apache2/sites-available/directoryname.conf
*nano-open editor
-include the following contents for bionic beaver 18.04 ubuntu
Step 2 — Modify the new conf file
-
<VirtualHost *:80> ServerAdmin your.email@gmail.com ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com/public_html <Directory /var/www/example.com/public_html> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <IfModule mod_dir.c> DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm </IfModule> </VirtualHost>
--------------------------
Restarting apache
include in/etc/hosts if you dont have any ip
/or set up domain in godaddy
-ip adress and server name
------------------------------------------------
Step 3 — Enabling a virtual host
-to enable the site
sudo a2ensite <directoryname>
-to test for syntax errors
sudo apachectl configtest
-syntax ok
-restart apache services
sudo systemctl restart apache2
Step 4— Enabling SSL
Install certbot
sudo snap install --classic certbot
$ sudo certbot --apache -d example.com -d www.example.com
sudo systemctl restart apache2
No comments:
Post a Comment