Mẫu File vhost dùng cho apache

  Lập Trình

Đây là mẫu file vhost cơ bản nhất dùng cho apache

Khối HTTP

<VirtualHost *:80>
    ServerAdmin khoi@wiki.mkbentre.com
    DocumentRoot "/home/ubuntu/demo"
    ServerName demo.com
    ErrorLog "/home/pi/logs/wiki-error.log"
    CustomLog "/home/pi/logs/wiki-access.log" common
    <Directory "/home/ubuntu/demo">
        Options FollowSymLinks
        AllowOverride All
        DirectoryIndex index.php
        Require all granted
    </Directory>
</VirtualHost>

Khối HTTPS

<VirtualHost *:443>
	 ServerAdmin khoi@wiki.mkbentre.com               
	 DocumentRoot "/home/ubuntu/demo"
	 ServerName demo.com
	 ErrorLog "/home/ubuntu/logs/demo-error.log"
	 SSLEngine on
	 SSLProtocol all
	 SSLCertificateFile "/etc/ssl/demo.com/certificate.crt"
	 SSLCertificateKeyFile "/etc/ssl/demo.com/private.key"
	 SSLCACertificateFile "/etc/ssl/demo.com/ca_bundle.crt"
	 <Directory "/home/ubuntu/demo">
        Options FollowSymLinks
        AllowOverride All
        DirectoryIndex index.php
        Require all granted
    </Directory>
</VirtualHost>