GNU/Linux >> Belajar Linux >  >> Ubuntu

Cara Menginstal Apache di Ubuntu 14.04

Dalam tutorial ini, kami akan menunjukkan kepada Anda cara menginstal Apache di Ubuntu 14.04. Bagi Anda yang belum tahu, Apache adalah server web HTTP, yang paling populer digunakan. menyajikan halaman web saat diminta oleh browser web. Saat Anda mengetik URL di server web dan menekan Enter, halaman yang Anda lihat di layar kemungkinan besar dilayani oleh server web Apache.

Artikel ini mengasumsikan Anda memiliki setidaknya pengetahuan dasar tentang Linux, tahu cara menggunakan shell, dan yang terpenting, Anda meng-host situs Anda di VPS Anda sendiri. Instalasinya cukup sederhana. Saya akan menunjukkan kepada Anda langkah demi langkah instalasi Apache di server Ubuntu 14.04.

Instal Apache di Ubuntu 14.04

Langkah 1. Pertama-tama, pastikan semua paket sudah diperbarui.

apt-get update
apt-get upgrade

Langkah 2. Menginstal server web Apache di Ubuntu 14.04.

Kami akan menginstal Apache dengan apt-get, yang merupakan manajer paket default untuk ubuntu:

apt-get install apache2 apache2-utils

Mulai Apache dan tambahkan untuk memulai secara otomatis pada sistem Anda start-up menggunakan:

service apache2 start

Anda dapat memverifikasi bahwa Apache benar-benar berjalan dengan membuka browser web favorit Anda dan memasukkan URL http://your-server's-address , jika sudah terinstal, maka Anda akan melihat ini:

Konfigurasi Apache (Host Tunggal)

Sekarang kita akan mengonfigurasi Apache dengan membuka file konfigurasi utama dan mengedit baris ServerName dan  ServerAdmin yang sesuai:

nano /etc/apache2/sites-available/000-default.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 webmaster@localhost
        DocumentRoot /var/www/html
        # 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>

Sekarang, kita dapat me-restart Apache agar perubahan terjadi:

service apache2 restart

Sekarang Anda dapat membuat/mengunggah konten web Anda ke direktori HTML Apache. (Ingatlah untuk mengganti file index.html yang ada dengan index.html Anda halaman beranda).

Konfigurasi Apache (Multi-Host)

Jika Anda ingin meng-host beberapa situs web, lanjutkan dengan membuka file konfigurasi utama, salin entri Virtual Host yang ada dan tempel di bawahnya. Kemudian edit ServerName, ServerAdmin, dan  baris DocumentRoot yang sesuai.

nano /etc/apache2/sites-available/000-default.conf

Atau, Anda cukup menyalin entri berikut dan mengeditnya:

    <VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/site1
    ServerName site1.com
    ServerAlias www.site1.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    <VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/site2
    ServerName site2.com
    ServerAlias www.site2.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>

Sekarang kita harus membuat direktori untuk situs yang baru saja dikonfigurasi, site1 dan site2.

mkdir -p /var/www/site1
mkdir -p /var/www/site2

Sekarang, kita dapat me-restart Apache agar perubahan terjadi:

service apache2 restart

Selamat! Anda telah berhasil menginstal Apache. Terima kasih telah menggunakan tutorial ini untuk menginstal server web Apache di sistem Ubuntu 14.04. Untuk bantuan tambahan atau informasi berguna, kami sarankan Anda memeriksa situs web resmi Apache.


Ubuntu
  1. Cara Menginstal Apache di Ubuntu 18.04

  2. Cara Menginstal Apache Sqoop di Ubuntu 16.04

  3. Bagaimana cara menginstal Apache di Ubuntu?

  1. Cara menginstal Apache di Ubuntu 20.04

  2. Cara Menginstal Apache Maven di Ubuntu 18.04

  3. Cara Menginstal Apache Cassandra di Ubuntu 18.04

  1. Cara Menginstal Apache Cassandra di Ubuntu 20.04

  2. Cara Menginstal Apache Solr di Ubuntu 20.04

  3. Cara Menginstal Apache Tomcat 10 Di Ubuntu 20.04 / Ubuntu 18.04