Cara Install WordPress di LAMP Stack Ubuntu 18.04

WordPress dikenal sebagai CMS yang sangat ramah terhadap pengguna pemula yang baru pertama kali menggunakan website atau blog, maka tak heran CMS ini digunakan oleh 30% website di seluruh dunia. Di artikel ini, kamu akan mempelajari cara install WordPress di LAMP Stack dengan sistem operasi (OS) Ubuntu 18.04.

Agar tidak terkecoh, Dewaweb juga pernah membuat tutorial cara instalasi WordPress di LAMP Stack, tapi untuk VPS dengan sistem operasi CentOS 7. Tutorial ini bisa kamu simak dari artikel Cara Install WordPress dengan LAMP Stack.

Baca Juga: Cara Install LAMP Stack di Server dengan Ubuntu 18.04

Cara Install WordPress di LAMP Stack Ubuntu 18.04

Sebelum melakukan instalasi WordPress di LAMP Stack, setidaknya kamu perlu mempersiapkan dua hal berikut:

  1. Memiliki VPS dan domain yang aktif.
  2. Memiliki akses ke root sebagai Administrator.

Jika sudah disiapkan, perhatikan beberapa langkah utama yang akan dilakukan saat meng-install WordPress di LAMP Stack Ubuntu 18.04 di bawah ini:

  • Update Server
  • Install Firewall
  • Install Apache Web Server
  • Install MariaDB Database Server
  • Install PHP 7.2
  • Configure PHP.ini
  • Create Database
  • Setting Apache Server Config
  • Download WordPress
  • Testing

Berikut ini adalah cara install WordPress di Ubuntu 18.04 LAMP Stack:

1. Update Server

Login sebagai root ke server, kemudian perbarui server lalu reboot.

$ apt-get update -y

$ reboot

 

Instal package yang dibutuhkan.

$ apt-get install perl git nano wget -y

 

Install Firewall

Firewall yang digunakan pada cara install WordPress di LAMP Stack Ubuntu 18.04 ini adalah Config Security & Firewall (CSF).

$ cd /usr/src

$ wget https://download.configserver.com/csf.tgz 

$ tar -xzf csf.tgz

$ cd csf/

$ install.sh

Edit csf.conf lalu ubah value make TESTING menjadi 0.

 

$ nano /etc/csf/csf.conf

make TESTING=’0’

 

Jika sudah selesai, simpan lalu keluar kemudian muat ulang CSF dengan perintah di bawah ini.

$ csf -r

Baca Juga: Cara Instalasi LAMP Stack di CentOS 8

2. Install Apache Web Server

Kita memerlukan web server Apache jika menggunakan LAMP Stack. Ikuti instalasinya seperti berikut.

$ apt-get install apache2 -y

 

Mulai dan aktifkan on-boot untuk apache.services:

$ systemctl enable apache2

$ systemctl start apache2

 

Cek status Apache, apakah sudah aktif atau belum.

$ systemctl status apache2
  •  apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: 

  Drop-In: /lib/systemd/system/apache2.service.d

           └─apache2-systemd.conf

   Active: active (running) since Thu 2020-10-22 08:02:40 UTC; 1h 41min ago

 Main PID: 24606 (apache2)

    Tasks: 55 (limit: 1152)

   CGroup: /system.slice/apache2.service

           ├─24606 /usr/sbin/apache2 -k start

           ├─24609 /usr/sbin/apache2 -k start

           └─24610 /usr/sbin/apache2 -k start

 

3. Install MariaDB Database Server

Server database yang digunakan adalah MariaDB, karena MariaDB adalah server database paling up-to-date dan kompatibel untuk saat ini. 

$ apt-get install mariadb-server mariadb-client

 

Mulai dan aktifkan on-boot untuk layanan MariaDB dan lakukan secure installation.

$ systemctl enable mariadb

$ systemctl start mariadb




$ mysql_secure_installation




Enter current password for root (enter for none): 

OK, successfully used password, moving on...




Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.




Set root password? [Y/n] y

New password: 

Re-enter new password: 

Password updated successfully!

Reloading privilege tables..

 ... Success!




Remove anonymous users? [Y/n] y

 ... Success!




Disallow root login remotely? [Y/n] y

 ... Success!




Remove test database and access to it? [Y/n] y

 - Dropping test database...

 ... Success!

 - Removing privileges on test database...

 ... Success!




Reload privilege tables now? [Y/n] y

 ... Success!




Cleaning up...




