Cara Set Up Apache Virtual Hosts Di Ubuntu 12.04 LTS


semoga dengan tutorial ini gak bosen atau gak jenuh dari pada sehari – hari kosng waktunya mending di isi dengan tulas-tulis.COM, ok kita mulai langsung aja ke topik utama kita yaitu bagaimana cara se tting virtualhost di apache, saya tidak akan membahas apa itu virtualhost dan apa itu apache karena bukan bagian dari Topik kita hari ini yang saya akan bahas adalah bagaimana cara setup nya berikut step bye step nya:

Install Paket apache nya di ubuntu

# sudo apt-get install apache2

Kalo suda di install buat directory untuk sample virtual host

# sudo mkdir -p /var/www/example.com/public_html 

Setting Permissionnya supaya jadi read write

# sudo chown -R $USER:$USER /var/www/example.com/public_html 

Atau bisa juga dengan ini

# chmod 0755 /var/www/example.com/public_html

Buat file index buat memastikan ada halaman browser nya

sudo nano /var/www/example.com/public_html/index.html

Isi halaman indexnya dengan mengisi contoh content sendiri juga bisa lihat sample

<html>
  <head>
    <title>www.example.com</title>
  </head>
  <body>
    <h1>Success: You Have Set Up a Virtual Host</h1>
  </body>
</html>

 

Buat file configuration untuk virtual histnya

 

# sudo nano /etc/apache2/sites-available/example.com

 

Isi file configurasi nya lihat sample file configurasinya

 

<VirtualHost 192.168.100.212:80>
        <Directory /var/www/example.com/public_html>
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        Allow from all
        </Directory>
        DocumentRoot /var/www/example.com/public_html
        ServerName example.com
        ServerAlias www.example.com
</VirtualHost>

 

Kalo suda untuk memastikan jalan atau tidaknya virtual hostnya bisa di restart service apache2

 

# /etc/init.d/apache2 restart
# /etc/init.d/apache2 restart
 * Restarting web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Fri Apr 19 05:15:26 2013] [warn] NameVirtualHost 192.168.100.212:80 has no VirtualHosts
 ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Fri Apr 19 05:15:27 2013] [warn] NameVirtualHost 192.168.100.212:80 has no VirtualHosts

Error seperti ini karena belome di setting name virtualhostnya sama server namenya configurasi namevirtualhost dan nameserver

# vim port.conf

 

Isi file confgurasinya lihat sample

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz

NameVirtualHost 192.168.100.212:80
ServerName ubuntu.com
Listen 80

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to 
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

Restart lagi apache nya lalu test browsing ke apache server nya

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s