NOTE
Bài viết này hướng dẫn chi tiết từng bước cài đặt WordPress lên server Ubuntu (VPS hoặc máy chủ vật lý), phù hợp cho cả người mới bắt đầu và webmaster muốn tự chủ hosting.
Chuẩn Bị VPS Ubuntu
- Đăng ký VPS tại các nhà cung cấp uy tín (Vultr, DigitalOcean, Linode, Hetzner...)
- Chọn hệ điều hành Ubuntu 22.04 LTS (khuyên dùng bản LTS mới nhất)
- Lưu lại IP, user (thường là
root
), mật khẩu hoặc SSH key

Kết Nối SSH Vào Server
ssh root@IP_VPS
Cập Nhật Hệ Thống
apt update && apt upgrade -y
Cài Đặt Web Server (LAMP hoặc LEMP)
A. Cài LAMP (Apache + MySQL + PHP)
apt install apache2 mysql-server php php-mysql libapache2-mod-php php-cli php-curl php-gd php-xml php-mbstring php-zip unzip -y
- Khởi động Apache và MySQL:
systemctl enable apache2 --now
systemctl enable mysql --now
B. Cài LEMP (Nginx + MySQL + PHP-FPM)
apt install nginx mysql-server php-fpm php-mysql php-cli php-curl php-gd php-xml php-mbstring php-zip unzip -y
- Khởi động Nginx và MySQL:
systemctl enable nginx --now
systemctl enable mysql --now
Tạo Database Cho WordPress
mysql -u root -p
CREATE DATABASE wordpress_db DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'matkhau_manh';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Tải Và Cài Đặt WordPress
cd /var/www
wget https://wordpress.org/latest.zip
unzip latest.zip
chown -R www-data:www-data wordpress
chmod -R 755 wordpress
- Đổi tên thư mục nếu muốn (ví dụ:
mv wordpress blog
)
Cấu Hình Virtual Host (Apache hoặc Nginx)
A. Apache
nano /etc/apache2/sites-available/yourdomain.com.conf
<VirtualHost *:80>
ServerName yourdomain.com
DocumentRoot /var/www/wordpress
<Directory /var/www/wordpress>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
a2ensite yourdomain.com.conf
a2enmod rewrite
systemctl reload apache2
B. Nginx
nano /etc/nginx/sites-available/yourdomain.com
server {
listen 80;
server_name yourdomain.com;
root /var/www/wordpress;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php-fpm.sock;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
systemctl reload nginx
Trỏ Domain Về Server
- Vào trang quản lý domain (Namecheap, Porkbun...)
- Trỏ bản ghi A về IP VPS
- Đợi DNS cập nhật (thường 5-30 phút)
Cài Đặt SSL Miễn Phí (Let’s Encrypt)
apt install certbot python3-certbot-apache # hoặc python3-certbot-nginx
- Apache:
certbot --apache -d yourdomain.com
- Nginx:
certbot --nginx -d yourdomain.com
- Thiết lập tự động gia hạn:
systemctl enable certbot.timer
Hoàn Tất Cài Đặt WordPress
- Truy cập
http://yourdomain.com
hoặchttps://yourdomain.com
- Làm theo hướng dẫn: chọn ngôn ngữ, nhập thông tin database, tạo tài khoản admin...
- Đăng nhập dashboard và bắt đầu xây dựng website!
Tối Ưu & Bảo Mật Cơ Bản
- Đổi đường dẫn đăng nhập (dùng plugin WPS Hide Login)
- Cài plugin bảo mật (Wordfence, Sucuri...)
- Cài plugin cache (WP Rocket, LiteSpeed Cache...)
- Luôn cập nhật WordPress, plugin, theme
- Đặt mật khẩu mạnh, bật xác thực 2 lớp
- Backup định kỳ (UpdraftPlus)
Câu Hỏi Thường Gặp (FAQ)
VPS Ubuntu tối thiểu cần cấu hình gì để chạy WordPress?
- RAM 1GB, CPU 1 core, SSD 20GB là đủ cho site nhỏ. Site lớn nên chọn 2GB RAM trở lên.
Có nên dùng LAMP hay LEMP?
- LEMP (Nginx) thường nhanh hơn, nhưng LAMP (Apache) dễ cấu hình hơn cho người mới.
Làm sao để tối ưu tốc độ WordPress?
- Dùng plugin cache, nén ảnh, bật HTTP/2, dùng CDN, tối ưu database.
Làm sao để backup website?
- Dùng plugin UpdraftPlus hoặc backup thủ công qua SSH.
Chúc bạn cài đặt WordPress thành công trên server Ubuntu!
Bình luận (0)
Table of Contents
- Chuẩn Bị VPS Ubuntu
- Kết Nối SSH Vào Server
- Cập Nhật Hệ Thống
- Cài Đặt Web Server (LAMP hoặc LEMP)
- A. Cài LAMP (Apache + MySQL + PHP)
- B. Cài LEMP (Nginx + MySQL + PHP-FPM)
- Tạo Database Cho WordPress
- Tải Và Cài Đặt WordPress
- Cấu Hình Virtual Host (Apache hoặc Nginx)
- A. Apache
- B. Nginx
- Trỏ Domain Về Server
- Cài Đặt SSL Miễn Phí (Let’s Encrypt)
- Hoàn Tất Cài Đặt WordPress
- Tối Ưu & Bảo Mật Cơ Bản
- Câu Hỏi Thường Gặp (FAQ)
- VPS Ubuntu tối thiểu cần cấu hình gì để chạy WordPress?
- Có nên dùng LAMP hay LEMP?
- Làm sao để tối ưu tốc độ WordPress?
- Làm sao để backup website?