One-Click WordPress on Ubuntu 24.04 for Small Business Sites
Introduction
This guide will walk you through installing WordPress on a ServerStadium VM or a ServerStadium dedicated server running Ubuntu 24.04. We’ll cover both Apache (LAMP) and Nginx (LEMP), free SSL with Let’s Encrypt, and simple backup & update routines—everything a small business needs to get online quickly with great performance.
Prerequisites
- A ServerStadium VM or dedicated server with Ubuntu 24.04 and a domain pointed to your server’s IP.
- SSH access with a sudo-capable user.
- An email address for Let’s Encrypt notifications (recommended).
Option A: LAMP (Apache) Quick Install
This path uses Apache + PHP + MySQL and enables HTTPS via the Certbot Apache plugin.
1) Update and install packages
sudo apt update && sudo apt -y upgrade
sudo apt -y install apache2 mysql-server php php-mysql php-curl php-xml php-gd php-zip php-mbstring php-intl unzip
sudo a2enmod rewrite
sudo systemctl enable --now apache2 mysql
2) Secure MySQL & create the WordPress database
sudo mysql_secure_installation
sudo mysql -e "CREATE DATABASE wpdb DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;"
sudo mysql -e "CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'ChangeThisStrongPassword!';"
sudo mysql -e "GRANT ALL PRIVILEGES ON wpdb.* TO 'wpuser'@'localhost'; FLUSH PRIVILEGES;"
3) Download & place WordPress
cd /tmp
curl -LO https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
sudo rsync -a wordpress/ /var/www/html/
sudo chown -R www-data:www-data /var/www/html
sudo find /var/www/html -type d -exec chmod 755 {} \;
sudo find /var/www/html -type f -exec chmod 644 {} \;
4) Configure Apache vHost (replace example.com
with your domain)
sudo tee /etc/apache2/sites-available/wordpress.conf >/dev/null <<'EOF'
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html
<Directory /var/www/html>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/wp_error.log
CustomLog ${APACHE_LOG_DIR}/wp_access.log combined
</VirtualHost>
EOF
sudo a2ensite wordpress.conf
sudo systemctl reload apache2
5) Create wp-config.php
and add secure keys
cd /var/www/html
cp wp-config-sample.php wp-config.php
sed -i "s/database_name_here/wpdb/g; s/username_here/wpuser/g; s/password_here/ChangeThisStrongPassword!/g" wp-config.php
curl -s https://api.wordpress.org/secret-key/1.1/salt/ | sudo tee /tmp/wp.keys >/dev/null
sudo awk 'BEGIN{print "[MARK]"}1' wp-config.php | sed -e "/\[MARK\]/r /tmp/wp.keys" -e "/\[MARK\]/d" | sudo tee wp-config.php.new >/dev/null
sudo mv wp-config.php.new wp-config.php
sudo chown www-data:www-data wp-config.php
6) Enable HTTPS (Let’s Encrypt)
sudo apt -y install certbot python3-certbot-apache
sudo certbot --apache -d example.com -d www.example.com --redirect -m you@example.com --agree-tos -n
Option B: LEMP (Nginx) Quick Install
Prefer Nginx? Use PHP-FPM + Nginx + MySQL, then secure with Certbot’s Nginx plugin.
1) Install Nginx, PHP-FPM, MySQL
sudo apt update
sudo apt -y install nginx mysql-server php-fpm php-mysql php-curl php-xml php-gd php-zip php-mbstring php-intl unzip
sudo systemctl enable --now nginx mysql
2) Database (same as LAMP) — reuse the MySQL commands above to create wpdb
/wpuser
.
3) Download & set permissions (same as LAMP), but place WordPress at /var/www/wordpress
for clarity:
sudo mkdir -p /var/www/wordpress
sudo rsync -a /tmp/wordpress/ /var/www/wordpress/
sudo chown -R www-data:www-data /var/www/wordpress
4) Nginx server block (replace example.com
):
sudo tee /etc/nginx/sites-available/wordpress >/dev/null <<'EOF'
server {
listen 80;
server_name example.com www.example.com;
root /var/www/wordpress;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php-fpm.sock;
}
location ~* \.(png|jpg|jpeg|gif|ico|css|js)$ {
expires max;
log_not_found off;
}
}
EOF
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress
sudo nginx -t && sudo systemctl reload nginx
5) Create wp-config.php
and salts (same as LAMP, but in /var/www/wordpress
):
cd /var/www/wordpress
cp wp-config-sample.php wp-config.php
sed -i "s/database_name_here/wpdb/g; s/username_here/wpuser/g; s/password_here/ChangeThisStrongPassword!/g" wp-config.php
curl -s https://api.wordpress.org/secret-key/1.1/salt/ | sudo tee -a wp-config.php >/dev/null
sudo chown www-data:www-data wp-config.php
6) Enable HTTPS (Let’s Encrypt)
sudo apt -y install certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com --redirect -m you@example.com --agree-tos -n
Finish Setup in the Browser
Visit https://example.com
to complete the WordPress installer (site title, admin user). After logging in, go to Settings → Permalinks and click Save once to ensure pretty URLs work.
Performance & Security Basics
- Permalinks & rewrites: Apache needs
AllowOverride All
and Nginx uses thetry_files
rule shown above. - PHP modules: We installed commonly needed modules (curl, xml, gd, zip, mbstring, intl) for plugin/theme compatibility.
- Auto-renew TLS: Certbot installs a timer by default. Verify with
systemctl status certbot.timer
. - Admin hygiene: Use strong passwords, enable two-factor for wp-admin, and keep plugins/themes minimal.
Simple Backups (Files + Database)
Create a quick backup script and schedule it with cron.
sudo mkdir -p /opt/wp-backups
sudo tee /opt/wp-backups/backup.sh >/dev/null <<'EOF'
#!/usr/bin/env bash
set -e
TS=$(date +%F-%H%M)
SITE_ROOT="/var/www/html" # or /var/www/wordpress for Nginx option
DB_NAME="wpdb"
DB_USER="wpuser"
DB_PASS="ChangeThisStrongPassword!"
mkdir -p /opt/wp-backups/${TS}
mysqldump -u ${DB_USER} -p${DB_PASS} ${DB_NAME} | gzip > /opt/wp-backups/${TS}/db.sql.gz
tar -czf /opt/wp-backups/${TS}/wp-files.tgz -C "${SITE_ROOT}" .
find /opt/wp-backups -type d -mtime +14 -exec rm -rf {} \; 2>/dev/null || true
EOF
sudo chmod +x /opt/wp-backups/backup.sh
echo "0 3 * * * root /opt/wp-backups/backup.sh" | sudo tee /etc/cron.d/wp-backup >/dev/null
Keeping WordPress Updated
- Core/plugin/theme updates: In Dashboard → Updates, apply updates weekly.
- CLI (optional): Install WP-CLI for scripted updates:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && php wp-cli.phar --info
. - Backups first: Run your backup script before major updates or theme changes.
One-Click Installer (Optional)
Prefer a single command? This script asks for your domain, email, and stack (LAMP or LEMP), then installs WordPress with HTTPS automatically.
cat <<'SCRIPT' > ~/oneclick-wp.sh
#!/usr/bin/env bash
set -euo pipefail
read -rp "Domain (e.g., example.com): " DOMAIN
read -rp "Email for Let's Encrypt: " EMAIL
read -rp "Stack [lamp|lemp]: " STACK
DB_NAME="wpdb"; DB_USER="wpuser"; DB_PASS="$(tr -dc A-Za-z0-9_@%+ | head -c 20)"
sudo apt update
if [[ "$STACK" == "lamp" ]]; then
sudo apt -y install apache2 mysql-server php php-mysql php-fpm php-curl php-xml php-gd php-zip php-mbstring php-intl unzip certbot python3-certbot-apache
sudo a2enmod rewrite
sudo systemctl enable --now apache2 mysql
sudo mysql -e "CREATE DATABASE ${DB_NAME} DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;"
sudo mysql -e "CREATE USER '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PASS}'; GRANT ALL ON ${DB_NAME}.* TO '${DB_USER}'@'localhost'; FLUSH PRIVILEGES;"
cd /tmp && curl -LO https://wordpress.org/latest.tar.gz && tar -xzf latest.tar.gz
sudo rsync -a wordpress/ /var/www/html/
sudo chown -R www-data:www-data /var/www/html
sudo tee /etc/apache2/sites-available/wordpress.conf >/dev/null </dev/null
sudo certbot --apache -d "${DOMAIN}" -d "www.${DOMAIN}" --redirect -m "${EMAIL}" --agree-tos -n
else
sudo apt -y install nginx mysql-server php-fpm php-mysql php-curl php-xml php-gd php-zip php-mbstring php-intl unzip certbot python3-certbot-nginx
sudo systemctl enable --now nginx mysql
sudo mysql -e "CREATE DATABASE ${DB_NAME} DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;"
sudo mysql -e "CREATE USER '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PASS}'; GRANT ALL ON ${DB_NAME}.* TO '${DB_USER}'@'localhost'; FLUSH PRIVILEGES;"
cd /tmp && curl -LO https://wordpress.org/latest.tar.gz && tar -xzf latest.tar.gz
sudo mkdir -p /var/www/wordpress && sudo rsync -a wordpress/ /var/www/wordpress/
sudo chown -R www-data:www-data /var/www/wordpress
sudo tee /etc/nginx/sites-available/wordpress >/dev/null </dev/null
sudo certbot --nginx -d "${DOMAIN}" -d "www.${DOMAIN}" --redirect -m "${EMAIL}" --agree-tos -n
fi
echo "DB: ${DB_NAME} USER: ${DB_USER} PASS: ${DB_PASS}"
echo "Open https://${DOMAIN} to finish WordPress setup."
SCRIPT
chmod +x ~/oneclick-wp.sh
bash ~/oneclick-wp.sh
Troubleshooting
- White page / 502 errors: Check PHP-FPM/Apache status:
systemctl status php*-fpm apache2 nginx
. - Permalinks not working (Apache): Confirm
AllowOverride All
and thatmod_rewrite
is enabled. - SSL issuance fails: Confirm DNS A/AAAA records point to your server and re-run Certbot with
--apache
or--nginx
.
Need a faster start? Choose a low-cost, instant ServerStadium dedicated server and be online today.
Conclusion
That’s it—your small business WordPress site is live with modern PHP, a secure database, and free SSL on high-performance ServerStadium hardware. For more help or information about ServerStadium services, visit our knowledge base or the ServerStadium website.