This page looks best with JavaScript enabled

Cara Install dan Setting XAMPP di Linux

 ·  ☕ 6 min read  ·  ✍️ anz007

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. Jadi 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 Linux Mint 19.1 dan XAMPP for Linux 7.3.8.

Install XAMPP for Linux 7.3

Nomor versi XAMPP mengikuti nomor versi PHP yang ada di dalamnya, seperti XAMPP 7.3 berisi PHP 7.3.

Isi dari XAMPP 7.3.8:

  • Apache 2.4.39
  • MariaDB 10.4.6
  • PHP 7.3.8 + SQLite 2.8.17/3.29.0. + multibyte (mbstring) support
  • Perl 5.16.3
  • ProFTPD 1.3.6
  • phpMyAdmin 4.9.0.1
  • OpenSSL 1.0.2s
  • Webalizer 2.23-05
  • IMAP C-Client 2007e
  • OpenLDAP (client) 2.4.21
  • cUrl 7.45.0

Download XAMPP for Linux.
wget -c https://www.apachefriends.org/xampp-files/7.3.8/xampp-linux-x64-7.3.8-2-installer.run

Jalankan XAMPP Linux installer.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.

Gambar 1

Setelah install XAMPP selesai, berjalan aplikasi GUI XAMPP Control. Klik tab Manage Servers untuk menjalankan atau menghentikan service Apache, MySQL (MariaDB), dan ProFTPD.

Gambar 2

Pengujian apakah XAMPP berhasil install dan berjalan dengan baik, browsing **http://localhost**atau http://127.0.0.1. Jika tampil seperti gambar di bawah ini berarti Apache web server sudah aktif.

Gambar 3

Browsing http://localhost/dashboard/phpinfo.php atau http://127.0.0.1/dashboard/phpinfo.php untuk menguji apakah script PHP bisa dijalankan dengan menampilkan informasi PHP seperti versi dan modul / extension PHP yang ada.

Gambar 4

Sementara untuk menguji database MariaDB, browsing **http://localhost/phpmyadmin**atau http://127.0.0.1/phpmyadmin.

Gambar 5

Command XAMPP

Menjalankan aplikasi GUI XAMPP Linux Manager.

1
sudo /opt/lampp/manager-linux-x64.run

Start semua service.

1
2
3
4
5
6
sudo /opt/lampp/lampp start 

Starting XAMPP for Linux 7.3.8-2... 
XAMPP: Starting Apache...ok. 
XAMPP: Starting MySQL...ok. 
XAMPP: Starting ProFTPD...ok.

Restart semua service.

1
2
3
4
5
6
7
8
9
sudo /opt/lampp/lampp restart 

Restarting XAMPP for Linux 7.3.8-2... 
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.

1
2
3
4
5
6
sudo /opt/lampp/lampp stop

Stopping XAMPP for Linux 7.3.8-2...
XAMPP: Stopping Apache...ok.
XAMPP: Stopping MySQL...ok.
XAMPP: Stopping ProFTPD...ok.

Command XAMPP lainnya.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
Usage: 
lampp <action> start         Start XAMPP (Apache, MySQL and eventually others) startapache   Start only Apache 
startmysql    Start only MySQL 
startftp      Start only ProFTPD 
stop          Stop XAMPP (Apache, MySQL and eventually others) 
stopapache    Stop only Apache 
stopmysql     Stop only MySQL 
stopftp       Stop only ProFTPD 
reload        Reload XAMPP (Apache, MySQL and eventually others) 
reloadapache  Reload only Apache 
reloadmysql   Reload only MySQL 
reloadftp     Reload only ProFTPD 
restart       Stop and start XAMPP 
security      Check XAMPP`s security 
enablessl     Enable SSL support for Apache 
disablessl    Disable SSL support for Apache 
backup        Make backup file of your XAMPP config, log and data files oci8          Enable the oci8 extenssion 
panel         Starts graphical XAMPP control panel

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.

1
2
3
4
5
6
7
sudo /opt/lampp/lampp start 

Starting XAMPP for Linux 7.3.8-2... 
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 yang memakai port tersebut sebelum menjalankan XAMPP, misalnya apache2 dan mysql

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.

1
2
3
cd /opt/lampp/htdocs 
sudo mkdir webku.com 
sudo chown $USER:$USER webku.com

ganti $USER dengan user yang kita gunakan.

Konfigurasi Shortcut

Saat instalasi xampp di linux, shortcut di menu tidak terpasang secara otomatis. Sehingga untuk menjalankan xampp kita harus menggunakan terminal yang tentu saja tidak praktis. Akan lebih praktis jika menjalankanya lewat shortcut di menu.

Gambar 6-1

  1. Masuk ke folder /usr/local/share sebagai root
  2. Buat file baru
  3. Buka file tersebut denga text editor (gedit, LeafPad, Notepad, dll)
  4. Tuliskan code dibawah ini:

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=/opt/lampp/htdocs/favicon.ico
Name[en_US]=XAMPP
Exec=gksu /opt/lampp/manager-linux-x64.run
Comment[en_US]=Start XAMPP Control Panel
Name=XAMPP
Comment=Start XAMPP Control Panel
Icon=/opt/lampp/htdocs/favicon.ico
Categories=Application;Development

  1. Save dan beri nama file tersebut dengan Xampp.desktop
  2. Sekarang shortcut xampp sudah muncul di menu

Gambar 7

Konfigurasi Virtual Hosts

Secara default untuk mengakses project website yang berada di direktori webku.com, kita browsing http://localhost/webku.com.

Gambar 8

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.
sudo gedit /opt/lampp/etc/httpd.conf

Cari # Virtual hosts, lalu lepas tanda komentar # di baris opsi httpd-vhosts.conf.

1
2
3
# Virtual hosts 

Include etc/extra/httpd-vhosts.conf

Gambar 9

Selanjutnya buka file konfigurasi virtual hosts httpd-vhosts.conf.
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.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
<VirtualHost *:80>     

ServerName localhost    
DocumentRoot /opt/lampp/htdocs
ErrorLog "logs/localhost.error.log"
CustomLog "logs/localhost.access.log" common 

</VirtualHost> 
<VirtualHost *:80>     

ServerName webku.com     
DocumentRoot /opt/lampp/htdocs/webku.com     
ErrorLog "logs/webku.com.error.log"     
CustomLog "logs/webku.com.access.log" common 

</VirtualHost>

Gambar 10

Kemudian selanjutnya buka file /etc/hosts untuk memasukkan servername webku.com.
sudo gedit /etc/hosts

Tambahkan.
127.0.0.1 webku.com

Gambar 11

Reload apache.

1
2
3
sudo /opt/lampp/lampp reloadapache 

XAMPP: Reload Apache...ok.

Terakhir pengujian akses, browsing http://webku.com.
Gambar 12

Keamanan XAMPP

Secara default XAMPP tidak ada password. Kita dapat memberikan passsword dengan mudah melalui command security.

 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.

Sumber :

  1. musaamin.web.id
  2. mrdoank.blogspot.com
Share on