Pastikan untuk meng-update source list mirror anda.
Step 1
Install apache dengan command :
#apt-get install apache2
Step 2
Buat direktori yang akan menampung letak root dari web yang dibuat
sudo mkdir -p /var/www/example.com/public_html
sudo mkdir -p /var/www/example.org/public_html
Step 3
Beri akses pada file agar bisa di baca oleh user lain
sudo chmod -R 755 /var/www
Step 4
Buat file .html agar bisa di test baik di .com maupun di .org
sudo nano /var/www/example.com/public_html/index.html
Step 5
Isi file .html
<html>
<head>
<title>www.example.com</title>
</head>
<body> <h1>Success: You Have Set Up a Virtual Host</h1> </body> </html>
Step 6Edit file virtual host
sudo nano /etc/apache2/sites-available/default
Tambahkan kode dibawah baris <VirtualHost># <VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName www.example.com
ServerAlias example.com
# Indexes + Directory Root.
DirectoryIndex index.html
DocumentRoot /var/www/example.com/public_html/
# CGI Directory apabila ingin menggunakan CGI
# ScriptAlias /cgi-bin/ /var/www/example.com/public_html/cgi-bin/
# <Location /cgi-bin>
# Options +ExecCGI
# </Location>
# Logfiles apabila ingin menggunakan log
# ErrorLog /var/www/example.com/public_html/logs/error.log
# CustomLog /var/www/example.com/public_html/logs/access.log combined
</VirtualHost>
# <VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName www.example.com
ServerAlias example.com
# Indexes + Directory Root.
DirectoryIndex index.html
DocumentRoot /var/www/example.org/public_html/
# CGI Directory apabila ingin menggunakan CGI
# ScriptAlias /cgi-bin/ /var/www/example.org/public_html/cgi-bin/
# <Location /cgi-bin>
# Options +ExecCGI
# </Location>
# Logfiles apabila ingin menggunakan log
# ErrorLog /var/www/example.org/public_html/logs/error.log
# CustomLog /var/www/example.org/public_html/logs/access.log combined
</VirtualHost>
Sesuaikan parameter didalamnya
Step 7 Restart service apache
sudo service apache2 restart
Step 8
Tambahkan domain pada daftar host
nano /etc/hosts
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
#
#
127.0.0.1 localhost
#Virtual Hosts
12.34.56.789 example.com
12.34.56.789 example.org
No comments:
Post a Comment