Langkah 1: Persiapan Sistem
– Pastikan sistem Anda sudah diperbarui dengan perintah berikut:
apt update
Langkah 2: Instalasi Nginx di VMA3 & VMA4
– Instal Nginx dengan perintah berikut:
apt install -y nginx
– Setelah instalasi, jalankan Nginx dengan perintah berikut:
systemctl start nginx
systemctl enable nginx
Langkah 3: Instalasi PostgreSQL di VMB3
– Instal PostgreSQL dengan perintah berikut:
apt install -y postgresql postgresql-contrib
– Setelah instalasi, buat database dan pengguna untuk WordPress:
sudo -u postgres psql
CREATE DATABASE wordpressdb;
CREATE USER wpuser WITH PASSWORD ‘aulia’;
GRANT ALL PRIVILEGES ON DATABASE wordpressdb TO wpuser;
\q
– Setelah itu, buat database dan pengguna untuk WordPress yang di VMA4:
sudo -u postgres psql
CREATE DATABASE wordpressdb2;
CREATE USER wpuser2 WITH PASSWORD ‘aulia’;
GRANT ALL PRIVILEGES ON DATABASE wordpressdb2 TO wpuser2;
\q
Langkah 4: Instalasi PHP dan Ekstensi yang Diperlukan di VMA3 & VMA4
– Instal PHP dan ekstensi yang diperlukan dengan perintah berikut:
apt install -y php-fpm php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-cli php-ldap php-zip php-curl php-pgsql tar wget git unzip
apt -y install php-mysqlnd php-pgsql
apt install php-fpm
Langkah 5: Konfigurasi Nginx untuk WordPress di VMA3 & VMA4
– Konfigurasi file default nginx:
nano /etc/nginx/sites-available/default
– hapus pagar pada bagian ini menjadi seperti dibawah ini
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
location ~ /\.ht {
deny all;
}
– Buat file konfigurasi baru untuk situs WordPress Anda:
sudo nano /etc/nginx/sites-available/wordpress
– Tambahkan konfigurasi berikut ke file tersebut:
server {
listen 80;
root /var/www/html/wordpress;
index index.php index.html index.htm;
server_name lksjogjaX.lan;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
– Aktifkan konfigurasi dengan membuat symlink ke direktori `sites-enabled`:
ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
– Verifikasi konfigurasi Nginx dan restart layanan:
nginx -t
systemctl restart nginx
Langkah 6: Instalasi WordPress di VMA3 & VMA4
– Unduh WordPress dan ekstrak file:
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
cp -a /tmp/wordpress/. /var/www/html/wordpress
– Ubah kepemilikan direktori WordPress:
chown -R www-data:www-data /var/www/html/wordpress
chmod 777 /var/www/html/wordpress
– Konfigurasi file wp-config:
cd /var/www/html/wordpress/
cp wp-config-sample.php wp-config.php
nano wp-config.php
ubah pada database name, database user, database password, dan database host
tambah ini:
define(‘DB_PORT’, ‘5432’); // Port PostgreSQL
define(‘DB_TYPE’, ‘pgsql’); // Jenis database (PostgreSQL)
– Konfigurasi PG4WP
cd /var/www/html/wordpress/wp-content/
apt install -y git
git clone https://github.com/kevinoid/postgresql-for-wordpress.git
mv postgresql-for-wordpress/pg4wp pg4wp
cp pg4wp/db.php db.php
rm -R postgresql-for-wordpress
– Buka browser dan akses situs WordPress Anda untuk menyelesaikan instalasi.
http://ip-address-server-anda/wordpress