To create a virtual host or local site in ubuntu machine, do the following things-
1) Put your contents in your local machine,
for me its in "/var/www/html/workingdir/testdomainfolder"
2) Cd /etc/apache2/sites-available/
5) Sudo a2ensite testdomain.com.conf
This will create a "testdomain.com.conf" in sites-enabled folder
6) Add an entry in the local host's file and this/your domain name as-
sudo vim /etc/hosts
Add below entry(or pur your domain name here)-
127.0.0.1 www.testdomain.com
7) sudo systemctl restart apache2
8) open your browser and type www.testdomain.com
Cheers!!!!!! It's done.
Below is the conf file for the created virtual host for port 80 and 443
<Directory /usr/lib/cgi-bin>
Order allow,deny
Allow from all
Options None
AllowOverride None
</Directory>
CustomLog /var/www/logs/vmsfrontend_log common
ErrorLog /var/www/logs/vmsfrontend_error_log
</VirtualHost>
<VirtualHost *:443>
ReWriteEngine On
ServerAlias www.vmsfrontend.com
ServerName vmsfrontend.com
DocumentRoot /var/www/html/workingdir/keystone_vms_ui
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
#SSLCertificateFile /etc/apache2/ssl/apache.crt
# SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
# SSLCACertificateFile /etc/ssl/certs/apache-selfsigned.crt
<Directory /var/www/html/workingdir/keystone_vms_ui>
Order allow,deny
Allow from all
Options +FollowSymLinks -Indexes
AllowOverride All
</Directory>
</VirtualHost>
1) Put your contents in your local machine,
for me its in "/var/www/html/workingdir/testdomainfolder"
2) Cd /etc/apache2/sites-available/
3) Create a file name- "www.testdomain.com", do the following-
sudo vim www.testdomain.com
4) Write the following contents in "www.testdomain.com", change domain name according to your and write your document root
<VirtualHost *:80>
ServerName www.testdomain.com
DocumentRoot /var/www/html/workingdir/testdomainfolder
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin
<Directory /var/www/html/workingdir/testdomainfolder>
Order allow,deny
Allow from all
Options +FollowSymLinks -Indexes
AllowOverride All
</Directory>
<Directory /usr/lib/cgi-bin>
Order allow,deny
Allow from all
Options None
AllowOverride None
</Directory>
CustomLog /var/www/logs/testdomain_log common
ErrorLog /var/www/logs/testdomain_error_log
</VirtualHost>
This will create a "testdomain.com.conf" in sites-enabled folder
6) Add an entry in the local host's file and this/your domain name as-
sudo vim /etc/hosts
Add below entry(or pur your domain name here)-
127.0.0.1 www.testdomain.com
7) sudo systemctl restart apache2
8) open your browser and type www.testdomain.com
Cheers!!!!!! It's done.
Below is the conf file for the created virtual host for port 80 and 443
<Directory /usr/lib/cgi-bin>
Order allow,deny
Allow from all
Options None
AllowOverride None
</Directory>
CustomLog /var/www/logs/vmsfrontend_log common
ErrorLog /var/www/logs/vmsfrontend_error_log
</VirtualHost>
<VirtualHost *:443>
ReWriteEngine On
ServerAlias www.vmsfrontend.com
ServerName vmsfrontend.com
DocumentRoot /var/www/html/workingdir/keystone_vms_ui
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
#SSLCertificateFile /etc/apache2/ssl/apache.crt
# SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
# SSLCACertificateFile /etc/ssl/certs/apache-selfsigned.crt
<Directory /var/www/html/workingdir/keystone_vms_ui>
Order allow,deny
Allow from all
Options +FollowSymLinks -Indexes
AllowOverride All
</Directory>
</VirtualHost>
Comments
Post a Comment