Enable Disable VHost di Apache2

Apache kini sudah mencapai versi 2.4, dimana semua fitur nya cukup berubah. Terutama dalam hal virtual host. Baca Selengkapnya!
2137  
       

Apache merupakan webserver terlaris, hampir semua penyedia hosting menghadirkan apache sebagai web servernya. Apache kini sudah mencapai versi 2.4, dimana semua fitur nya cukup berubah. Terutama dalam hal virtual host (VHOST). Nah, ada apa saja yang baru disini? mari kita lihat selengkapnya.

 

Pengaturan Umum Apache2

Apache2 tersedia diberbagai distro *nix, seperti ubuntu, centos, dan sebagainya. Seperti biasa, pengaturan configurasi VHOST terletak di /etc/apache2/ semua konfigurasi ada disana. Ada yang baru disini, disini ada 2 folder untuk vhost. Yaitu site-available dan sites-enabled.

Menambahkan VHOST

Untuk menambahkan VHOST, di apache2 cukup dengan mengedit file baru didalamnya. Adapun folder tersebut adalah sites-available. Folder sites-avaiable adalah isi dari semua situs web / vhost yang akan digunakan.

Template VHOST

Adapun template untuk VHOST untuk apache2 sebagai berikut:


<Directory /home/ec2-user/sites/nyingspot.com/public_html>
    Require all granted
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
</Directory>

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerName nyingspot.com
        ServerAlias www.nyingspot.com
        ServerAdmin nyingspot@gmail.com
        DocumentRoot /home/ec2-user/sites/nyingspot.com/public_html    


        <FilesMatch \.php$>
         SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost"
        </FilesMatch>

        ErrorLog /home/ec2-user/logs/nyingspot.com/error.log
        CustomLog /home/ec2-user/logs/nyingspot.com/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

 

Penamaan File VHOST

Untuk memudahkan kita dalam menggunakan fungsi a2ensite maupun a2dissite, biasakan nama filenya itu nama hostname.tld nya, sehingga bisa berjalan mulus. Adapun contoh penamaanya antara lain:

blog.travtou.com.conf
nyingspot.com.conf
cirengeasy.com-ssl.conf

 

fungsi a2ensite dan a2dissite

Fungsi a2ensite merupakan fungsi bawaan dari apache2, dimana untuk mengaktifkan vhost, cukup dengan menjalankan perintah tersebut dengan diikut nama host atau nama file konfigurasinya. contoh

#harus root
a2ensite nama.config.conf
a2ensite nyingspot.com
#
#sesudah gitu, barulah direstart service nya
service apache2 restart

 
Sementara untuk a2dissite sama saja, hanya yang membedakan perintah awalnya aja. Adapun contohnya sebagai berikut:

#harus root
a2dissite nama.config.conf
a2dissite nyingspot.com
#
#sesudah gitu, barulah direstart service nya
service apache2 restart

 
Demikian. Semoga Membantu.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>