Tutorial

Memulai Web Server di Raspberry

cuma catatan pribadi aja yang dishare di blog pribadi

Install LAMP (Linux, Apache, MySQL, PHP) di Raspberry (bisa juga dipakai untuk Ubuntu dan Debian karena masih 1 keluarga, selain Raspberry, ganti username pi jadi username yang sudah dibikin diawal untuk konfigurasi Apache atau lainnya yang membutuhkan username)

Biasalah, namanya abis install awal harus di update dulu

sudo apt-get update -y
sudo apt-get upgrade -y

Install dah LAMPnya

sudo apt-get install apache2 mariadb-server php7.3 libapache2-mod-php7.3 php7.3-mbstring php7.3-mysql php7.3-curl php7.3-gd php7.3-zip -y
Spoiler for: command ini untuk Ubuntu/Debian
sudo apt-get install apache2 mariadb-server php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath -y

dah semua, sekarang config 1-1 dari Apache2.

Bikin folder log Apache2 di /var/log/apache2 dan ubah user foldernya jadi pi:pi (kalau udah ada folder log Apache2, langsung di chown aja)

sudo mkdir /var/log/apache2
sudo chown -R pi:pi /var/log/apache2

Setting config Apache2 di Raspberry Pi ada di /etc/apache2 setting apache2.conf jadi gini : (cek / ganti yang diberi tanda warna merah)

DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5

# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

HostnameLookups Off

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf

# Sets the default security model of the Apache2 HTTPD server.

<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>

<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

AccessFileName .htaccess

<FilesMatch "^\.ht">
Require all denied
</FilesMatch>

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf

Terus cek file 000-default.conf di folder sites-available jadi gini : (cek / ganti yang diberi tanda warna merah)

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

cek envvars, sama kaya gini gak : (cek / ganti yang diberi tanda warna merah)

unset HOME

if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
SUFFIX=
fi

export APACHE_RUN_USER=pi
export APACHE_RUN_GROUP=pi

export APACHE_PID_FILE=/var/run/apache2$SUFFIX/apache2.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX

export APACHE_LOG_DIR=/var/log/apache2$SUFFIX

export LANG=C

export LANG

Sehabis itu rewrite/beri akses/chown folder www-nya user:group jadi pi:pi

sudo chown -R pi:pi /var/www

sekarang rewrite pakai a2enmod dan sehabis itu Restart Apache2

sudo a2enmod rewrite
sudo systemctl restart apache2

Untuk PHPnya, cuma cek lewat php.info aja kok, tinggal bikin phpinfonya :

echo "<?php phpinfo ();?>" > /var/www/info.php

Sekarang setting MariaDB SQL-nya

Login mysqlnya dulu tanpa password

sudo mysql -u root -p

sehabis itu bikin password buat si root dan beri akses ke localhost

1. --- command drop user Root dibawah ini untuk mengganti host dari localhost ke any host, tapi kalau mau tetap di localhost langsung ganti password saja ---

DROP USER 'root'@'localhost';
CREATE USER 'root'@'%' IDENTIFIED BY 'bikin_passwordnya_disini';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

2. --- Jika user Root sudah ada, bisa langsung reset/bikin password buat user Root ---

ALTER USER 'root'@'localhost' IDENTIFIED BY 'bikin_passwordnya_disini';
FLUSH PRIVILEGES;
  • INGAT, import-export MySQL CLI
    Export pakai : mysqldump -u root -p namadatabase > namadatabase.sql
    Import pakai : mysql -u root -p namadatabase < namadatabase.sql
  • Cara melihat semua user MySQL di host
    Mysql > SELECT user,host FROM mysql.user;

Dah selesai


Terakhir, install dan setting phpmyadminnya

sudo apt-get install phpmyadmin -y

user phpmyadmin gak usah ikut dbconfignya, install tanpa phpmyadmin user dan database, udah pake bawaan dari MariaDB aja,

Pada opsi layar biru “Configuring phpmyadmin” untuk configure phpmyadmin with dbconfig-common, pilih No

terakhir :

sudo phpenmod mysqli
sudo /etc/init.d/apache2 restart

Selesai, cek di localhost/phpmyadmin

TROUBLESHOOT PHPMYADMIN

Untuk mengatasi blowfish_secret, edit file yang ada di config.default.php

sudo nano /usr/share/phpmyadmin/libraries/config.default.php

dan masukin kalimat panjang bebas terserah, contoh :

[email protected]

Jika ada error pada ./libraries/sql.lib.php, backup dulu filenya :

sudo cp /usr/share/phpmyadmin/libraries/sql.lib.php /usr/share/phpmyadmin/libraries/sql.lib.php.bak

edit filenya :

sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php

cari script : (count($analyzed_sql_results[‘select_expr’] == 1

dan tambahkan/ganti dengan : ((count($analyzed_sql_results[‘select_expr’]) == 1)


Jika ada error pada ./libraries/plugin_interface.lib.php, biasa, backup dulu file itu dan edit deh

# sudo nano /usr/share/phpmyadmin/libraries/plugin_interface.lib.php

cari script : if ($options != null && count($options) > 0)

terus ganti sama : if (! is_null($options) && count((array)$options) > 0) {

Related Article

Pradja DJ

M untuk Mini dan W untuk Wumbo

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Advertisment ad adsense adlogger