Alhamdulillah Bersyukur Kepada Allah yang telah memberi kita semuanya

imam's posts with tag: apache

What are tags? You can give your posts a "tag", which is like a keyword. Tags help you find content which has something in common. You can assign as many tags as you wish to each post.
View posts by people in your network with tag apache
Blog EntryApache virtual host untuk virtual domain hostingMay 13, '08 1:47 PM
for everyone
Apache virtual host untuk virtual domain hosting

Pada sebuah environtment virtual domain hosting yang menggunakan apache sebagai webservernya
selain kita mengkonfigurasi name server (aka bind) kita juga perlu setting virtual host
pada apache agar redirect (request domain) yang dilempar dari bind dan kemudian diteruskan
ke apache server port 80 akan diarahkan ke virtual domain/path yang sesuai untuk account/domain
tersebut yang dimaksud.  Sebenarnya selanjutnya  solusi yang tepat adalah menggunakan
semacam DLZ tetapi pada apache agar tidak perlu restart ulang apache bila menambahkan
virtual hosting baru.  Tetapi baiklah untuk tahap belajar pertama kita set dulu virtual
host pada apache2. Berikut adalah langkah teknis membuat virtual hosting pada apache 2 :



1. Buat direktori (folder) khusus untuk menyimpan file2 data hostingan client
   dan tempat upload data sesuai dengan acccount masing masing, contohnya
   untuk 2 buah client dibuat sebagai berikut:

   # buat grup utama
   groupadd client

   # buat user dan folder stuktur untuk client1
   
   mkdir -p /home/vhost/client1/www
   mkdir -p /home/vhost/client1/logs
   mkdir -p /home/vhost/client1/cgi-bin
   useradd client1 -g client -d /home/vhost/client1/
   passwd client1
   chown client1.client -R  /home/vhost/client1


   # buat user dan folder stuktur untuk client2
  
   mkdir -p /home/vhost/client2/www
   mkdir -p /home/vhost/client2/logs
   mkdir -p /home/vhost/client2/cgi-bin
   useradd client2 -g client -d /home/vhost/client2/
   passwd client2
   chown client2.client -R  /home/vhost/client2


2. Tambahkan domain untuk account user tersebut ke dalam record database DNS
   seperti contoh pada posting sebelumnya tentang DLZ domain


3. Pointing domain name (virtual host) pada apache

   mkdir /home/vhost-conf/  
   mc -e /etc/httpd/httpd.conf

   # tambahkan include pada httpd.conf agar meload
   # semua *.conf pada folder  /home/vhost-conf

   ### Use name-based virtual hosting.
   DirectoryIndex index.html index.htm index.php
   NameVirtualHost *:80
   NameVirtualHost *:443
   Include /home/vhost-conf/*.conf
   LoadModule ssl_module lib/httpd/modules/mod_ssl.so

4. mengaktifkan ssl
(http://slacksite.com/apache/certificate.php )

mkdir /etc/httpd/ssl
cd /etc/httpd/ssl
openssl genrsa -des3 -rand file1:file2:file3:file4:file5 -out server.key 1024
openssl rsa -in server.key -out server.pem
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 60 -in server.csr -signkey server.key -out server.crt


5. konfigurasi untuk vhost untuk client 1

   mc -e /home/vhost-conf/client1.conf

   #paste kode berikut pada client1.conf

   <VirtualHost *:80>
    ServerAdmin client1@client1-domain1.com
    DocumentRoot /home/vhost/client1/www/
    ServerName client1-domain1.com
    ServerAlias client1-domain1.com *.client1-domain1.com
    ErrorLog /home/vhost/client2/logs/client1-domain1.com-error_log
    CustomLog /home/vhost/client2/logs/client1-domain1.com-access_log common
    ErrorDocument 403 /403.html
        ErrorDocument 404 /404.html
        <Directory "/home/vhost/client1/www/">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
        </Directory>
    ScriptAlias /cgi-bin/ "/home/vhost/client1/cgi-bin"
    <Directory "/home/vhost/client1/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>
   </VirtualHost>  
   <VirtualHost *:443>
        ServerName client1-domain1.com
        DocumentRoot /home/vhost/client1/www/
        CustomLog /home/vhost/client2/logs/client1-domain1.com-ssl-access.log combined
        ErrorLog /home/vhost/client2/logs/client1-domain1.com-ssl-error.log
        SSLEngine on
    SSLCertificateFile /etc/httpd/ssl/server.crt
    SSLCertificateKeyFile /etc/httpd/ssl/server.pem
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
   </VirtualHost>


   #ubah permision client1.conf
   chown client1.client /home/vhost-conf/client1.conf


6.  ulangi step 4 pada untuk client-client lainnya

7.  restart apache
killall httpd
/etc/rc.d/rc.httpd restart

© 2008 Multiply, Inc.    About · Blog · Terms · Privacy · Corp Info · Contact Us · Help