Searching...
Minggu, 04 September 2022

Install LAMPP Stack di Ubuntu Server 20.04

September 04, 2022

 



Tahapan Install LAMPP Stack di Ubuntu Server 20.04:

1. Update Software Package

 sudo apt update  
 sudo apt upgrade  

========================================================

2. Install Apache Web Server

 sudo apt install -y apache2 apache2-utils  

Periksa status Service Apache

 systemctl status apache2  

Contoh Output:

 * apache2.service - The Apache HTTP Server  
    Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor prese>  
    Active: active (running) since Mon 2021-03-01 02:05:04 UTC; 18s ago  
     Docs: https://httpd.apache.org/docs/2.4/  
   Main PID: 15430 (apache2)  
    Tasks: 27 (limit: 4915)  
    Memory: 4.3M  
    CGroup: /system.slice/apache2.service  
        |-15430 /usr/sbin/apache2 -k start  
        |-15433 /usr/sbin/apache2 -k start  
        `-15434 /usr/sbin/apache2 -k start  

Jika service belum running, jalankan dengan perintah:

 sudo systemctl start apache2  

Buat agar Apache dijalankan pada saat Server dinyalakan (Boot):

 sudo systemctl enable apache2  

Cek versi Apache:

 apache2 -v  
Server version: Apache/2.4.41 (Ubuntu)
Server built:   2020-08-12T19:46:17

Jika Connection Refused:

 sudo iptables -I INPUT -p tcp --dport 80 -j ACCEPT  

Atau

 sudo ufw allow http  

Atau bila diperlukan, matikan firewall

 systemctl stop ufw

Set kepemilikan direktori web root (www-data) yang secara default merupakan kepemilikan user root, dirubah menjadi kepemilikan user apache:

 sudo chown www-data:www-data /var/www/html/ -R  

 Periksa konfigurasi apache:

 sudo apache2ctl -t   

Jika ada error seperti ini:

 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message  

Buat file konfigurasi dengan perintah ini:

 sudo nano /etc/apache2/conf-available/servername.conf  

Tambahkan pada file tersebut, parameter:

 ServerName localhost  

Lalu Enable file konfigurasi tersebut:

 sudo a2enconf servername.conf  

Restart / Reload apache:

 sudo systemctl reload apache2  

Periksa kembali konfigurasi apache:

 sudo apache2ctl -t   

Seharusnya sudah tidak ada error lagi.

Akses server dari jaringan lokal ke url: http://ip-server-anda/



========================================================

3. Install Database MariaDB

 sudo apt install mariadb-server mariadb-client  

Periksa status service Mariadb:

 sudo systemctl status mariadb  

Jika belum jalan, jalankan dengan perintah:

 sudo systemctl start mariadb  

Buat agar MariaDB jalan pada saat Boot:

 sudo systemctl enable mariadb  

Jalankan Post-Installation security script:

 sudo mysql_secure_installation  

Buat password untuk root nya, selebihnya tekan Y saja (atau tekan ENTER) atau menyesuaikan.

Cek Versi MariaDB:

 mariadb --version

Output:

 mariadb Ver 15.1 Distrib 10.3.25-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2  

========================================================

4. Install PHP7.4

 sudo apt install php7.4 libapache2-mod-php7.4 php7.4-mysql php-common php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline  

Enable modul Apache-php7.4, lalu restart service apache:

 sudo a2enmod php7.4  
 sudo systemctl restart apache2

Periksa Versi PHP:

 php --version  

Output:

 PHP 7.4.3 (cli) (built: Oct 6 2020 15:47:56) ( NTS )  
 Copyright (c) The PHP Group  
 Zend Engine v3.4.0, Copyright (c) Zend Technologies  
   with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies  

Untuk mengetahui versi php, buat file info.php di dalam web root direktori.

 sudo nano /var/www/html/info.php  

Tambahkan baris kode ini pada file tersebut:

 <?php phpinfo(); ?>  

Simpan perubahan, lalu akses melalui browser ke alamat: http://ip-server-anda/info.php



5. Install PHP-FPM (Fast CGI)

Ini adalah alternatif penggunaan PHP7.4, Jika menggunakan PHP-FPM, maka PHP7.4 harus di disable terlebih dahulu.

 sudo a2dismod php7.4  

Lalu install PHP-FPM

 sudo apt install php7.4-fpm  

Enable proxy_fcgi  dan modul setenvif

 sudo a2enmod proxy_fcgi setenvif  

Enable konfigurasi file /etc/apache2/conf-available/php7.4-fpm.conf 

 sudo a2enconf php7.4-fpm  

Restart apache

 sudo systemctl restart apache2  

Akses kembali info.php untuk memeriksa perubahan php dibrowser (refresh).



Jika sudah tidak diperlukan, kita bisa menghapus kembali file info.php untuk alasan keamanan.

Demikianlah cara instalasi LAMPP (Linux Apache MariaDB PHP) di Linux Ubuntu Server 20.04.

0 komentar:

Posting Komentar