Install Wordpress Nginx Ubuntu - DotKom

Install Wordpress Nginx Ubuntu

Cara Install Wordpress Nginx
Step 1

ufw enable
Step 2

ufw allow ssh
Step 3

sudo apt install nginx -y
Step 4

sudo ufw allow 'Nginx Full'
Step 5

sudo apt-get install software-properties-common -y
Step 6

sudo apt install php8.1-fpm php8.1-common php8.1-dom php8.1-intl php8.1-mysql php8.1-xml php8.1-xmlrpc php8.1-curl php8.1-gd php8.1-imagick php8.1-cli php8.1-dev php8.1-imap php8.1-mbstring php8.1-soap php8.1-zip php8.1-bcmath -y
Step 7

sudo apt-get install apt-transport-https curl
Step 8

sudo mkdir -p /etc/apt/keyrings
Step 9

sudo curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp'
Step 10

sudo apt-get install mariadb-server
Step 11

mysql_secure_installation
Step 12

passwordku
Step 13

mysql
Step 14

GRANT ALL PRIVILEGES ON * . * TO 'root'@'localhost' IDENTIFIED BY 'passwordku';
Step 15

CREATE USER 'userku'@'localhost' IDENTIFIED BY 'passwordku';
Step 16

CREATE DATABASE dbku;
Step 17

grant all privileges on dbku.* to userku@localhost;
Step 18

FLUSH PRIVILEGES;
Step 19

exit
Step 20

mkdir /var/www/domainku.com
Step 21

cd /var/www/domainku.com
Step 22

wget https://wordpress.org/latest.zip
Step 23

apt install zip
Step 24

unzip latest.zip
Step 25

rm -r latest.zip
Step 26

nano /etc/nginx/sites-enabled/domainku.com
Copy Paste

server {
  listen 80;
  listen [::]:80;
  server_name www.domainku.com domainku.com;
  root /var/www/domainku.com/wordpress/;
  index index.php index.html index.htm index.nginx-debian.html;

  error_log /var/log/nginx/wordpress.error;
  access_log /var/log/nginx/wordpress.access;

  location / {
    limit_req zone=mylimit burst=20 nodelay;
    limit_conn addr 10;
    try_files $uri $uri/ /index.php;
  }

   location ~ ^/wp-json/ {
     rewrite ^/wp-json/(.*?)$ /?rest_route=/$1 last;
   }

  location ~* /wp-sitemap.*\.xml {
    try_files $uri $uri/ /index.php$is_args$args;
  }

  error_page 404 /404.html;
  error_page 500 502 503 504 /50x.html;

  client_max_body_size 20M;

  location = /50x.html {
    root /usr/share/nginx/html;
  }

  location ~ \.php$ {
    fastcgi_pass unix:/run/php/php8.1-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    include snippets/fastcgi-php.conf;
    fastcgi_buffers 1024 4k;
    fastcgi_buffer_size 128k;
  }

  #enable gzip compression
  gzip on;
  gzip_vary on;
  gzip_min_length 1000;
  gzip_comp_level 5;
  gzip_types application/json text/css application/x-javascript application/javascript image/svg+xml;
  gzip_proxied any;

  # A long browser cache lifetime can speed up repeat visits to your page
  location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {
       access_log        off;
       log_not_found     off;
       expires           360d;
  }

  # disable access to hidden files
  location ~ /\.ht {
      access_log off;
      log_not_found off;
      deny all;
  }
}
Step 27

mkdir /etc/ssl/domainku.com
Step 28 Copy Sertifikat SSL

nano /etc/ssl/domainku.com/cert.pem
Step 29 Copy Key SSL

nano /etc/ssl/domainku.com/key.pem
Step 30 tambahkan pada /etc/nginx/sites-enabled/domainku.com

# SSL configuration

listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate         /etc/ssl/domainku.com/cert.pem;
ssl_certificate_key     /etc/ssl/domainku.com/key.pem;
Step 31

sudo chown www-data:www-data /var/www/domainku.com/wordpress/ -R
Step 32

chmod 755 /var/www/domainku.com/wordpress/wp-content
Step 34 tambahkan pada /etc/nginx/nginx.conf

limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s;
limit_conn_zone $binary_remote_addr zone=addr:10m;
client_body_timeout   10s;
client_header_timeout 10s;
keepalive_timeout     10s;
send_timeout          10s;
Finish

service nginx restart

Post a Comment