vi

Cài WordPress trên VPS: Hướng Dẫn LEMP Stack

WordPress chạy trên VPS riêng với LEMP stack mang lại hiệu suất vượt trội so với shared hosting. Bạn kiểm soát toàn bộ môi trường, không bị giới hạn tài nguyên, và có thể tùy chỉnh sâu. Hướng dẫn này giúp bạn cài đặt WordPress trên VPS offshore AnubizHost với Nginx, MySQL và PHP-FPM.

Need this done for your project?

We implement, you ship. Async, documented, done in days.

Start a Brief

Cài Đặt LEMP Stack

LEMP stack gồm Linux (Ubuntu), Nginx, MySQL và PHP. Cài đặt từng thành phần:

apt update && apt upgrade -y

# Nginx
apt install -y nginx

# MySQL
apt install -y mysql-server
mysql_secure_installation

# PHP và extensions cần cho WordPress
apt install -y php8.2-fpm php8.2-mysql php8.2-xml php8.2-mbstring   php8.2-curl php8.2-zip php8.2-gd php8.2-intl php8.2-bcmath

Kiểm tra PHP:

php -v

Tạo Database và User MySQL

Tạo database riêng cho WordPress:

mysql -u root -p

Trong MySQL shell:

CREATE DATABASE wordpress_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Tải và Cài Đặt WordPress

Tải WordPress và đặt vào thư mục web:

cd /var/www
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
mv wordpress yourdomain.com
chown -R www-data:www-data yourdomain.com
chmod -R 755 yourdomain.com

Cấu hình wp-config.php:

cd /var/www/yourdomain.com
cp wp-config-sample.php wp-config.php
nano wp-config.php

Điền thông tin database:

define('DB_NAME', 'wordpress_db');
define('DB_USER', 'wp_user');
define('DB_PASSWORD', 'StrongPassword123!');
define('DB_HOST', 'localhost');

Cấu Hình Nginx cho WordPress

Tạo server block Nginx tối ưu cho WordPress:

nano /etc/nginx/sites-available/yourdomain.com
server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;
    root /var/www/yourdomain.com;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ .php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    }

    location ~ /.ht {
        deny all;
    }

    location ~* .(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
    }
}
ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx

Why Anubiz Host

100% async — no calls, no meetings
Delivered in days, not weeks
Full documentation included
Production-grade from day one
Security-first approach
Post-delivery support included

Ready to get started?

Skip the research. Tell us what you need, and we'll scope it, implement it, and hand it back — fully documented and production-ready.

Anubiz Chat AI

Online