Cara Install WordPress dengan Apache di FreeBSD

Tutorial FreeBSD server kali ini, kita akan belajar bagaimana cara install WordPress dengan menggunakan Apache web server disertai SSL dari Let’s Encrypt untuk protokol HTTPS.

*Perangkat yang digunakan*

Perangkat yang digunakan di tutorial ini:

· VPS FreeBSD 12.1 di Vultr · Domain musaamin.my.id · IP 207.148.123.152 · Apache · PHP 7.4 · MariaDB 10.5 · Let’s Encrypt · WordPress

*Install Apache*

Install Apache web server.

[INPUT]

1 pkg install apache24

Aktifkan service apache24.

[INPUT]

1 sysrc apache24_enable=”YES”

Jalankan service apache24.

[INPUT]

1 service apache24 start

Browse *http://serverIP* untuk menguji apakah Apache web server sudah berjalan dengan baik.

-Konfigurasi VirtualHost-

Selanjutnya mengkonfigurasi virtualhost untuk domain *musaamin.my.id*.

Membuat folder untuk document root.

[INPUT]

1 2 mkdir -p /var/www/musaamin.my.id echo “hello world” > /var/www/musaamin.my.id/index.html

Membuat folder untuk menyimpan file konfigurasi virtual host.

[INPUT]

1 mkdir /usr/local/etc/apache24/vhosts

Membuat folder untuk log Apache.

[INPUT]

1 mkdir /var/log/apache

Membuat file konfigurasi virtual host.

[INPUT]

1 nano /usr/local/etc/apache24/vhosts/musaamin.my.id.conf

Isi file konfigurasi virtual hosts.

[INPUT]

1 2 3 4 5 6 7 8 9 10 11 12 13     DocumentRoot /var/www/musaamin.my.id     ServerName musaamin.my.id     ServerAlias www.musaamin.my.id     ErrorLog /var/log/apache/musaamin.my.id_error.log     CustomLog  /var/log/apache/musaamin.my.id_access.log common              Order allow,deny         Allow from all         Require all granted         AllowOverride All     

Buka file konfigurasi Apache.

[INPUT]

1 nano /usr/local/etc/apache24/httpd.conf

Aktifkan opsi *ServerName* dan masukkan server IP address.

[INPUT]

1 ServerName 207.148.123.152

Tambahkan di baris paling bawah.

[INPUT]