All done!  If you've completed all of the above steps, your MariaDB

installation should now be secure.




Thanks for using MariaDB!

 

Kamu cukup menekan “Enter” pada current password for root, kemudian pada set root password pilih Y. Kemudian selanjutnya pilih Y semua hingga proses pengamanan selesai.

Baca Juga: Cara Install WordPress dengan LAMP Stack

Cek status MariaDB sudah aktif atau belum:

$ systemctl status mariadb
  •  mariadb.service - MariaDB 10.1.44 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: 

   Active: active (running) since Thu 2020-10-22 09:45:59 UTC; 7min ago

     Docs: man:mysqld(8)

           https://mariadb.com/kb/en/library/systemd/

 Main PID: 26632 (mysqld)

   Status: "Taking your SQL requests now..."

    Tasks: 27 (limit: 1152)

   CGroup: /system.slice/mariadb.service

           └─26632 /usr/sbin/mysqld

 

4. Install PHP 7.2

PHP yang digunakan pada tutorial ini adalah versi 7.2, install PHP 7.2 serta beberapa ekstensi yang dibutuhkan.

$ apt-get install php7.2 php7.2-fpm php7.2-mysql php-common php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline php7.2-mbstring php7.2-xml php7.2-gd php7.2-curl libapache2-mod-php -y

 

Mulai dan aktifkan on-boot untuk PHP 7.2-FPM.

$ systemctl enable php7.2-fpm

$ systemctl start php7.2-fpm

 

Cek status PHP 7.2-fpm sudah aktif atau belum:

$ systemctl status php7.2-fpm
  •  php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor prese

   Active: active (running) since Thu 2020-10-22 09:54:45 UTC; 4min 25s ago

     Docs: man:php-fpm7.2(8)

 Main PID: 8114 (php-fpm7.2)

   Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/se

    Tasks: 3 (limit: 1152)

   CGroup: /system.slice/php7.2-fpm.service

           ├─8114 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf)

           ├─8131 php-fpm: pool www

           └─8133 php-fpm: pool www

 

Perintah agak Apache2 dapat membaca file dengan mengutamakan extension index.php terlebih dulu:

$ nano /etc/apache2/mods-enabled/dir.conf

 

Sebelum:

<IfModule mod_dir.c>

    DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm

</IfModule>

 

Sesudah:

<IfModule mod_dir.c>

    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm

</IfModule>

 

5. Configure PHP.ini

Buka file php.ini dan php-fpm configuration. Ubah konfigurasi sesuai di bawah ini.

$ nano /etc/php/7.2/fpm/php.ini

;cgi.fix_pathinfo=1 menjadi cgi.fix_pathinfo=0




$ nano /etc/php/7.2/cli/php.ini

;cgi.fix_pathinfo=1 menjadi cgi.fix_pathinfo=0

 

Kemudian simpan dan keluar.

 

6. Create Database

Agar dapat menginstall WordPress, kamu memerlukan database dan user database-nya terlebih dulu dengan perintah berikut.

$ mysql -u root -p

$ CREATE DATABASE wp DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

$ GRANT ALL ON wp.* TO 'wpuser'@'localhost' IDENTIFIED BY 'p4ssw0rd123';

$ FLUSH PRIVILEGES;

$ EXIT;

Baca Juga: Cara Mengatasi HTTP Error 500 dan HTTP Error 503

7. Setting Apache Server Config

Nginx server block sama seperti virtual host di Apache, path-nya ada di “/etc/apache2/sites-available/” buat file baru dengan nama domain yang kamu gunakan, misalnya pada contoh berikut adalah wplamp.dewiweb.net.

$ nano /etc/apache2/sites-available/wplamp.dewiweb.net.conf

 

Akibat Apache menonaktifkan .htaccess secara default, maka kamu perlu mengaktifkan secara manual pada config-nya dengan memasukkan script di bawah ini.

<VirtualHost *:80>

    ServerAdmin [email protected]

    ServerName wplamp.dewiweb.net

    ServerAlias www.wplamp.dewiweb.net

    DocumentRoot /var/www/html/

    ErrorLog ${APACHE_LOG_DIR}/error.log

    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

<Directory /var/www/html/>

    AllowOverride All

</Directory>

 

Mengaktifkan Rewrite Module

$ a2enmod rewrite
Enabling module rewrite.

To activate the new configuration, you need to run:

  systemctl restart apache2

 

Mengaktifkan file dengan a2ensite tools:

$ a2ensite wplamp.dewiweb.net.conf

