Cara Install WordPress dengan Nginx di Ubuntu 20.04

WordPress adalah sebuah perangkat lunak content management system (CMS) yang dapat memudahkan kita dalam membuat website. WordPress menjadi CMS paling populer saat ini, di mana terdapat 40% website di internet yang berbasis WordPress. Pada tutorial kali ini, kita akan belajar bagaimana cara install WordPress di Ubuntu 20.04 dengan menggunakan Nginx web server.

*0.Tutorial Environment*

Spesifikasi dan konfigurasi yang digunakan di tutorial ini:

· Server: VPS Ubuntu 20.04 · IP server: 188.166.229.126 · Web server: Nginx · SSL: Let’s Encrypt · PHP: versi 7.4 · MariaDB: versi 10.5 · WordPress: versi 5.7 · Domain: domain.com

*1.DNS Record*

Arahkan domain ke IP server terlebih dahulu dengan melakukan konfigurasi DNS record.

· Type = A, Name = domain.com, Target = 188.166.229.126 · Type = CNAME, Name = www, Target = domain.com

*2.Update System*

Update dan upgrade Ubuntu.

[INPUT]

1 2 apt update apt upgrade -y

*3.Install Nginx*

Install Nginx web server.

[INPUT]

1 apt install nginx -y

*4.Install PHP*

Pasang repository PPA untuk PHP.

[INPUT]

1 add-apt-repository ppa:ondrej/php

Install PHP dan extensionnya.

[INPUT]

1 apt install php7.4 php7.4-fpm php7.4-cli php7.4-common php7.4-mbstring php7.4-gd php7.4-intl php7.4-xml php7.4-mysql php7.4-zip php7.4-json -y

*5.Konfigurasi Nginx*

Membuat konfigurasi server block untuk domain.com.

[INPUT]

1 nano /etc/nginx/conf.d/domain.com.conf

Masukkan konfigurasi server block.

[INPUT]

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 server {     listen 80;     server_name domain.com www.domain.com;     root /var/www/domain.com;     index index.php index.html index.htm;       location / {       try_files $uri $uri/ /index.php?$args;     }       location ~ \.php$ {       try_files $fastcgi_script_name =404;       include fastcgi_params;       fastcgi_pass    unix:/run/php/php7.4-fpm.sock;       fastcgi_index   index.php;       fastcgi_param DOCUMENT_ROOT    $realpath_root;       fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;     }       access_log /var/log/nginx/domain.com_access.log;     error_log /var/log/nginx/domain.com_error.log; }

Download WordPress, ekstrak, dan pindahkan ke /var/www.

[INPUT]

1 2 3 wget https://wordpress.org/latest.tar.gz -O wordpress.tar.gz tar xzvf wordpress.tar.gz mv wordpress /var/www/domain.com

Ubah ownership dan permission file WordPress.

[INPUT]

1 2 chown -R www-data:www-data /var/www/domain.com chmod -R 755 /var/www/domain.com

Restart service nginx, dan cek statusnya apakah berjalan dengan baik.

[INPUT]

1 2 systemctl restart nginx systemctl status nginx

*6.Let’s Encrypt SSL*

Install certbot.

[INPUT]

1 2 snap install –classic certbot ln -s /snap/bin/certbot /usr/bin/certbot

Request SSL untuk domain.com yang terpasang di Apache.

[INPUT]

1 certbot –nginx -d domain.com -d www.domain.com

Masukkan alamat email untuk menerima notifikasi ketika SSL akan habis masa berlakunya, perlu dilakukan pembaruan SSL.

[INPUT]

1 2 Enter email address (used for urgent renewal and security notices) (Enter ‘c’ to cancel): saya@email.com

Jawab ‘Y (Yes)’ untuk menyetujui Terms of Service.

[INPUT]

1 2 3 4 5 Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server. Do you agree? – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – (Y)es/(N)o: Y

Jawab ‘Y (Yes)’ jika ingin dikirimkan informasi ke email.

[INPUT]

1 2 3 4 5 6 7 Would you be willing, once your first certificate is successfully issued, to share your email address with the Electronic Frontier Foundation, a founding partner of the Let’s Encrypt project and the non-profit organization that develops Certbot? We’d like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – (Y)es/(N)o: Y

SSL berhasil terpasang.

[INPUT]

1 2 Congratulations! You have successfully enabled HTTPS on https://domain.com and https://www.domain.com

SSL dari Let”€™s Encrypt hanya berlaku selama 3 bulan, harus diperbarui secara berkala. Untuk memperbarui SSL dari Let”€™s Encrypt cukup menjalankan certbot dengan parameter renew.

[INPUT]

1 certbot renew

*7.Install MariaDB*

Pasang repository MariaDB versi 10.5 untuk Ubuntu 20.04 yang berada di server mirror DigitalOcean Singapura.

[INPUT]

1 2 3 apt install software-properties-common -y apt-key adv –fetch-keys ‘https://mariadb.org/mariadb_release_signing_key.asc’ add-apt-repository ‘deb [arch=amd64,arm64,ppc64el] http://sgp1.mirrors.digitalocean.com/mariadb/repo/10.5/ubuntu focal main’

Update dan upgrade.

[INPUT]

1 2 apt update apt upgrade -y

Install MariaDB server.

[INPUT]

1 apt install mariadb-server -y

Mengamankan Instalasi MariaDB.

[INPUT]

1 mysql_secure_installation

Jawab pertanyaan yang diajukan.

[INPUT]

1 2 3 4 5 6 7 Enter current password for root (enter for none): ENTER Switch to unix_socket authentication [Y/n] y Change the root password? [Y/n] y Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] y Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y

Login ke MariaDB.

[INPUT]

1 mysql

Membuat database, username, dan memberikan hak akses ke database.

[INPUT]

1 2 3 4 5 CREATE DATABASE wordpress; CREATE USER ‘wordpress’@’localhost’ IDENTIFIED BY ‘rahasia’; GRANT ALL PRIVILEGES ON wordpress.* TO ‘wordpress’@’localhost’; FLUSH PRIVILEGES; exit

*8.Install WordPress*

Browse domain.com untuk menyelesaikan instalasi WordPress.

1. Bahasa = English (United States), Continue. 2. Let’s go! 3. Database Name = wordpress, Username = wordpress, Password = rahasia. Submit. 4. Run the installation. 5. Masukkan Site Title, Username, Password, dan Your Email. Install WordPress.

WordPress sudah siap digunakan.

Selamat mencoba 🙂

Leave a Reply

Your email address will not be published.