WordPress VPS template on HostAfrica

WordPress implementation on HostAfrica

Russell

Last Update 2 months ago

What is Self-Hosted WordPress?

Self-Hosted WordPress gives you complete control of your website on a dedicated VPS environment. Unlike shared hosting, your site runs on isolated resources with a dedicated IP for improved performance, security, and reliability. With full root access, you can customize your server, install additional tools, and scale as needed perfect for business sites, developers, agencies, and anyone who wants a powerful, flexible WordPress setup.

EXAMPLE USE CASES

Business Websites: Run professional corporate websites with full control over performance, security, and customization without the limitations of shared hosting.

E-commerce Sites: Host WooCommerce stores with dedicated resources ensuring fast page loads, secure transactions, and the ability to handle traffic spikes.


Development & Staging: Create isolated development environments for testing themes, plugins, and updates before deploying to production sites.


Agency Client Sites: Manage multiple client WordPress installations with full server access, custom configurations, and white-label control panels.


High-Traffic Blogs: Run content-heavy blogs and news sites with optimized caching, CDN integration, and resources dedicated solely to your site.


Membership Sites: Host subscription-based platforms with secure login systems, protected content, and reliable uptime for paying members.

Implementation on HostAfrica:

Our Self-Hosted WordPress implementation includes CloudPanel, a modern server control panel that makes managing WordPress simple and efficient. The setup provides:

  • Dual Admin Interfaces: CloudPanel for server management (cp.yourdomain.com) and WordPress admin for content management (yourdomain.com/wp-admin)

  • Automatic SSL: Let's Encrypt certificates automatically installed and renewed for both domains

  • WP-CLI Integration: Command-line tool for advanced WordPress management

  • Single Sign-On: One set of credentials (admin username) for both CloudPanel and WordPress

  • Automated Deployment: Complete setup in 3-5 minutes via Cloud-init automation

ComponentDescription
Ubuntu 24.04Long-term support base operating system
CloudPanelWeb-based server control panel for site, database, and SSL management
WordPressLatest WordPress version with auto-installation
NGINXHigh-performance web server with HTTP/2 support
PHP-FPM 8.4Latest PHP version optimized for WordPress
MySQL 8.4Database server with WordPress-optimized configuration
Let's EncryptFree automatic SSL certificate provisioning
Cloud-initAutomated provisioning system
UFW FirewallPre-configured with secure port rules
Architecture Diagram

WordPress Template Implementation

The deployment is fully automated using Cloud-init provisioning. All configuration happens during the first boot, creating a production-ready WordPress environment without manual intervention.

Directory Structure:
  • WordPress Files: /home/wordpress/htdocs/{domain}/

  • CloudPanel Config: /home/clp/

  • Cloud-init Logs: /var/log/cloud-init-output.log

  • NGINX Config: /etc/nginx/sites-enabled/

Service Endpoints:
ServiceURLPort
WordPress Sitehttps://{domain}443
WordPress Admin
https://{domain}/wp-admin
443
CloudPanel GUI
https://cp.{domain}
443
CloudPanel Directhttps://{server_ip}:84438443
SSH Access
{server_ip}
22

Environment Variables: 

Cloud-init uses variables passed from the provisioning system to configure the WordPress installation:

VariableDescription
Example
{$domain}Primary domain nameexample-wordpress-wordpress-wordpress.hcloud.app
{$passwordHash}Hashed root passwordAuto-generated
{$customfields.app_login}Admin usernameadmin
{$customfields.app_pass}Admin passwordAuto-generated alphanumeric
Default Configuration:


  • Admin Username: admin (used for both CloudPanel and WordPress)

  • Admin Password: Auto-generated 16-character alphanumeric password

  • Database Name: wordpress

  • Database User: wordpress

  • Database Password: Auto-generated during deployment

  • PHP Version: 8.4

  • CloudPanel Domain: cp.{domain}

Cloud-init Functionality:

Cloud-init automates the complete WordPress deployment process during the first VM boot. The script:

  1. Sets the hostname and root password

  2. Waits for CloudPanel to be ready (30 seconds)

  3. Creates CloudPanel admin user with provided credentials

  4. Configures reverse proxy for CloudPanel access via custom domain

  5. Installs SSL certificate for CloudPanel domain

  6. Creates PHP 8.4 site for the main domain

  7. Creates MySQL database with secure credentials

  8. Downloads and installs latest WordPress

  9. Configures WordPress with database connection

  10. Completes WordPress installation with admin user

  11. Sets correct file permissions

  12. Installs SSL certificate for WordPress domain

