Linux and Drupal Developer Shortcode

Pengembangan berbagai aplikasi yang requirementnya beda-beda selain membutuhkan spesifikasi PC yang handal (SSD dan RAM >=16GB), juga memerlukan konfigurasi dan instalasi server yang sangat rumit (misal multiphp, multidb, multidocker), nah ketimbang kita install server linux yang kompleks dan rumit agar dapat mengakomodir semua aplikasi dan juga memberatkan kinerja server, lebih baik kita siapkan saja satu server untuk satu aplikasi sehingga simpel dan ringan, dan apabila kita akan development aplikasi lainnya yang berbeda, maka kita tinggal reinstall ulang aja sesuai kebutuhan.

Dirangkum dari berbagai sumber dan telah melalui proses percobaan yang panjang dan melelahkan, berikut adalah tahapan-tahapan proses install/reinstall LAMPP yang saya terapkan di WSL2, disertakan juga install/maintenance drupal menggunakan composer dan drush, dan diujung saya sertakan instalasi docker Laradock yang sering saya gunakan juga.

Saya posting di website saya agar mudah membukanya dan saya share postingan ini ke public agar "some-one-out-there" bisa mempercayainya, implementasi di level produksi bisa melihat pada konten iniiniiniinisebagain ini dan sebagian vlog ini.

Demikan.

Kuningan, 20 Agustus 2024.
update : 4 Juli 2025.


WINDOWS SUBSYTEM LINUX 2

::INSTALL
Turn Windows Features "Linux Subsytem For Linux" ON 
wsl -l -v
wsl --list --online
wsl --install Ubuntu-22.04

::MOVING WSL DISTRIBUTION TO ANOTHER DRIVE ( From HDD to SSD )
wsl -l -v
wsl -t Ubuntu-22.04
wsl --export Ubuntu-22.04 "E:\WSL\wsl_export\ubuntu-ex.tar"
wsl --unregister Ubuntu-22.04
wsl --import Ubuntu-22.04 "E:\WSL\wsl_import\ubuntu" "E:\WSL\wsl_export\ubuntu-ex.tar"
ubuntu2204.exe config --default-user luki
wsl --setdefault Ubuntu-22.04

::UNINSTALL
wsl -l -v
wsl --unregister Ubuntu-22.04
rm E:\WSL
Reboot


LINUX APACHE MYSQL PHP PHPMYADMIN

sudo apt update
sudo apt upgrade

::APACHE
sudo apt install apache2 -y
sudo systemctl status apache2

sudo ufw allow 80/tcp
sudo ufw reload
sudo ufw status

:MODREWRITE
sudo apache2ctl -M
sudo a2enmod rewrite
sudo nano /etc/apache2/apache2.conf
<Directory />
Options FollowSymLinks
AllowOverride All
Require all denied
</Directory>

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

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


:: VIRTUALHOST
sudo mkdir -p /var/www/site1.local

sudo chown -R $USER:$USER /var/www/site1.local
sudo chown -R $USER:$USER /var/www

sudo chmod -R 755 /var/www/site1.local
sudo chmod -R 755 /var/www

nano /var/www/site1.local/index.html

sudo nano /etc/apache2/sites-available/site1.local.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName site1.local
ServerAlias www.site1.local
DocumentRoot /var/www/site1.local/homedir/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

sudo a2ensite site1.local.conf
sudo apache2ctl configtest
sudo systemctl restart apache2

::PHP
sudo add-apt-repository ppa:ondrej/php
sudo apt install php8.2 php8.2-cli php8.2-common php8.2-curl php8.2-gd php8.2-mbstring php8.2-mysql php8.2-opcache php8.2-readline php8.2-sqlite3 php8.2-xml php8.2-zip php8.2-apcu
sudo php -v
sudo php -m
sudo nano /etc/php/8.2/apache2/php.ini
sudo nano /var/www/html/info.php
<?php phpinfo();?>

::MYSQL 
sudo apt install mysql-server-8.0
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'My7Pass@Word_9_8A_zE';
exit
sudo systemctl start mysql.service
sudo systemctl status mysql.service
sudo mysql_secure_installation
sudo systemctl is-enabled mysql.service
sudo systemctl enable mysql.service

::MARIA DB
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.globo.tech/repo/10.11/ubuntu jammy main'
sudo apt update
sudo apt install mariadb-server
sudo systemctl status mariadb
sudo mariadb --version
sudo mysql_secure_installation
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
    bind-address = 127.0.0.1
    default_authentication_plugin = mysql_native_password
sudo systemctl restart mariadb

