Bagi orang awam, penggunaan Graphic User Interface (GUI) akan lebih nyaman dibanding Command Line Interface (CLI) yang terdiri dari susunan coding, termasuk ketika mengelola database. Sebab, ketika mengelola database, kamu harus mampu menghafal commands. Tapi, kini phpMyAdmin bisa membantumu. Pelajari cara install phpMyAdmin dengan Apache di Debian 10 pada artikel ini.
Apa Itu phpMyAdmin?
Penjelasan sekilas tentang apa itu phpMyAdmin, yaitu sebuah software gratis berbasis scripting language PHP yang bertujuan untuk memudahkan pengelolaan database MySQL. Software ini juga mendukung beberapa operasional database, seperti MariaDB, MySQL dan Drizzle.
Alhasil, kamu bisa mengelola database, columns, tables, indexes, users, dan masih banyak lagi fitur yang dapat kamu kelola. Di saat yang sama, kamu juga bisa meng-execute SQL statement apapun dari phpMyAdmin secara langsung.
Baca Juga: SQL: Pengertian, Fungsi Beserta Perintah Dasarnya
Cara Install phpMyAdmin dengan Apache di Debian 10
Ada beberapa hal yang perlu disiapkan untuk meng-install phpMyAdmin di Debian 10:
Kemudian, berikut ini adalah beberapa poin tutorial yang akan kita lakukan:
- Update Server
- Install Packages
- Install Firewall
- Install Apache Web Server
- Install PHP 7.2 & PHP-FPM
- Configure PHP.ini
- Install MariaDB Database Server
- Install phpMyAdmin
- Configure phpMyAdmin
- Import SQL
- Setting Virtual Host Apache
- Create New Superuser phpMyAdmin
- Testing
Simak penjelasannya di bawah ini.
Update Server
Cara pertama untuk meng-install phpMyAdmin dengan Apache di Debian 10 adalah login sebagai root ke server dan update server dengan perintah berikut:
$ apt-get update -y $ reboot
Install Packages
Install beberapa packages yang dibutuhkan Debian 10.
$ apt-get install wget nano perl zip unzip gnupg2 -y
Install Firewall
Sebelum memulai instalasi phpMyAdmin, kamu perlu meng-install firewall agar lebih aman. Di artikel ini firewall yang digunakan adalah CSF (ConfigServer Security & Firewall). Instalasinya dilakukan dengan perintah di bawah ini:
$ cd /usr/src $ wget https://download.configserver.com/csf.tgz $ tar -xzf csf.tgz $ cd csf/ $ sh install.sh
Ada sedikit perbedaan instalasi pada Debian 10 ini, ikuti perintah di bawah ini.
Install packages libwww:
$ apt-get install libwww-perl -y
$ perl /usr/local/csf/bin/csftest.pl
Kemudian akan keluar output di bawah ini.
Testing ip_tables/iptable_filter...OK Testing ipt_LOG...OK Testing ipt_multiport/xt_multiport...OK Testing ipt_REJECT...OK Testing ipt_state/xt_state...OK Testing ipt_limit/xt_limit...OK Testing ipt_recent...OK Testing xt_connlimit...OK Testing ipt_owner/xt_owner...OK Testing iptable_nat/ipt_REDIRECT...OK Testing iptable_nat/ipt_DNAT...OK RESULT: csf should function on this server
Nonaktifkan firewalld:
$ systemctl stop firewalld $ systemctl disable firewalld
Pada konfigurasi CSF ubah “make TESTING=’1’ menjadi 0”.
$ nano /etc/csf/csf.conf
Restart dan tes CSF:
$ systemctl restart {csf,lfd} $ systemctl enable {csf,lfd} $ systemctl is-active {csf,lfd}
Kemudian restart CSF agar dapat me-reload konfigurasi yang sudah diperbarui.
$ csf -r
Baca Juga: 10 Aplikasi Web Server Terbaik Untuk Deployment Website
Install Apache Web Server
Mengingat cara install phpMyAdmin ini dilakukan menggunakan Apache, maka kamu perlu meng-install Apache WebServer terlebih dulu dengan perintah di bawah ini.
$ apt-get install apache2 -y
Cek versi Apache yang kamu gunakan.
$ apache2 -v Server version: Apache/2.4.38 (Debian) Server built: 2020-08-25T20:08:29
Versi yang kami gunakan saat ini adalah Apache 2.4.38, mungkin akan berbeda dengan yang kamu install, tergantung versi Apache terbaru.
Start dan aktifkan on-boot Apache:
$ systemctl start apache2 $ systemctl enable apache2
Cek status Apache, apakah sudah aktif atau belum.
$ systemctl status apache2
-
apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2021-03-25 20:22:35 UTC; 5s ago Docs: https://httpd.apache.org/docs/2.4/ Process: 3141 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 3145 (apache2) Tasks: 6 (limit: 1149) Memory: 11.4M CGroup: /system.slice/apache2.service ├─3145 /usr/sbin/apache2 -k start ├─3146 /usr/sbin/apache2 -k start ├─3147 /usr/sbin/apache2 -k start ├─3148 /usr/sbin/apache2 -k start ├─3149 /usr/sbin/apache2 -k start └─3150 /usr/sbin/apache2 -k start
Install PHP 7.2 & PHP-FPM
Di artikel ini, kami menggunakan PHP 7.2 dan PHP-FPM. Sedikit penjelasan, PHP-FPM (FastCGI Process Manager) adalah alternatif untuk implementasi FastCGI di bahasa pemrograman PHP. PHP-FPM merupakan penerjemah PHP yang terpisah dari web server sehingga setiap request untuk script PHP yang masuk ke web server akan diteruskan ke FastCGI melalui socket koneksi TCP/IP.
Ikuti instalasi PHP 7.2 dan PHP-FPM di bawah ini.
Import dan tambahkan SURY repository:
$ wget https://packages.sury.org/php/apt.gpg $ apt-key add apt.gpg $ echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.list
Perbarui indeks repositori.
$ apt-get update -y
Install PHP
$ apt-get install php7.2 php7.2-fpm php7.2-mysqli php-common php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline php7.2-mbstring php7.2-xml php7.2-gd php7.2-curl libapache2-mod-php7.2 -y
Start dan aktifkan on-boot untuk PHP 7.2-FPM.
$ systemctl enable php7.2-fpm $ systemctl start php7.2-fpm
Cek status php7.2-fpm, apakah sudah aktif atau belum:
$ systemctl status php7.2-fpm
-
php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2021-03-25 10:02:57 UTC; 10h ago Docs: man:php-fpm7.2(8) Main PID: 12435 (php-fpm7.2) Status: "Processes active: 0, idle: 2, Requests: 14, slow: 0, Traffic: 0req/sec" Tasks: 3 (limit: 1149) Memory: 33.5M CGroup: /system.slice/php7.2-fpm.service ├─12435 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf) ├─12436 php-fpm: pool www └─12437 php-fpm: pool www
Agar Apache2 dapat membaca file dengan mengutamakan ekstensi index.php, gunakan perintah berikut:
$ nano /etc/apache2/mods-enabled/dir.conf
Sebelum:
<IfModule mod_dir.c> DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm </IfModule>
Sesudah:
<IfModule mod_dir.c> DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm </IfModule>
Configure PHP.ini
Buka file php.ini dan php-fpm configuration. Ubah konfigurasi sesuai di bawah ini.
$ nano /etc/php/7.2/fpm/php.ini ;cgi.fix_pathinfo=1 menjadi cgi.fix_pathinfo=0 $ nano /etc/php/7.2/cli/php.ini ;cgi.fix_pathinfo=1 menjadi cgi.fix_pathinfo=0 $ nano /etc/php/7.2/apache/php.ini ;extension=mysqli menjadi extension=mysqli
Kemudian simpan dan keluar.
Baca Juga: Cara Install SSL Let’s Encrypt pada Apache di Debian 10
Install MariaDB Database Server
Kami menggunakan MariaDB sebagai server database untuk menggantikan MySQL. Sebab, server database MySQL sudah deprecated dan tidak up-to-date sehingga lebih baik kamu menggunakan MariaDB.
$ apt-get install mariadb-server -y
Jika instalasinya sudah selesai, start dan aktifkan MariaDB on-boot.
$ systemctl enable mariadb $ systemctl start mariadb
Jangan lupa untuk cek status MariaDB, apakah sudah running atau belum
$ systemctl status mariadb
-
mariadb.service - MariaDB 10.3.27 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: Active: active (running) since Thu 2021-03-25 05:12:53 UTC; 5min ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Main PID: 3854 (mysqld) Status: "Taking your SQL requests now..." Tasks: 30 (limit: 1149) Memory: 76.3M CGroup: /system.slice/mariadb.service └─3879 /usr/sbin/mysqld
Lakukan command di bawah ini untuk memulai initiate setup MariaDB.
$ mysql_secure_installation Enter current password for root (enter for none): OK, successfully used password, moving on... Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! Remove anonymous users? [Y/n] y ... Success! Disallow root login remotely? [Y/n] y ... Success! Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
Install phpMyAdmin
Instalasi phpMyAdmin tidak tersedia secara default pada repositori Debian, maka kamu perlu mengunduh source code-nya ke server kamu dari website resmi phpMyAdmin. Unduh melalui phpMyAdmin Download Pages, pilih versi yang stable dan terbaru, kemudian klik Copy Link pada file .tar.gz, lalu unduh dan extract.
$ wget https://files.phpmyadmin.net/phpMyAdmin/5.1.0/phpMyAdmin-5.1.0-all-languages.tar.gz $ tar -xzf phpMyAdmin-5.1.0-all-languages.tar.gz $ mv phpMyAdmin-5.1.0-all-languages/ /usr/share/phpMyAdmin $ mkdir -p /etc/phpMyAdmin
Configure phpMyAdmin
Mengingat cara install phpMyAdmin menggunakan Apache di Debian 10 dilakukan melalui source code, maka server tidak melakukan konfigurasi otomatis sehingga kamu perlu melakukan konfigurasi manual.
Caranya, salin file konfigurasi.
$ cp /usr/share/phpMyAdmin/config.sample.inc.php /usr/share/phpMyAdmin/config.inc.php
Kemudian, kamu perlu mengisi 32 string random characters pada line blowfish_secret. Kamu bisa men-generate string tersebut menggunakan string generator. atau kamu bisa meng-install pwgen.
$ apt-get install pwgen $ pwgen -s 32 1
Jika sudah keluar output string-nya, tambahkan pada config.inc.php.
$cfg['blowfish_secret'] = 'string-yang-sudah-digenerate'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ $ nano /usr/share/phpmyadmin/config.inc.php
Uncomment beberapa line seperti di bawah ini.
$cfg['Servers'][$i]['controluser'] = 'pma'; $cfg['Servers'][$i]['controlpass'] = 'pmapass'; $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin'; $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark'; $cfg['Servers'][$i]['relation'] = 'pma__relation'; $cfg['Servers'][$i]['table_info'] = 'pma__table_info'; $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords'; $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages'; $cfg['Servers'][$i]['column_info'] = 'pma__column_info'; $cfg['Servers'][$i]['history'] = 'pma__history'; $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs'; $cfg['Servers'][$i]['tracking'] = 'pma__tracking'; $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig'; $cfg['Servers'][$i]['recent'] = 'pma__recent'; $cfg['Servers'][$i]['favorite'] = 'pma__favorite'; $cfg['Servers'][$i]['users'] = 'pma__users'; $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups'; $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding'; $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches'; $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns'; $cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings'; $cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';
Ubah pmapass dengan password yang kamu inginkan.
Jika sudah selesai, simpan dan keluar.
Import SQL
Import file create_tables.sql untuk membuat tabel di phpMyAdmin.
$ mysql < /usr/share/phpmyadmin/sql/create_tables.sql -u root -p # mysql -u root -p GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass'; # FLUSH PRIVILEGES;
Setting Virtual Host Apache
Ketika menggunakan Apache Web Server di Debian 10, kamu bisa menggunakan Virtual Host (sama seperti server blocks di Apache Web Server pada Ubuntu). Hal ini berguna bagi kamu yang ingin menggunakan lebih dari 1 domain pada server. Path untuk virtual host-nya berada di “/etc/apache2/sites-available/”. Lalu ubah nama domain sesuai dengan yang kamu gunakan.
$ nano /etc/apache2/sites-available/vps201.dewiweb.net.conf
Masukkan script di bawah ini:
<VirtualHost *:80> ServerAdmin [email protected] ServerName vps201.dewiweb.net ServerAlias www.vps201.dewiweb.net DocumentRoot /var/www/html/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Buat file dengan nama phpmyadmin.conf pada direktori /etc/apache2/conf-available/.
$ nano /etc/apache2/conf-available/phpmyadmin.conf
Tempel hasil salinan script di bawah ini.
# phpMyAdmin default Apache configuration Alias /phpMyAdmin /usr/share/phpMyAdmin <Directory /usr/share/phpMyAdmin> Options SymLinksIfOwnerMatch DirectoryIndex index.php <IfModule mod_php5.c> <IfModule mod_mime.c> AddType application/x-httpd-php .php </IfModule> <FilesMatch ".+\.php$"> SetHandler application/x-httpd-php </FilesMatch> php_value include_path . php_admin_value upload_tmp_dir /var/lib/phpMyAdmin/tmp php_admin_value open_basedir /usr/share/phpMyAdmin/:/etc/phpMyAdmin/:/var/lib/phpMyAdmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/ php_admin_value mbstring.func_overload 0 </IfModule> <IfModule mod_php.c> <IfModule mod_mime.c> AddType application/x-httpd-php .php </IfModule> <FilesMatch ".+\.php$"> SetHandler application/x-httpd-php </FilesMatch> php_value include_path . php_admin_value upload_tmp_dir /var/lib/phpMyAdmin/tmp php_admin_value open_basedir /usr/share/phpMyAdmin/:/etc/phpMyAdmin/:/var/lib/phpMyAdmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/ php_admin_value mbstring.func_overload 0 </IfModule> </Directory> # Authorize for setup <Directory /usr/share/phpMyAdmin/setup> <IfModule mod_authz_core.c> <IfModule mod_authn_file.c> AuthType Basic AuthName "phpMyAdmin Setup" AuthUserFile /etc/phpMyAdmin/htpasswd.setup </IfModule> Require valid-user </IfModule> </Directory> # Disallow web access to directories that don't need it <Directory /usr/share/phpMyAdmin/templates> Require all denied </Directory> <Directory /usr/share/phpMyAdmin/libraries> Require all denied </Directory> <Directory /usr/share/phpMyAdmin/setup/lib> Require all denied </Directory>
Aktifkan file dengan a2ensite tools:
$ a2ensite vps201.dewiweb.net.conf Enabling site vps201.dewiweb.net. To activate the new configuration, you need to run: systemctl reload apache2
Disable default site pada 000-default.conf:
$ a2dissite 000-default.conf $ a2enconf phpmyadmin.conf
Tes hasil konfigurasi:
$ apache2ctl configtest
Output-nya:
Syntax OK
Kemudian reload dan restart Apache:
$ systemctl reload apache2 $ systemctl restart apache2
Create New Superuser phpMyAdmin
Login ke MySQL sebagai root untuk membuat superuser agar bisa login ke phpMyAdmin di web interface.
$ mysql -u root -p
Masukkan password: (masukkan password root mysql saat melakukan mysql_secure_installation)
Buat superuser dengan perintah di bawah ini.
# CREATE USER 'pmauser'@'localhost' IDENTIFIED BY 'p4ssw0rd123'; # GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'%' WITH GRANT OPTION;
Lalu keluar dari MySQL.
Testing
Jika sudah, coba akses domainkamu.com/phpMyAdmin, maka akan terlihat halaman login seperti di bawah ini.
Baca Juga: Panduan phpMyAdmin untuk Pemula
Simpulan
Jika cara di atas dilakukan dengan tepat, maka seharusnya tak ada kendala berarti dan kamu sudah berhasil meng-install phpMyAdmin dengan Apache web server di Debian 10. Satu hal yang wajib kamu ingat, kamu harus selalu bisa memilih yang terbaik untuk website-mu, termasuk dalam memilih cloud hosting dan server VPS.
Selain aman, pemilihan hosting atau VPS yang tepat juga bisa membuat website-mu cepat dan selalu bisa diandalkan. Demikian artikel ini, jangan sungkan untuk meninggalkan ide-ide topik yang ingin kamu baca di blog Dewaweb, ya. Semoga artikel ini membantu!