Enabling site wplamp.dewiweb.net.

To activate the new configuration, you need to run:

  systemctl reload apache2

 

Menonaktifkan default site pada 000-default.conf:

$ a2dissite 000-default.conf

 

Tes konfigurasi:

$ apache2ctl configtest

Output-nya:

Syntax OK

 

Reload dan restart Apache dengan perintah berikut:

$ systemctl reload apache2

$ systemctl restart apache2

 

8. Download WordPress

Langkah install WordPress di LAMP Stack Ubuntu 18.04 selanjutnya adalah mengunduh WordPress ke direktori /tmp dan memindahkan ke direktori yang kamu isi pada wplamp.dewiweb.net, yaitu /var/www/html/

$ cd /tmp

$ curl -LO https://wordpress.org/latest.tar.gz

$ tar -xzf latest.tar.gz

$ cp -a /tmp/wordpress/. /var/www/html/

$ cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php

 

Grab WordPress Secret Key Generator

$ curl -s https://api.wordpress.org/secret-key/1.1/salt/

 

Maka output-nya akan seperti di bawah ini:

define('AUTH_KEY',         'l+FUkV0~j^-yu^pi>u:E|7P?VveU)GexYU3FA]-aQflSsa1x<&MU9wLW2v|.GNn+');

define('SECURE_AUTH_KEY',  'ud=:|0W^rs,t)MbL$v )_~5^^^Ex1 Ylzx^Xg&HMB`jD^_nYvz0$|DUJ;k%Fp{B3');

define('LOGGED_IN_KEY',    '&BG_j!U)q=`jT.93Yty[1}C;hHV)Z1*z:Z</Z~FDUi[*0%F>@_?7b-(@ioH~FBQp');

define('NONCE_KEY',        'p>(%E+8{o^|d%^D+6]Cb_l:{.?+S|DrCR XDYO!0Cx$z4(LdX1sRLF/UV|Sk/bEk');

define('AUTH_SALT',        '8[K{P)202n]ew-*X`]tQc._MDyT]A4l#nE=_Mi-DADB-TP)36|TA:Un|mm=jmjC#');

define('SECURE_AUTH_SALT', 'kuuGYe(p1ZHr{+UmFym(N/x |/O0OVbE8RSOh)1I+9dz7zV&<+YY9Ue67jD- p_i');

define('LOGGED_IN_SALT',   'rlX5;IGEEeckN *;tn|^pw_gWA+AOri7?ygEys<;Ygjp?uucO(,1=Bnv;~)&rirq');

define('NONCE_SALT',       'A)ytsa6QXc,f~0u9GhWhaj-R1Pl#slga+IJgO7k?ji8mL~c>X/a+G@+T8J%Q)Ld;');

 

Simpan kode-kode tersebut ke Notepad untuk nantinya disalin dan tempel di wp-config.php.

$ nano /var/www/html/wp-config.php

/** The name of the database for WordPress */

 

Ubah konfigurasi database-nya:

define( 'DB_NAME', 'wp' );




/** MySQL database username */

define( 'DB_USER', 'wpuser' );




/** MySQL database password */

define( 'DB_PASSWORD', 'p4ssw0rd123' );




/** MySQL hostname */

define( 'DB_HOST', 'localhost' );


Kemudian tempel kode kunci di atas pada “key”. Jika sudah, simpan dan keluar.

9. Lakukan Test Akses Website

Langkah terakhir adalah coba akses website-mu untuk mengecek hasil install hingga setup WordPress yang baru dijalankan pada LAMP Stack di Ubuntu 18.04.

install wordpress di lamp stack ubuntu 18.04 success

Baca Juga: Cara Install WordPress dengan LEMP Stack

Simpulan

Jika diikuti dengan benar, seharusnya kini WordPress sudah ter-install di website-mu. LAMP (Linux Apache MySQL/MariaDB PHP) adalah stack yang cukup mudah diinstal dan digunakan. Oleh karena itu, meng-install WordPress menggunakan LAMP Stack bisa menjadi langkah tepat jika kamu menggunakan OS Ubuntu 18.04.

Baca juga: Cara Install Zabbix dengan Apache di Ubuntu 18.04

Demikian artikel cara install WordPress di LAMP Stack Ubuntu 18.04 ini, jangan sungkan untuk meninggalkan ide-ide topik yang ingin kamu baca di blog Dewaweb, ya. Semoga artikel ini membantu pengguna hosting murah berkualitas sekalian. Salam sukses online!