Difference between revisions of "Apache: Virtual Host 2"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) (→Client) |
Onnowpurbo (talk | contribs) |
||
(One intermediate revision by the same user not shown) | |||
Line 6: | Line 6: | ||
==Buat Directory== | ==Buat Directory== | ||
− | sudo mkdir -p / | + | sudo mkdir -p /var/www/html/webmirror/test.ac.id/ |
− | sudo mkdir -p / | + | sudo mkdir -p /var/www/html/webmirror/coba.ac.id/ |
− | sudo chown -Rf nobody: / | + | sudo chown -Rf nobody: /var/www/html/webmirror/test.ac.id/ |
− | sudo chown -Rf nobody: / | + | sudo chown -Rf nobody: /var/www/html/webmirror/coba.ac.id/ |
− | sudo chmod -Rf 755 / | + | sudo chmod -Rf 755 /var/www/html/webmirror/ |
− | sudo chown -Rf nobody: / | + | sudo chown -Rf nobody: /var/www/html/webmirror/ |
==Buat Demo Page== | ==Buat Demo Page== | ||
Line 19: | Line 19: | ||
Edit | Edit | ||
− | vi / | + | vi /var/www/html/webmirror/test.ac.id/index.html |
Isi dengan | Isi dengan | ||
Line 34: | Line 34: | ||
Copy | Copy | ||
− | cp / | + | cp /var/www/html/webmirror/test.ac.id/index.html /var/www/html/webmirror/coba.ac.id/index.html |
Modify jika di perlukan | Modify jika di perlukan | ||
− | vi / | + | vi /var/www/html/webmirror/coba.ac.id/index.html |
<html> | <html> | ||
Line 74: | Line 74: | ||
ServerName test.ac.id | ServerName test.ac.id | ||
ServerAlias www.test.ac.id | ServerAlias www.test.ac.id | ||
− | DocumentRoot / | + | DocumentRoot /var/www/html/webmirror/test.ac.id |
ErrorLog ${APACHE_LOG_DIR}/error.log | ErrorLog ${APACHE_LOG_DIR}/error.log | ||
CustomLog ${APACHE_LOG_DIR}/access.log combined | CustomLog ${APACHE_LOG_DIR}/access.log combined | ||
Line 92: | Line 92: | ||
ServerName coba.ac.id | ServerName coba.ac.id | ||
ServerAlias www.coba.ac.id | ServerAlias www.coba.ac.id | ||
− | DocumentRoot / | + | DocumentRoot /var/www/html/webmirror/coba.ac.id |
ErrorLog ${APACHE_LOG_DIR}/error.log | ErrorLog ${APACHE_LOG_DIR}/error.log | ||
CustomLog ${APACHE_LOG_DIR}/access.log combined | CustomLog ${APACHE_LOG_DIR}/access.log combined | ||
Line 129: | Line 129: | ||
111.111.111.111 www.coba.ac.id | 111.111.111.111 www.coba.ac.id | ||
− | Dimana 111.111.111.111 | + | Dimana |
+ | |||
+ | * 111.111.111.111 IP address server virtual | ||
==Pranala Menarik== | ==Pranala Menarik== |
Latest revision as of 10:49, 11 October 2018
Install
sudo apt update sudo apt install apache2
Buat Directory
sudo mkdir -p /var/www/html/webmirror/test.ac.id/ sudo mkdir -p /var/www/html/webmirror/coba.ac.id/
sudo chown -Rf nobody: /var/www/html/webmirror/test.ac.id/ sudo chown -Rf nobody: /var/www/html/webmirror/coba.ac.id/
sudo chmod -Rf 755 /var/www/html/webmirror/ sudo chown -Rf nobody: /var/www/html/webmirror/
Buat Demo Page
Edit
vi /var/www/html/webmirror/test.ac.id/index.html
Isi dengan
<html> <head> <title>Welcome to test.ac.id!</title> </head> <body>
Success! The test.ac.id virtual host is working!
</body> </html>
Copy
cp /var/www/html/webmirror/test.ac.id/index.html /var/www/html/webmirror/coba.ac.id/index.html
Modify jika di perlukan
vi /var/www/html/webmirror/coba.ac.id/index.html
<html> <head> <title>Welcome to coba.ac.id!</title> </head> <body>
Success! The coba.ac.id virtual host is working!
</body> </html>
Buat Virtual Host
Buat Contekan
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/test.ac.id.conf
Edit
sudo vi /etc/apache2/sites-available/test.ac.id.conf
Aslinya
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Untuk virtualhost
<VirtualHost *:80> ServerAdmin admin@test.ac.id ServerName test.ac.id ServerAlias www.test.ac.id DocumentRoot /var/www/html/webmirror/test.ac.id ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Konfigurasi Apache2
Edit
sudo cp /etc/apache2/sites-available/test.ac.id.conf /etc/apache2/sites-available/coba.ac.id.conf sudo vi /etc/apache2/sites-available/coba.ac.id.conf
Akan tampak
<VirtualHost *:80> ServerAdmin admin@coba.ac.id ServerName coba.ac.id ServerAlias www.coba.ac.id DocumentRoot /var/www/html/webmirror/coba.ac.id ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Enable Virtual Host
Enable
sudo a2ensite test.ac.id.conf sudo a2ensite coba.ac.id.conf
Disable
sudo a2dissite 000-default.conf
Restart
sudo systemctl restart apache2 sudo service apache2 restart sudo service apache2 reload
Client
Edit
sudo vi /etc/hosts
Isi dengan
127.0.0.1 localhost 127.0.1.1 guest-desktop 111.111.111.111 test.ac.id 111.111.111.111 www.test.ac.id 111.111.111.111 coba.ac.id 111.111.111.111 www.coba.ac.id
Dimana
- 111.111.111.111 IP address server virtual