Tutorials

Deploy WordPress

WordPress is the most popular content management system, powering over 40% of all websites. This guide covers installing WordPress on a LAMP stack (Linux, Apache, MariaDB, PHP) on Ubuntu.

Requirements

  • A VPS running Ubuntu 20.04+ or Debian 11+
  • Root or sudo access
  • At least 1 GB RAM and 10 GB free disk space
  • A domain name pointed at your server's IP address

1. Connect to Your Server

ssh root@YOUR_SERVER_IP

Or use the web terminal in the Sitequest dashboard.

2. Install Apache

apt update
apt install -y apache2
systemctl enable apache2

Verify Apache is running by visiting http://YOUR_SERVER_IP in your browser.

3. Install MariaDB

apt install -y mariadb-server

Secure the installation:

mysql_secure_installation

Follow the prompts to set a root password, remove anonymous users, disallow remote root login, and remove the test database.

MariaDB is a drop-in replacement for MySQL with better performance and lower memory usage -- ideal for VPS deployments.

4. Create a Database for WordPress

mysql -u root -p
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'YOUR_STRONG_PASSWORD';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace YOUR_STRONG_PASSWORD with a secure password.

5. Install PHP

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

Verify PHP is working:

php -v

6. Download WordPress

cd /tmp
curl -LO https://wordpress.org/latest.tar.gz
tar xzf latest.tar.gz

Move the files to the web root:

cp -a /tmp/wordpress/. /var/www/html/wordpress
chown -R www-data:www-data /var/www/html/wordpress
chmod -R 755 /var/www/html/wordpress

7. Configure Apache Virtual Host

Create a virtual host configuration:

nano /etc/apache2/sites-available/wordpress.conf
<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/html/wordpress

    <Directory /var/www/html/wordpress>
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log
    CustomLog ${APACHE_LOG_DIR}/wordpress_access.log combined
</VirtualHost>

Enable the site and required modules:

a2ensite wordpress.conf
a2enmod rewrite
a2dissite 000-default.conf
systemctl reload apache2

8. Configure WordPress

Copy the sample configuration file:

cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php

Edit the database settings:

nano /var/www/html/wordpress/wp-config.php

Update these lines with your database credentials:

define('DB_NAME', 'wordpress');
define('DB_USER', 'wpuser');
define('DB_PASSWORD', 'YOUR_STRONG_PASSWORD');
define('DB_HOST', 'localhost');

Also replace the salt keys with fresh values from the WordPress secret key generator.

9. Complete the Installation

Open http://YOUR_DOMAIN in your browser. The WordPress installer will guide you through:

  1. Selecting your language
  2. Setting the site title
  3. Creating an admin account
  4. Finalizing the installation

10. Secure Your WordPress Installation

  • Set up Let's Encrypt SSL for HTTPS
  • Install a security plugin (e.g., Wordfence or Sucuri)
  • Keep WordPress, themes, and plugins updated
  • Disable file editing in the admin panel by adding to wp-config.php:
define('DISALLOW_FILE_EDIT', true);

Alternative: Using Nginx

If you prefer Nginx over Apache, install Nginx first, then use php-fpm instead of libapache2-mod-php:

apt install -y php-fpm

Configure Nginx to pass PHP requests to the FPM socket:

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

Alternative: Using OpenLiteSpeed

OpenLiteSpeed offers excellent WordPress performance with built-in caching. It supports .htaccess files, making it compatible with most WordPress plugins out of the box.

Install OpenLiteSpeed and PHP:

apt install -y wget
wget -O - https://repo.litespeed.sh | bash
apt install -y openlitespeed lsphp83 lsphp83-mysql lsphp83-curl lsphp83-gd lsphp83-mbstring lsphp83-xml lsphp83-zip lsphp83-intl

Link the PHP binary:

ln -sf /usr/local/lsws/lsphp83/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp

Copy WordPress to the OpenLiteSpeed web root:

cp -a /tmp/wordpress/. /usr/local/lsws/DEFAULT/html/wordpress
chown -R nobody:nogroup /usr/local/lsws/DEFAULT/html/wordpress

Access the admin panel at https://YOUR_SERVER_IP:7080 (default credentials: admin / password set during install) to configure your virtual host and document root.

After setup, install the LiteSpeed Cache plugin in WordPress for optimal caching performance.

Next Steps