WordPress:Installasi di VPS: Difference between revisions
m Kangtain moved page Installasi Wordpress di VPS to WordPress:Installasi di VPS |
No edit summary |
||
| (8 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
Berikut adalah cara singkat menginstall [[WordPress]] di VPS [[Ubuntu]] | |||
==Installasi== | |||
<syntaxhighlight lang="bash"> | |||
wget https://wordpress.org/latest.zip | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash"> | |||
sudo apt install unzip | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash"> | |||
sudo mkdir -p /var/www/wordpress | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash"> | |||
sudo unzip latest.zip -d /var/www/ | |||
</syntaxhighlight> | |||
===Create a Database and User for WordPress Site=== | |||
Masuk ke database server | |||
<syntaxhighlight lang="bash"> | |||
sudo mariadb -u root | |||
</syntaxhighlight> | |||
atau | |||
<syntaxhighlight lang="bash"> | |||
sudo mysql -u root | |||
</syntaxhighlight> | |||
Lalu buat database dengan menggunakan perintah berikut | |||
<syntaxhighlight lang="sql"> | |||
create database wordpress; | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="sql"> | |||
grant all privileges on wordpress.* to [/cdn-cgi/l/email-protection <nowiki>[email protected]</nowiki>] identified by 'your-password'; | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="sql"> | |||
flush privileges; | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="sql"> | |||
exit; | |||
</syntaxhighlight> | |||
===Configure WordPress=== | |||
<syntaxhighlight lang="bash"> | |||
cd /var/www/wordpress | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash"> | |||
sudo cp wp-config-sample.php wp-config.php | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash"> | |||
sudo vim wp-config.php | |||
</syntaxhighlight> | |||
Temukan baris berikut dan ganti teks merah dengan nama database, nama pengguna, dan kata sandi yang Anda buat pada langkah sebelumnya. | |||
<syntaxhighlight lang="php"> | |||
/** The name of the database for WordPress */ | |||
define('DB_NAME', 'database_name_here'); | |||
/** MySQL database username */ | |||
define('DB_USER', 'username_here'); | |||
/** MySQL database password */ | |||
define('DB_PASSWORD', 'password_here'); | |||
</syntaxhighlight> | |||
Kemudian gulir ke bawah untuk menemukan baris berikut. | |||
<syntaxhighlight lang="php"> | |||
$table_prefix = 'wp_'; | |||
</syntaxhighlight> | |||
Secara default, setiap nama tabel database WordPress dimulai dengan wp_ sebagai awalan. Sangat disarankan untuk mengubahnya menjadi sesuatu yang lain untuk meningkatkan keamanan. Gunakan karakter acak seperti di bawah ini. | |||
<syntaxhighlight lang="php"> | |||
$table_prefix = '9OzB3g_'; | |||
</syntaxhighlight> | |||
simpan dengan menggunakan tombol <code>esc</code> lalu ketik <code>:wq</code> | |||
Kita juga perlu mengatur pengguna Nginx (www-data) sebagai pemilik direktori situs WordPress dengan menggunakan perintah berikut. | |||
<syntaxhighlight lang="bash"> | |||
sudo chown www-data:www-data /var/www/wordpress/ -R | |||
</syntaxhighlight> | |||
===Create an Nginx Server Block for WordPress=== | |||
<syntaxhighlight lang="bash"> | |||
sudo vim /etc/nginx/conf.d/wordpress.conf | |||
</syntaxhighlight> | |||
Masukkan teks berikut ke dalam file. Ganti teks merah dengan nama domain Anda sendiri. Jangan lupa untuk membuat catatan A untuk nama domain Anda di pengelola DNS Anda. | |||
<syntaxhighlight lang="bash"> | |||
server { | |||
listen 80; | |||
listen [::]:80; | |||
server_name www.example.com example.com; | |||
root /var/www/wordpress/; | |||
index index.php index.html index.htm index.nginx-debian.html; | |||
location / { | |||
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/php7.4-fpm.sock; | |||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |||
include fastcgi_params; | |||
include snippets/fastcgi-php.conf; | |||
# Add headers to serve security related headers | |||
add_header X-Content-Type-Options nosniff; | |||
add_header X-XSS-Protection "1; mode=block"; | |||
add_header X-Permitted-Cross-Domain-Policies none; | |||
add_header X-Frame-Options "SAMEORIGIN"; | |||
} | |||
#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; | |||
} | |||
} | |||
</syntaxhighlight> | |||
Simpan dan tutup file. Kemudian uji konfigurasi Nginx. | |||
<syntaxhighlight lang="bash"> | |||
sudo nginx -t | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash"> | |||
sudo systemctl reload nginx | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash"> | |||
sudo systemctl restart nginx | |||
</syntaxhighlight> | |||
==Extension PHP== | ==Extension PHP== | ||
<syntaxhighlight lang="bash"> | |||
sudo apt install php7.4-mbstring php7.4-xml php7.4-mysql php7.4-common php7.4-gd php7.4-bcmath php7.4-json php7.4-cli php7.4-curl php7.4-zip php-imagick php7.4-fpm php7.4-bcmath | |||
</syntaxhighlight> | |||
==Virtual Host Nginx== | ==Virtual Host Nginx== | ||
<syntaxhighlight lang="bash"> | |||
server { | server { | ||
## Your website name goes here. | ## Your website name goes here. | ||
| Line 41: | Line 231: | ||
} | } | ||
} | } | ||
</syntaxhighlight> | |||
==Source== | ==Source== | ||
*[https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/ nginx.com] | *[https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/ nginx.com] | ||
*[https://www.linuxbabe.com/ubuntu/install-wordpress-ubuntu-20-04-nginx-mariadb-php7-4-lemp linuxbabe.com] | |||
[[Category:WordPress]] | |||
[[Category:Website]] | |||
[[Category:Web Server]] | |||
[[Category:Server]] | |||
[[Category:Tutorial]] | |||
[[Category:CMS]] | |||