Ditutorial kali ini kita akan membahas cara install WordPress di Debian 10. Bila anda mengikuti tutorial ini dari awal sampai akhir setelah 20 menit anda akan mendapati WordPress anda telah terinstall, tinggal di kustom untuk Thema dan Plugin.

1. Install Database MariaDB

Install MariaDB 10.3 dari repository

apt install mariadb-server -y

Buat user dan database baru

CREATE DATABASE dbwp;
GRANT ALL PRIVILEGES ON dbwp.* TO "dbwp"@"localhost" IDENTIFIED BY "fMys7YJrXWjc3Eatns4j";

nama database : dbwp
user database : dbwp
password database : fMys7YJrXWjc3Eatns4j
server : localhost

2. Install PHP

Debian 10 sudah menyertakan PHP 7.3, jadi bisa langsung di install dari repository

apt-get install php php-cli php-common php-gd php-xmlrpc php-fpm \
        php-curl php-intl php-imagick php-mysql php-zip php-xml \
        php-mbstring php-bcmath -y

Cek versi PHP yang terinstall php -v

$ php -v
PHP 7.3.14-1~deb10u1 (cli) (built: Feb 16 2020 15:07:23) ( NTS )

Update konfigurasi PHP FPM

sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php/7.3/fpm/php.ini
sed -i 's/;date.timezone =/date.timezone = Asia\/Jakarta/g' /etc/php/7.3/fpm/php.ini
sed -i 's/disable_functions =/disable_functions =dl,exec,passthru,proc_open,proc_close,shell_exec,system/g' /etc/php/7.3/fpm/php.ini
sed -i 's/post_max_size \=\ 8M/post_max_size \=\ 80M/g' /etc/php/7.3/fpm/php.ini
sed -i 's/upload_max_filesize \=\ 2M/upload_max_filesize \=\ 80M/g' /etc/php/7.3/fpm/php.ini
sed -i 's/memory_limit \=\ 128M/memory_limit \=\ 512M/g' /etc/php/7.3/fpm/php.ini

Aktifkan PHP FPM waktu Boot

systemctl enable php7.3-fpm
systemctl restart php7.3-fpm

3. Install NGINX

Install dependency

apt-get install curl gnupg2 ca-certificates lsb-release -y

Tambahkan repository Nginx

wget -qO - http://nginx.org/keys/nginx_signing.key | apt-key add -
echo "deb http://nginx.org/packages/debian/ $(lsb_release -sc) nginx" >> /etc/apt/sources.list

Install Nginx

apt update
apt install nginx -y

Tweak konfigurasi Nginx

cat >/etc/nginx/nginx.conf <<'EOL'
user  www-data;
worker_processes  auto;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
worker_rlimit_nofile 10000;
events {
    worker_connections  10000;
    use epoll;
    multi_accept on;
}
 
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    tcp_nopush on;
    tcp_nodelay on;
    send_timeout 5;
    client_body_timeout 20;
    keepalive_timeout 40;
    server_tokens off;
    client_max_body_size 200M;
 
    gzip on;
    gzip_min_length 10240;
    gzip_comp_level 1;
    gzip_vary on;
    gzip_disable msie6;
    gzip_proxied expired no-cache no-store private auth;
    gzip_types
        text/css
        text/javascript
        text/xml
        text/plain
        text/x-component
        application/javascript
        application/x-javascript
        application/json
        application/xml
        application/rss+xml
        application/atom+xml
        font/truetype
        font/opentype
        application/vnd.ms-fontobject
        image/svg+xml;
 
    open_file_cache max=1000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;
    include /etc/nginx/sites/*.conf;
}
EOL

Buat folder untuk menyimpan konfigurasi nginx

mkdir -p /etc/nginx/sites

Buat root folder nginx

mkdir -p /var/www/

Struktur folder akan kita buat untuk memudahkan konfigurasi multi domain. Struktur yang gampang untuk digunakan

# nginx
/etc/nginx/sites/domain.com.conf
/etc/nginx/sites/sub.domain.com.conf
# root 
/var/www/domain.com
/var/www/sub.domain.com

Buat server block untuk domain anda, disini contoh wp-debian.jaranguda.com

cat >/etc/nginx/sites/wp-debian.jaranguda.com.conf <<'EOL'
server {
    listen       80;
    server_name  wp-debian.jaranguda.com;
    root   /var/www/wp-debian.jaranguda.com;
    index index.php index.html;
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    location ~ \.php(?:$|/) {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTPS on;
        fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice
        fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        fastcgi_intercept_errors on;
    }
}
EOL

Aktifkan Nginx

systemctl enable nginx
systemctl restart nginx

4. Install WordPress

Install WordPress dengan wp-cli

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp
chmod +x /usr/local/bin/wp

Buat user baru jaranguda, user ini akan digunakan untuk mengelola domain-domain anda.

useradd jaranguda

Buat folder untuk wp-debian.jaranguda.com

mkdir -p /var/www/wp-debian.jaranguda.com

Ubah file permission

chown jaranguda:jaranguda /var/www/wp-debian.jaranguda.com

Download WordPress terbaru

cd /var/www/wp-debian.jaranguda.com
sudo -u jaranguda wp core download

Buat file wp-config.php dari database yang dibuat diatas

sudo -u jaranguda wp config create --dbname=dbwp --dbuser=dbwp --dbpass=fMys7YJrXWjc3Eatns4j --dbhost=localhost

Terakhir install WordPress

sudo -u jaranguda wp core install --url=https://wp-debian.jaranguda.com --title="Blog Jaranguda" --admin_user=wp-debian --admin_password=kWKwvwpXCKpuKMir3HAJ --admin_email=wp-debian@jaranguda.com

Setelah selesai di install buka di browser https://wp-debian.jaranguda.com. Login dengan
user : wp-debian
password : kWKwvwpXCKpuKMir3HAJ

Join the Conversation

1 Comment

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

  1. untuk jasa terkait proyek lebih lanjut bisa menghubungi siapa ya mas? urgent