Create Subdomain via vhost on Debian

semisalnya kita membuat sebuah domain.com dan masih bisa kita tambahkan lagi sub-domain dari domain utama tersebut, sehingga kita akan lebih hemat dalam menggunakan ip address dan juga domain. Jika anda menggunakan hostingan hal tersebut tidaklah sulit karena anda dapat melakukannya menggunakan Cpanel. Bagaimana kalau seandainya anda menggunakan VPS?.
Pada artikel ini kita akan membahas bagaimana membuat sub-domain menggunakan vhost pada server debian.
1. Buatlah sebuah direktori untuk subdomain tersebut.
kita asumsikan kalau subdomain akan berada didalam direktori html dengan nama "subdomain"
ex :
mkdir /var/www/html/subdomain
2.  Konfigurasi Virtualhost
masukan perintah ini di terminal
3. Pindah directory
cd /etc/apache2/sites-available
4. masukan perintah berikut 
cp 000-default.conf subdomain.conf
5. edit file subdomain.conf
nano subdomain.conf
<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
ServerAdmin xmoensen@gmail.com
ServerName domain.com
ServerAlias subdomain.domain.com
DocumentRoot /var/www/html/subdomain

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/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>


keterangan :
ServerAdmin = alamat email pemilik domain
ServerName = nama domain utama, ex : domain.com
ServerAlias = nama subdomain yang ingin di ahlikan. ex : subdomain.domain.com
DocumentRoot= tempat/ directory pengalihan dari virtual alias yang sudah dibuat.
6. aktifkan site tersebut
code :
a2ensite subdomain.conf
7. restart apache2
code 
/etc/init.d/apache2 restart 
 8. testing dengan browser dengan akses nama subdomain yang sudah dibuat tadi.

Berikan Komentar yang bermanfaat dan sehat.

Posting Komentar (0)
Lebih baru Lebih lama