Total Deployment Time: 3-5 minutes from provisioning to production-ready

The CloudPanel reverse proxy is created to allow access to the CloudPanel web interface via a custom domain name instead of the default IP address and port (usually https://server-ip:8443). This makes it easier for users to remember and access the panel.


Additionally, the reverse proxy handles SSL termination, allowing secure HTTPS connections with a valid SSL certificate (e.g., via Let’s Encrypt), without requiring CloudPanel itself to manage certificates directly. It also provides flexibility for managing traffic, improving security, and allowing CloudPanel to coexist with other services on the same server.

How to Access WordPress & CloudPanel:

WordPress Admin Access

After deployment, access your WordPress admin dashboard:

URL: https://{domain}/wp-adminUsername: admin (or custom value from app_login field)Password: Auto-generated (provided in provisioning confirmation)

CloudPanel Access

Manage your server, databases, and SSL certificates:

Primary URL: https://cp.{domain}
Fallback
URL: https://{server_ip}:8443
Username: admin (same as WordPress)
Password: Same password as WordPress

Note: Both CloudPanel and WordPress use the same login credentials for simplicity.





How to change CloudPanel domain:
  1. Login to CloudPanel Admin Area.

  2. Go to Settings.

  3. Ensure you create an A record for your new domain (e.g., cp.domain.com) in your DNS manager, pointing to the WordPress VPS IP.

  4. Add the domain in CloudPanel and save.

  5. Your CloudPanel URL should now be cp.domain.com.

How to Change WordPress Site Domain/URL

  1. Ensure you create an A record for your new domain (e.g., domain.com) in your DNS manager, pointing to the WordPress VPS IP.

  2. Login to the CloudPanel GUI.

  3. Navigate to Sites → Your Domain → Manage

  4. Navigate to the vhost settings

  5. Change the server_name for both ports 80 and 8080 to your new domain.

  1. Click Save.

  2. At this point, the new domain should load without SSL.





Install SSL for the new Domain

Run via Terminal: 

Then Reload nginx: 

Update WordPress URL's via WP-CLI
Replace yourolddomain with your current site path, and NEWDOMAIN/OLDDOMAIN as appropriate.
OPTIONAL: Verify URL's 
Both should now return the new domain.



Password Management: 
Password Reset (Admin):

Administrators can reset both CloudPanel and WordPress passwords simultaneously:

  1. Access your server via SSH

  2. Execute password reset commands:

Note: Passwords must be alphanumeric only (A-Z, a-z, 0-9) - no special characters, as CloudPanel doesn't accept them.




Useful Commands: 
WordPress Management (WP-CLI)
CloudPanel CLI Commands:
System Management:
Firewall Configuration:

The server comes with UFW (Uncomplicated Firewall) pre-configured with secure rules:

Firewall Commands:
Issues You Could Encounter:
1. Domain Not Accessible (ERR_SSL_PROTOCOL_ERROR)
 

Cause: Cloud-init script failed to run or SSL installation failed

Solution:
2. CloudPanel Not Accessible

Cause: Firewall blocking ports or service not running

Solution:

3. WordPress Shows Database Connection Error


Cause: Database credentials mismatch

Solution:


4. SSL Certificate Installation Failed


Cause: DNS records not propagated or ports 80/443 blocked

Solution:

  • Verify DNS A record points to server IP

  • Check ports are open: ufw status

  • Wait 5-10 minutes for DNS propagation

  • Retry SSL installation via CloudPanel

5. Password Contains Special Characters Not Accepted


Cause: CloudPanel doesn't accept certain special characters

Solution: Use alphanumeric passwords only (A-Z, a-z, 0-9)

6. File Permission Issues


Cause: Incorrect ownership of WordPress files

Solution:

Best PracticeSecurity
  • Change default admin username after first login

  • Use strong alphanumeric passwords (16+ characters)

  • Keep WordPress, themes, and plugins updated

  • Install a security plugin (Wordfence, Sucuri)

  • Enable two-factor authentication

  • Regular database backups via CloudPanel

Performance
  • Install a caching plugin (WP Super Cache, W3 Total Cache)

  • Use a CDN for static assets

  • Optimize images before uploading

  • Remove unused themes and plugins

  • Enable CloudPanel's built-in caching features

Maintenance
  • Schedule regular backups (daily recommended)

  • Monitor disk space usage

  • Review CloudPanelgs periodically

  • Test updates on staging before production

  • Keep SSH keys secure and rotate regularly



Additional Resources:


Was this article helpful?

0 out of 0 liked this article

Still need help? Message Us