Konfigurasi Virtual Host pada Ubuntu Server 16.04 LTS


 Anggap anda telah pun mempunyai konfigurasi asas berikut:
1. Ubuntu 16.04 LTS
2. Apache2

Langkah berikut adalah secara arahan sahaja:

1. sudo mkdir -p /var/www/apaapa.com/public_html 
2. sudo touch /var/www/apapa.com/public_html/index.html  
3. sudo chmod -Rv 755 /var/www/apaapa.com/ 
4. sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/site-available/apaapa.com.conf 
5. sudo nano /etc/apache2/site-available/apaapa.com.conf

  1. <VirtualHost *:80>
    ServerName apaapa.com
    ServerAlias www.apaapa.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/apapa.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>

6. sudo a2ensite apapa.com.conf 
7. sudo service apache2 restart 
8. sudo nano /etc/apache2/apache2.conf

  1. <Directory /var/www/apaapa.com/public_html>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>

9. sudo service apache2 restart

Selesai semua konfigurasi.

Jika lengkap menggunakan semua arahan yang disenaraikan sepatutnya Virtual Host anda berfungsi dengan baik. Kaedah ini tidak termasuk langkah konfigurasi NameServer.

0 comments:

Post a Comment

My Instagram