Difference between revisions of "Apache: Virtual Host 2"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) |
Onnowpurbo (talk | contribs) |
||
Line 53: | Line 53: | ||
Buat Contekan | Buat Contekan | ||
− | sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/ | + | sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/test.ac.id.conf |
Edit | Edit | ||
− | sudo | + | sudo vi /etc/apache2/sites-available/test.ac.id.conf |
Aslinya | Aslinya | ||
Line 71: | Line 71: | ||
<VirtualHost *:80> | <VirtualHost *:80> | ||
− | ServerAdmin admin@ | + | ServerAdmin admin@test.ac.id |
− | ServerName | + | ServerName test.ac.id |
− | ServerAlias www. | + | ServerAlias www.test.ac.id |
− | DocumentRoot / | + | DocumentRoot /usr/local/src/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 |
Revision as of 10:37, 11 October 2018
Install
sudo apt update sudo apt install apache2
Buat Directory
sudo mkdir -p /usr/local/src/webmirror/test.ac.id/ sudo mkdir -p /usr/local/src/webmirror/coba.ac.id/
sudo chown -Rf nobody: /usr/local/src/webmirror/test.ac.id/ sudo chown -Rf nobody: /usr/local/src/webmirror/coba.ac.id/
sudo chmod -Rf 755 /usr/local/src/webmirror/ sudo chown -Rf nobody: /usr/local/src/webmirror/
Buat Demo Page
Edit
vi /usr/local/src/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 /usr/local/src/webmirror/test.ac.id/index.html /usr/local/src/webmirror/coba.ac.id/index.html
Modify jika di perlukan
vi /usr/local/src/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 /usr/local/src/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/example.com.conf /etc/apache2/sites-available/test.com.conf sudo nano /etc/apache2/sites-available/test.com.conf
Akan tampak
<VirtualHost *:80> ServerAdmin admin@test.com ServerName test.com ServerAlias www.test.com DocumentRoot /var/www/test.com/public_html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Enable Virtual Host
Enable
sudo a2ensite example.com.conf sudo a2ensite test.com.conf
Disable
sudo a2dissite 000-default.conf
Restart
sudo systemctl restart apache2 sudo service apache2 restart
Client
Edit
sudo nano /etc/hosts
Isi dengan
127.0.0.1 localhost 127.0.1.1 guest-desktop 111.111.111.111 example.com 111.111.111.111 test.com