1 Include etc/apache24/vhosts/*.conf

Cek apakah ada kesalahan konfigurasi.

[INPUT]

1 apachectl -t

Jika tidak ada kesalahan.

[INPUT]

1 Syntax OK

Restart service Apache.

[INPUT]

1 service apache24 restart

Browse *http://musaamin.my.id*.

*Install PHP*

Install PHP 7.4 dan extensionnya.

[INPUT]

1 pkg install php74 mod_php74 php74-mysqli php74-mbstring php74-pecl-mcrypt php74-zlib php74-curl php74-opcache php74-xml php74-xmlrpc php74-gd php74-json php74-zip

Buat file konfigurasi untuk menghubungkan Apache dengan PHP.

[INPUT]

1 nano /usr/local/etc/apache24/Includes/php.conf

Isi file php.conf.

[INPUT]

1 2 3 4 5 6 7 8 9 DirectoryIndex index.php index.html SetHandler application/x-httpd-php SetHandler application/x-httpd-php-source

Buat file *php.ini*

[INPUT]

1 2 cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini-production.default ln -s /usr/local/etc/php.ini-production /usr/local/etc/php.ini

Restart service Apache.

[INPUT]

1 service apache24 restart

Buat file *info.php*.

[INPUT]

1 echo “” > /var/www/musaamin.my.id/info.php

Browse *http://musaamin.my.id/info.php*

*Install SSL Let’s Encrypt*

Buka file konfigurasi Apache.

[INPUT]

1 nano /usr/local/etc/apache24/httpd.conf

Aktifkan modul SSL dan rewrite.

[INPUT]

1 2 LoadModule ssl_module libexec/apache24/mod_ssl.so LoadModule rewrite_module libexec/apache24/mod_rewrite.so

Restart service Apache.

[INPUT]

1 service apache24 restart

Install certbot Let’s Encrypt.

[INPUT]

1 pkg install py37-certbot-apache

Request SSL untuk domain musaamin.my.id.

[INPUT]

1 certbot –apache -d musaamin.my.id -d www.musaamin.my.id

Jika berhasil, certbot mengubah file konfigurasi virtual host musaamin.my.id.conf.

[INPUT]

1 nano /usr/local/etc/apache24/vhosts/musaamin.my.id.conf

Isinya.

[INPUT]

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17     DocumentRoot /var/www/musaamin.my.id     ServerName musaamin.my.id     ServerAlias www.musaamin.my.id     ErrorLog /var/log/apache/musaamin.my.id_error.log     CustomLog  /var/log/apache/musaamin.my.id_access.log common              Order allow,deny         Allow from all         Require all granted         AllowOverride All      RewriteEngine on RewriteCond %{SERVER_NAME} =musaamin.my.id [OR] RewriteCond %{SERVER_NAME} =www.musaamin.my.id RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

Certbot juga membuat file baru.

[INPUT]

1 nano /usr/local/etc/apache24/vhosts/musaamin.my.id-le-ssl.conf

Isinya.

[INPUT]

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19     DocumentRoot /var/www/musaamin.my.id     ServerName musaamin.my.id     ServerAlias www.musaamin.my.id     ErrorLog /var/log/apache/musaamin.my.id_error.log     CustomLog  /var/log/apache/musaamin.my.id_access.log common              Order allow,deny         Allow from all         Require all granted         AllowOverride All        Include /usr/local/etc/letsencrypt/options-ssl-apache.conf SSLCertificateFile /usr/local/etc/letsencrypt/live/musaamin.my.id/fullchain.pem SSLCertificateKeyFile /usr/local/etc/letsencrypt/live/musaamin.my.id/privkey.pem

Browse *https://musaamin.my.id*.

*Install MariaDB*

Install MariaDB database.

[INPUT]

1 pkg install mariadb105-server mariadb105-client

Aktifkan dan jalankan service MariaDB.

[INPUT]

1 2 sysrc mysql_enable=”YES” service mysql-server start

Amankan instalasi MariaDB.

[INPUT]

1 mysql_secure_installation

Jawab pertanyaannya.

[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 MariaDB

[INPUT]

1 mysql

Buat database untuk WordPress.

[INPUT]

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

*Install WordPress*

Download WordPress terbaru.

[INPUT]

1 wget https://wordpress.org/latest.tar.gz -O wordpress.tar.gz

Ekstrak wordpress.tar.gz

[INPUT]

1 tar xzvf wordpress.tar.gz

Copy isi folder wordpress ke document root.

[INPUT]

1 cp -Rfv wordpress/* /var/www/musaamin.my.id

Ubah ownership.

[INPUT]

1 chown -R www:www /var/www/musaamin.my.id

Hapus file index.html dan info.php yang dibuat sebelumnya.

[INPUT]

1 2 rm -f /var/www/musaamin.my.id/info.php rm -f /var/www/musaamin.my.id/index.html

Browse *https://musaamin.my.id* untuk install WordPress.

· Continue · Let’s go! · Masukkan nama database, username, dan password yang telah dibuat di MariaDB. Untuk *Database Host = 127.0.0.1*. Submit · Run the installation · Masukkan site title, username, password, dan email. Install WordPress.

WordPress telah selesai diinstall.

Cek *https://musaamin.my.id* dan login ke dashboard.

/Gratis saldo $100 untuk pendaftaran akun baru di Vultr. Daftar sekarang/

Selamat mencoba 🙂

Leave a Reply

Your email address will not be published.