Servers & VPS

How to Install WordPress on a Linux VPS in Mexico

Step-by-step guide to installing WordPress on a Linux VPS from scratch, with real commands and security tips for websites in Mexico.

Detailed image of a server rack with glowing lights in a modern data center.

To install WordPress on a Linux VPS you need to set up a LAMP stack (Linux, Apache, MySQL, PHP), create a database, and copy the CMS files — the entire process takes 30 to 60 minutes if you follow this guide.

Unlike shared hosting, a VPS gives you full control over the server. You choose PHP versions, adjust memory limits, and enable exactly the modules WordPress needs. This guide uses Ubuntu 22.04 LTS, the most common distribution among VPS providers in Mexico.

Prerequisites

Before you start, make sure you have the following:

  • A VPS running Ubuntu 22.04 (minimum 1 GB RAM; 2 GB is recommended for production).
  • SSH access as a user with sudo privileges.
  • A domain pointing to the VPS IP (A records configured).
  • Ports 22, 80, and 443 open in your provider's firewall.

If your VPS is brand new, check out our VPS servers category for guidance on choosing the right plan before installing WordPress.

Step 1 — Install the LAMP Stack

The LAMP stack is the foundation WordPress runs on. Install the four components in this order:

Update the system

sudo apt update && sudo apt upgrade -y

Install Apache

sudo apt install apache2 -y
sudo systemctl enable apache2
sudo systemctl start apache2

Install MariaDB (recommended over vanilla MySQL)

sudo apt install mariadb-server -y
sudo mysql_secure_installation

During mysql_secure_installation, answer Y to all prompts: remove anonymous users, disable remote root login, and drop the test database. This seals the most common security gaps.

Install PHP and required extensions

sudo apt install php libapache2-mod-php php-mysql \
  php-curl php-gd php-mbstring php-xml php-xmlrpc \
  php-soap php-intl php-zip -y

WordPress requires at least PHP 7.4; installing PHP 8.2 improves performance by 15–25% according to the CMS's own benchmarks.

Step 2 — Create the WordPress Database

WordPress stores all its content in MySQL/MariaDB. Create a dedicated database and user — never use root for the application.

sudo mysql -u root -p

Once inside the MariaDB prompt, run:

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;

Use a long, random password. Special characters are fine — WordPress's database driver handles them correctly through parameterized credentials.

Step 3 — Download and Install WordPress

Always download the latest version directly from wordpress.org:

cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
sudo mv wordpress /var/www/html/yoursite.com

Set permissions so Apache can read and write where WordPress needs:

sudo chown -R www-data:www-data /var/www/html/yoursite.com
sudo find /var/www/html/yoursite.com -type d -exec chmod 755 {} \;
sudo find /var/www/html/yoursite.com -type f -exec chmod 644 {} \;

Create wp-config.php

cd /var/www/html/yoursite.com
sudo cp wp-config-sample.php wp-config.php
sudo nano wp-config.php

Edit the following lines with your database credentials:

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

Also replace the security salts using the official generator: https://api.wordpress.org/secret-key/1.1/salt/

Step 4 — Configure Apache for WordPress

Create a dedicated VirtualHost for your site:

sudo nano /etc/apache2/sites-available/yoursite.com.conf

Paste the following block:

<VirtualHost *:80>
    ServerName yoursite.com
    ServerAlias www.yoursite.com
    DocumentRoot /var/www/html/yoursite.com

    <Directory /var/www/html/yoursite.com>
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/yoursite-error.log
    CustomLog ${APACHE_LOG_DIR}/yoursite-access.log combined
</VirtualHost>

Enable the site and the rewrite module (required for WordPress permalinks):

sudo a2ensite yoursite.com.conf
sudo a2enmod rewrite
sudo systemctl reload apache2

Step 5 — Enable HTTPS with Let's Encrypt

HTTPS is non-negotiable in 2025: Google requires it for ranking and browsers flag HTTP as insecure.

sudo apt install certbot python3-certbot-apache -y
sudo certbot --apache -d yoursite.com -d www.yoursite.com

Certbot configures the HTTP-to-HTTPS redirect automatically and renews the certificate every 90 days. Verify that automatic renewal is active:

sudo systemctl status certbot.timer

Step 6 — Complete the Installation via Browser

Open https://yoursite.com in your browser. The WordPress wizard will ask for:

  1. Site title.
  2. Admin username and password (use a strong password, not "admin").
  3. Admin email address.

Click Install WordPress and within 30 seconds you will have access to the dashboard at /wp-admin.

Recommended Post-Installation Security Settings

  • Change the table prefix: in wp-config.php, change $table_prefix = 'wp_'; to something random like 'x7k2_'.
  • Disable file editing from the dashboard: add define('DISALLOW_FILE_EDIT', true); to wp-config.php.
  • Limit login attempts: install a plugin like Limit Login Attempts Reloaded.
  • Enable a Web Application Firewall (WAF): the free tier of Wordfence covers the most common attack vectors.
  • Set up automatic backups: UpdraftPlus to an external bucket (not on the same VPS).

If you need professional support for your infrastructure, elenlace.com offers server configuration and maintenance services for businesses in Mexico.

Key takeaways

  • The LAMP stack (Linux, Apache, MariaDB, PHP) is the minimum foundation for running WordPress on a VPS.
  • Always create a dedicated database user for WordPress; never use root.
  • 755/644 permissions and the www-data owner prevent most write-permission issues.
  • HTTPS with Let's Encrypt is free, automatic, and mandatory.
  • Post-installation security settings (table prefix, DISALLOW_FILE_EDIT, WAF) dramatically reduce the attack surface.
  • PHP 8.2 improves WordPress performance by up to 25% compared to older versions.

Ready to launch your site on your own VPS? Contact us at elenlace.com and we will help you choose the right plan, configure the server, and lock it down from day one.

FAQ

How much RAM does a VPS need to run WordPress?

With 1 GB of RAM you can run a low-to-medium traffic WordPress site. For sites with more than 10,000 monthly visitors or WooCommerce, 2 GB or more is recommended. Caching (Redis or Memcached) significantly reduces memory consumption.

Is it better to use Apache or Nginx for WordPress on a VPS?

Apache is easier to configure with WordPress thanks to native .htaccess support and the mod_rewrite module. Nginx has better performance under high concurrency but requires manual rewrite rule configuration. For most sites in Mexico, Apache is the more practical choice.

Can I migrate an existing WordPress site to a VPS?

Yes. The standard process is: install WordPress on the VPS, export the database from the previous host with mysqldump, import it on the new server, copy wp-content files, and update wp-config.php. Plugins like All-in-One WP Migration automate most of the process.

What if I make a mistake in the Apache configuration?

Apache has the apachectl configtest command, which validates your configuration file syntax before reloading the service. If there is an error, it shows you exactly which line the problem is on, without interrupting the running server.

Compare providers

Other providers and guides worth comparing:

← All