install wordpress pada nginx Centos 7

Sekarang ini WordPress merupakan pilihan utama untuk blog, situs perusahaan, situs belanja, dan banyak lainnya. Kemudahan pengoperasian dan maintenance WordPress menjadikannya sangat mudah digunakan untuk pemula sekalipun. Mmenginstall server untuk WordPress pun cukup mudah, bisa dilihat langkah demi langkahnya dibawah ini.

Pada tutorial ini saya akan menggunakan VPS Linode, tetapi cara yang sama bisa digunakan dimana saja selama masih sama-sama menggunakan CentOS 7.

Update CentOS 7

yum clean all
yum update -y

Install aplikasi yang dibutuhkan

yum install wget curl nano -y
yum install epel-release -y
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Install PHP 7.1

yum install php71-php php71-php-cli php71-php-common php71-php-json php71-php-intl php71-php-mbstring php71-php-mcrypt php71-php-mysqlnd php71-php-pdo php71-php-tidy php71-php-xml php71-php-fpm -y

PHP pathinfo

Setting cgi.fix_pathinfo dan zona waktu php

sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/opt/remi/php71/php.ini
sed -i 's/;date.timezone =/date.timezone = Asia\/Jakarta/g' /etc/opt/remi/php71/php.ini

Install MySQL / MariaDB

yum install mariadb-server mariadb -y
systemctl start mariadb
/usr/bin/mysql_secure_installation

Kemudian ikuti proses installnya

Buat database untuk WordPress

Login ke mariadb

mysql -u root -p

Buat database dengan nama wp dan user wp

create database wp;
GRANT ALL PRIVILEGES ON wp.* TO "wp"@"localhost" IDENTIFIED BY "yourpasswordhere";

Install Nginx

yum install nginx -y

Edit file konfiguras nginx /etc/nginx/nginx.conf, yang perlu ditambahkan

# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
 worker_connections 1024;
}

http {
 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;
 keepalive_timeout 65;
 types_hash_max_size 2048;

include /etc/nginx/mime.types;
 default_type application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
 # See http://nginx.org/en/docs/ngx_core_module.html#include
 # for more information.
 include /etc/nginx/conf.d/*.conf;
 server {
 listen 80 default_server;
 listen [::]:80 default_server;
 server_name _;
 root /usr/share/nginx/html;

# Load configuration files for the default server block.
 include /etc/nginx/default.d/*.conf;

location / {
 try_files $uri $uri/ /index.html;
 index index.html index.php index.htm;}

location ~ \.php$ {
 try_files $uri =404;
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;
 }

error_page 404 /404.html;
 location = /40x.html {
 }

error_page 500 502 503 504 /50x.html;
 location = /50x.html {
 }
 }

# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }

}

Setting agar php71-php-fpm berjalan sebagai nginx

sed -i 's/user = apache/user = nginx/g' /etc/opt/remi/php71/php-fpm.d/www.conf
sed -i 's/group = apache/user = nginx/g' /etc/opt/remi/php71/php-fpm.d/www.conf

Restart php71-php-fpm dan nginx

systemctl restart php71-php-fpm
systemctl restart nginx

Install WordPress

wget wordpress.org/latest.tar.gz 
tar zxvf latest.tar.gz

Buka di browser http://IP.SERVER/wordpress

Terakhir aktifkan mysql php71-php-fpm nginx agar otomatis jalan setelah restart/booting

systemctl enable nginx 
systemctl enable mariadb
systemctl enable php71-php-fpm