XAMPP adalah paket aplikasi server yang terdiri dari Apache, MariaDB, PHP dan Perl yang ditujukan untuk memudahkan developer dalam PHP development environment.
Dengan XAMPP, developer tidak harus lagi melakukan install aplikasi server satu per satu. *XAMPP sangat tidak disarankan dipakai di production environment* (server operasional).
Di artikel ini dibahas bagaimana cara install XAMPP for Linux 7.x. Teman-teman developer bisa menggunakan distro Linux 64bit apa saja seperti Debian, Ubuntu, Fedora, atau openSUSE. Tutorial ini menggunakan Ubuntu 18.04 LTS dan XAMPP for Linux 7.2.
*Install XAMPP for Linux 7.2*
Nomor versi XAMPP mengikuti nomor versi PHP yang ada di dalamnya, seperti XAMPP 7.2 berisi PHP 7.2.
Isi dari XAMPP 7.2.18:
· Apache 2.4.39 · MariaDB 10.1.40 · PHP 7.2.18 · phpMyAdmin 4.8.5 · OpenSSL 1.1.1 · XAMPP Control Panel 3.2.2 · Webalizer 2.23-04 · Mercury Mail Transport System 4.63 · FileZilla FTP Server 0.9.41 · Tomcat 7.0.92 (with mod_proxy_ajp as connector) · Strawberry Perl 5.16.3.1 Portable
Download XAMPP for Linux.
[INPUT]1 wget -c https://www.apachefriends.org/xampp-files/7.2.18/xampp-linux-x64-7.2.18-1-installer.run
Jalankan XAMPP Linux installer.
[INPUT]1 2 chmod +x xampp-linux*.run sudo ./xampp-linux-*-installer.run
Ditampilkan XAMPP Setup Wizard. Klik Next sampai Finish. XAMPP terinstall di direktori */opt/lampp*. Next.
XAMPP Setup Wizard
Setelah install XAMPP selesai, berjalan aplikasi GUI XAMPP Control. Klik tab *Manage Servers* untuk menjalankan atau menghentikan service Apache, MySQL (MariaDB), dan ProFTPD.
XAMPP Control
Pengujian apakah XAMPP berhasil install dan berjalan dengan baik, browsing *http://localhost*. Jika tampil seperti gambar di bawah ini berarti Apache web server sudah aktif.
XAMPP Dashboard
Browsing *http://localhost/dashboard/phpinfo.php* untuk menguji apakah script PHP bisa dijalankan dengan menampilkan informasi PHP seperti versi dan modul / extension PHP yang ada.
PHP Info
Sementara untuk menguji database MariaDB, browsing *http://localhost/phpmyadmin*.
phpMyAdmin
*Command XAMPP*
Menjalankan aplikasi GUI XAMPP Linux Manager.
[INPUT]1 sudo /opt/lampp/manager-linux-x64.run
Start semua service.
[INPUT]1 2 3 4 5 6 sudo /opt/lampp/lampp start Starting XAMPP for Linux 7.2.18-1… XAMPP: Starting Apache…ok. XAMPP: Starting MySQL…ok. XAMPP: Starting ProFTPD…ok.
Restart semua service.
[INPUT]1 2 3 4 5 6 7 8 9 sudo /opt/lampp/lampp restart Restarting XAMPP for Linux 7.2.18-1… XAMPP: Stopping Apache…ok. XAMPP: Stopping MySQL…ok. XAMPP: Stopping ProFTPD…ok. XAMPP: Starting Apache…ok. XAMPP: Starting MySQL…ok. XAMPP: Starting ProFTPD…ok.
Stop semua service.
[INPUT]1 2 3 4 5 6 sudo /opt/lampp/lampp stop Stopping XAMPP for Linux 7.2.18-1… XAMPP: Stopping Apache…ok. XAMPP: Stopping MySQL…ok. XAMPP: Stopping ProFTPD…ok.
Command XAMPP lainnya.
[INPUT]1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Usage: lampp
*XAMPP Gagal Dijalankan?*
Jika XAMPP gagal dijalankan dengan pesan error *already running*, artinya sebelum install XAMPP sudah ada web server lain yang aktif atau sedang menggunakan nomor port 80 HTTP.
[INPUT]1 2 3 4 5 6 7 sudo /opt/lampp/lampp start Starting XAMPP for Linux 7.2.18-1… XAMPP: Starting Apache…fail. XAMPP: Another web server is already running. XAMPP: Starting MySQL…ok. XAMPP: Starting ProFTPD…ok.
Solusinya non aktifkan service terlebih dahulu web server tersebut sebelum menjalankan XAMPP, misalnya apache2 dan mysql di Ubuntu 18.04 LTS
[INPUT]1 2 3 4 sudo systemctl stop apache2 sudo systemctl disable apache2 sudo systemctl stop mysql sudo systemctl disable mysql
*Direktori dan File Penting*
File konfigurasi XAMPP:
· Apache configuration file: /opt/lampp/etc/httpd.conf, /opt/lampp/etc/extra/httpd-xampp.conf · PHP configuration file: /opt/lampp/etc/php.ini · MySQL configuration file: /opt/lampp/etc/my.cnf · ProFTPD configuration file: /opt/lampp/etc/proftpd.conf
Direktori penting XAMPP:
· Direktori Document Root: /opt/lampp/htdocs · Direktori database: /opt/lampp/var/mysql · Direktori konfigurasi: /opt/lampp/etc
Direktori htdocs dimiliki oleh root dan hanya bisa dimodifikasi (tambah, ubah, hapus) oleh root. Agar lebih mudah mengakses dan memodifikasi direktori dalam htdocs untuk project website, direktori project website harus diubah kepemilikannya dari root menjadi user yang kita gunakan.
[INPUT]1 2 3 cd /opt/lampp/htdocs sudo mkdir webku.com sudo chown $USER.$USER webku.com
*Konfigurasi Virtual Hosts*
Secara default untuk mengakses project website yang berada di direktori webku.com, kita browsing *http://localhost/webku.com*.
http://localhost/webku.com
URL akses tersebut bisa diubah menjadi *http://webku.com* dengan cara melakukan konfigurasi Virtual Hosts Apache dan file hosts di system.
Buka file konfigurasi Apache httpd.conf.
[INPUT]1 sudo gedit /opt/lampp/etc/httpd.conf
Cari *# Virtual hosts*, lalu lepas tanda komentar # di baris opsi *httpd-vhosts.conf*.
[INPUT]1 2 # Virtual hosts Include etc/extra/httpd-vhosts.conf
Apache httpd.conf – virtual hosts
Selanjutnya buka file konfigurasi virtual hosts httpd-vhosts.conf.
[INPUT]1 sudo gedit /opt/lampp/etc/extra/httpd-vhosts.conf
Menuju ke baris paling bawah, terdapat 2 contoh konfigurasi virtual hosts, hapus saja. Tambahkan konfigurasi virtual host untuk webku.com dan localhost.
[INPUT]1 2 3 4 5 6 7 8 9 10 11 12 13
httpd-vhosts.conf
Kemudian selanjutnya buka file /etc/hosts untuk memasukkan servername webku.com.
[INPUT]1 sudo gedit /etc/hosts
Tambahkan.
[INPUT]1 127.0.0.1 webku.com
hosts
Reload apache.
[INPUT]1 2 3 sudo /opt/lampp/lampp reloadapache XAMPP: Reload Apache…ok.
Terakhir pengujian akses, browsing http://webku.com.
http://webku.com
*Keamanan XAMPP*
Secara default XAMPP tidak ada password. Kita dapat memberikan passsword dengan mudah melalui command security.
[INPUT]1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 sudo /opt/lampp/lampp security XAMPP: Quick security check… XAMPP: MySQL is accessable via network. XAMPP: Normaly that’s not recommended. Do you want me to turn it off? [yes] yes XAMPP: Turned off. XAMPP: Stopping MySQL…ok. XAMPP: Starting MySQL…ok. XAMPP: The MySQL/phpMyAdmin user pma has no password set!!! XAMPP: Do you want to set a password? [yes] yes XAMPP: Password: XAMPP: Password (again): XAMPP: Setting new MySQL pma password. XAMPP: Setting phpMyAdmin’s pma password to the new one. XAMPP: MySQL has no root passwort set!!! XAMPP: Do you want to set a password? [yes] yes XAMPP: Write the password somewhere down to make sure you won’t forget it!!! XAMPP: Password: XAMPP: Password (again): XAMPP: Setting new MySQL root password. XAMPP: Change phpMyAdmin’s authentication method. XAMPP: The FTP password for user ‘daemon’ is still set to ‘xampp’. XAMPP: Do you want to change the password? [yes] yes XAMPP: Password: XAMPP: Password (again): XAMPP: Reload ProFTPD…ok. XAMPP: Done.
Selamat mencoba ð