How to Install WordPress: A Step-by-Step Guide for Beginners
Take control of your sites performance and security with a friendly, step-by-step approach tailored for beginners. Follow this practical walkthrough to install WordPress on VPS, configure your web stack and database, and deploy a secure, production-ready site.
Installing WordPress on a VPS gives you full control over performance, security, and scaling—critical considerations for site owners, developers, and businesses. This guide walks you through a practical, step-by-step process to install WordPress on a typical Linux VPS, explains the underlying components and common deployment scenarios, compares hosting approaches, and offers concrete recommendations for selecting a VPS suited to production workloads.
Prerequisites and high-level workflow
Before starting the installation, confirm these prerequisites are met on your VPS:
- Root or sudo-enabled user access to the server.
- A supported Linux distribution (Ubuntu 20.04+, Debian 10+, CentOS 7/8, etc.).
- At least 1 GB RAM (2 GB+ recommended for production), sufficient disk space and a public IP.
- A registered domain name with DNS A record pointing to the VPS IP.
- Basic knowledge of SSH, systemd services and editing config files.
The high-level workflow is:
- Provision a VPS and secure basic access.
- Install the web stack (LAMP: Apache/MySQL/PHP or LEMP: Nginx/MySQL/PHP-FPM).
- Create a MySQL database and user.
- Download and configure WordPress, set file permissions.
- Configure Nginx/Apache virtual host and SSL.
- Finalize via the WordPress web installer or WP-CLI.
Installing the web stack: LEMP vs LAMP
WordPress runs on PHP and requires a web server and a database. Two common stacks are:
- LAMP: Linux + Apache + MySQL/MariaDB + PHP. Apache is straightforward, supports .htaccess overrides and is compatible with many shared hosting setups.
- LEMP: Linux + Nginx + MySQL/MariaDB + PHP-FPM. Nginx excels in static content handling, concurrency and memory efficiency; recommended for VPS hosts serving medium-to-high traffic.
Below are concise installation commands for a LEMP stack on Ubuntu 22.04. Adjust package names for other distributions.
Install Nginx, MariaDB, PHP-FPM and common PHP extensions:
sudo apt update
sudo apt install nginx mariadb-server php-fpm php-mysql php-xml php-gd php-curl php-mbstring unzip -y
Then secure the database server:
sudo mysql_secure_installation
And create a WordPress database and user:
sudo mysql -u root -p
CREATE DATABASE wp_production DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON wp_production. TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Download and configure WordPress
Download the latest WordPress core, unpack and move files into the web root:
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
sudo mv wordpress /var/www/example.com
sudo chown -R www-data:www-data /var/www/example.com
sudo find /var/www/example.com -type d -exec chmod 755 {} ;
sudo find /var/www/example.com -type f -exec chmod 644 {} ;
Create a wp-config.php from the sample and set database credentials:
cd /var/www/example.com
cp wp-config-sample.php wp-config.php
nano wp-config.php
In wp-config.php, set the DB_NAME, DB_USER and DB_PASSWORD constants and add strong authentication keys (generate at https://api.wordpress.org/secret-key/1.1/salt/ and paste them into the file).
File permissions and security
- Owner: set to the webserver user (www-data for Debian/Ubuntu). This allows WordPress to write when needed (plugins, themes).
- File modes: directories 755, files 644. Prevent world writable files.
- Disable file editing inside the admin by adding
define('DISALLOW_FILE_EDIT', true);to wp-config.php for security.
Configure Nginx virtual host and PHP-FPM
Create an Nginx server block for your domain and point the root to the WordPress directory. A minimal Nginx config for WordPress with PHP-FPM:
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com;
index index.php index.html index.htm;
client_max_body_size 64M;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
}
location ~ .(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires max;
log_not_found off;
}
}
Enable the block and reload Nginx:
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
Secure the site with SSL (Let’s Encrypt)
Use Certbot to obtain and auto-renew certificates:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d example.com -d www.example.com
Certbot will update your Nginx configuration to redirect HTTP to HTTPS and configure the certificates. Verify auto-renewal with sudo certbot renew --dry-run.
Complete installation: WP-CLI vs Web installer
You can finish the install using the browser-based setup or via WP-CLI for automation and scripting.
Install WP-CLI and run:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
Then:
cd /var/www/example.com
wp core install --url="https://example.com" --title="Site Title" --admin_user="admin" --admin_password="strong_password" --admin_email="admin@example.com" --path=/var/www/example.com --allow-root
WP-CLI is invaluable for scripting installs, plugin/theme management, database exports and migrations.
Performance and caching recommendations
To achieve production-grade performance, implement these layers:
- PHP-FPM tuning: adjust pm.max_children, pm.start_servers and pm.max_requests based on available RAM and process size. Monitor with top/htop.
- Object caching: use Redis or memcached for persistent object cache via plugins like Redis Object Cache.
- Full-page caching: Nginx fastcgi_cache or a plugin like WP Super Cache / WP Rocket for cached HTML responses.
- CDN: offload static assets to a CDN (Cloudflare, BunnyCDN) to reduce origin load and latency.
- Database optimization: enable slow query log, run periodic OPTIMIZE TABLE, and consider separating database to a managed DB for large sites.
Security best practices
Hardening steps for a VPS-hosted WordPress include:
- Keep core, themes and plugins updated and remove unused plugins/themes.
- Install a WAF (Cloudflare or ModSecurity) and limit login attempts.
- Use SSH key authentication and disable password SSH logins.
- Configure a basic firewall (ufw or firewalld) to allow only necessary ports (80, 443, 22).
- Deploy intrusion detection and fail2ban to block brute-force attempts.
- Regular backups: use automated offsite backups (rsync to object storage, scheduled mysqldump to S3-compatible storage) and test restores.
Application scenarios and when to choose a VPS
WordPress on a VPS is suitable when you need:
- Full control over server stack for custom performance tuning or compliance requirements.
- Isolated resources for predictable performance (unlike noisy-shared hosting).
- Ability to run additional services (Elasticsearch, Redis, Node services) alongside WordPress.
- Scalability strategies: vertical scaling for resources, or horizontal scaling with load balancers and separate DB nodes for high-traffic sites.
For small personal blogs, managed WordPress hosting may be simpler. For businesses, agencies, and developers requiring flexibility, a VPS is often the best balance of cost and control.
Advantages comparison: managed hosting vs VPS
Key points to consider:
- Managed WordPress Hosting: Pros – automatic updates, simplified dashboard, built-in caching and security. Cons – limited control, higher cost, plugin restrictions.
- VPS Hosting: Pros – full root access, customizable stack, cost-effective for advanced users, better for multi-application deployments. Cons – you are responsible for maintenance, security and updates.
In short, choose managed hosting for convenience; choose a VPS for control and extensibility.
Choosing a VPS: practical suggestions
When selecting a VPS for WordPress, evaluate the following:
- CPU and RAM: Start with 2 vCPUs and 2–4 GB RAM for small business sites; scale up as traffic grows.
- Disk type: Prefer NVMe or SSD for fast I/O. Database-heavy sites benefit significantly from fast storage.
- Network and location: Pick a datacenter close to your audience to reduce latency. Consider multiple locations for redundancy or distributed audiences.
- Backups and snapshots: Ensure automated snapshots and backups are available and test restores periodically.
- Support and SLAs: For mission-critical sites choose providers with responsive support and clear SLAs.
For readers interested in reliable VPS options, consider providers that offer US-based nodes with strong networking and SSD storage. For example: USA VPS from VPS.DO provides a range of plans suitable for staging and production WordPress deployments, with fast NVMe storage and global connectivity.
Maintenance and operational tips
Once WordPress is running, implement an operational checklist:
- Automate daily or weekly backups for files and DB; keep at least one offsite copy.
- Monitor performance (New Relic, Prometheus + Grafana) and logs for anomalies.
- Schedule maintenance windows for major updates and test on staging first.
- Use version control for themes/plugins you develop; deploy via CI/CD to avoid manual mistakes.
- Document server configuration and recovery steps for your team.
Summary
Installing WordPress on a VPS gives you the flexibility to optimize performance, enforce security controls and scale according to demand. The core steps are provisioning the VPS, installing a LEMP/LAMP stack, creating a database, configuring WordPress and securing the site with SSL and hardening measures. For production-grade sites, incorporate caching, persistent object stores, backups and monitoring. Choose a VPS plan with sufficient CPU, RAM and fast NVMe storage, and ensure automated backups and support are available.
If you need a reliable hosting foundation in the United States with a variety of resource tiers and NVMe performance, you can explore plans at VPS.DO — USA VPS to find an option that fits your WordPress deployment strategy.