::PHPMYADMIN
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
tar xvf phpMyAdmin-*-all-languages.tar.gz
mkdir /var/www/html/phpmyadmin
sudo mv phpMyAdmin-5.2.2-all-languages/* /var/www/html/phpmyadmin/
sudo mkdir -p /var/www/html/phpmyadmin/tmp
sudo cp /var/www/html/phpmyadmin/config.sample.inc.php /var/www/html/phpmyadmin/config.inc.php
openssl rand -base64 32
sudo nano /var/www/html/phpmyadmin/config.inc.php
$cfg[‘blowfish_secret’] = ‘your-key‘; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
$cfg['TempDir'] = '/var/www/html/phpmyadmin/tmp';
sudo chown -R www-data:www-data /var/www/html/phpmyadmin
sudo find /var/www/html/phpmyadmin/ -type d -exec chmod 755 {} \;
sudo find /var/www/html/phpmyadmin/ -type f -exec chmod 644 {} \;
sudo nano /etc/apache2/conf-available/phpmyadmin.conf
    Alias /phpmyadmin /var/www/html/phpmyadmin

    <Directory /var/www/html/phpmyadmin>
    Options Indexes FollowSymLinks
    DirectoryIndex index.php

    <IfModule mod_php8.c>
    AddType application/x-httpd-php .php

    php_flag magic_quotes_gpc Off
    php_flag track_vars On
    php_flag register_globals Off
    php_value include_path .
    </IfModule>

    </Directory>

    # Authorize for setup
    <Directory /var/www/html/phpmyadmin/setup>
    <IfModule mod_authn_file.c>
    AuthType Basic
    AuthName "phpMyAdmin Setup"
    AuthUserFile /etc/phpmyadmin/htpasswd.setup
    </IfModule>
    Require valid-user
    </Directory>

    # Disallow web access to directories that don't need it
    <Directory /var/www/html/phpmyadmin/libraries>
    Order Deny,Allow
    Deny from All
    </Directory>
    <Directory /var/www/html/phpmyadmin/setup/lib>
    Order Deny,Allow
    Deny from All
    </Directory>

sudo a2enconf phpmyadmin.conf
sudo systemctl restart apache2
https://localhost/phpmyadmin

::COMPOSER
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
HASH=`curl -sS https://composer.github.io/installer.sig`
echo $HASH
php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
sudo chmod +x /usr/local/bin/composer
composer

::DRUPAL
cd /var/www/site1.local/
#latest
composer create-project --no-install drupal/recommended-project homedir
#spesific version
composer create-project --no-install drupal/recommended-project:10.3.5 homedir
cd homedir/
sed -i 's/web\//public_html\//g' composer.json

composer install

sudo nano /etc/apache2/sites-available/site1.local.conf

sudo apache2ctl configtest
sudo systemctl restart apache2

cd public_html/
mkdir sites/default/files
chmod -R 755 sites/default
chmod -R 755 sites/default/files/
chmod 777 sites/default/
chmod 777 sites/default/files/
cp sites/default/default.settings.php sites/default/settings.php
chmod +777 sites/default/settings.php
sudo systemctl restart apache2

::NODEJS  NPM
sudo apt-get install nodejs
sudo apt install npm


Composer Best Practices for Updating Drupal 8^ Core and Modules

Install Drush
composer require drush/drush
vendor/bin/drush

Take a backup of the database
drush sql:dump --result-file=../backup.sql.

Take a backup of the database and files
drush archive:dump --destination=../archive.tar.gz
tar cvzf ../backup.tar.gz homedir/ 

Check what Drupal core and packages are available to update
drush cex
Composer outdated
Composer outdated drupal/*
composer show drupal/core-recommended
drush sset system.maintenance_mode 1
Composer update drupal/core --with-dependencies
drush updb
drush cr
drush sset system.maintenance_mode 0
drush cr
drush cex

composer update --dry-run "drupal/*"
composer update drupal/core-recommended --with-dependencies
drush updatedb
drush cache:rebuild
composer install --no-dev
composer update.
drush updatedb

Download/Install/Update/UnInstall/Remove Module:
composer require drupal/<modulename>:<version>
drush en <modulename>
composer require drupal/<modulename>:<version>
drush updatedb
drush pm:uninstall <modulename> -y
composer remove drupal/<modulename>
drush cr

Download/Install/Update/UnInstall/Remove Theme:
composer require drupal/<themename>:<version>
drush then <themename>
composer require drupal/<themename>:<version>
drush updatedb
drush theme:uninstall themename> -y
composer remove drupal/<themename>
vendor/bin/drush cr


Laradock On Almalinux 8

rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux
dnf update
reboot
dnf install git wget nano
dnf install epel-releas
dnf install screen
dnf install yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin
systemctl start docker
systemctl enable docker
systemctl status docker
docker version
docker run hello-world
curl -SL https://github.com/docker/compose/releases/download/v2.27.2/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose
screen
git clone https://github.com/Laradock/laradock.git
cd laradock/
mkdir ../app
cp .env.example .env
docker-compose up -d nginx mysql phpmyadmin redis workspace
cp nginx/sites/app.conf.example nginx/sites/dev-ops.kuningankab.go.id.conf
nano nginx/sites/dev-ops.kuningankab.go.id.conf
docker-compose exec laradock-workspace-1 bash
docker-compose ps
docker-compose build nginx mysql phpmyadmin redis workspace
docker-compose up -d nginx mysql phpmyadmin redis workspace
docker-compose ps
docker-compose ls
docker-compose ps
docker-compose down
docker ps