.COM Domain Price Drop Just KES 999
India English
Kenya English
United Kingdom English
South Africa English
Nigeria English
United States English
United States Español
Indonesia English
Bangladesh English
Egypt العربية
Tanzania English
Ethiopia English
Uganda English
Congo - Kinshasa English
Ghana English
Côte d’Ivoire English
Zambia English
Cameroon English
Rwanda English
Germany Deutsch
France Français
Spain Català
Spain Español
Italy Italiano
Russia Русский
Japan English
Brazil Português
Brazil Português
Mexico Español
Philippines English
Pakistan English
Turkey Türkçe
Vietnam English
Thailand English
South Korea English
Australia English
China 中文
Somalia English
Canada English
Canada Français
Netherlands Nederlands

How to Host a PHP Website: A Beginner-Friendly Step-by-Step Guide

Buy domains, business emails, hosting, VPS and more: Get Started

Cheapest Domains in Kenya

Get your .Co.ke domain now for just KSh 999 (Back to 1200 in 7 days)

.CO.KE for KSh 999 | .COM for KSh 999

Hosting a PHP website might seem intimidating, but it’s straightforward once you break it down. 

So, if you’re building a personal blog, an e-commerce store, or a business site, this guide will walk you through every step.

Key Takeaways:

  • Learn to choose the right hosting plan for your needs.
  • Upload files, set up databases, and configure security.
  • Discover tools and tips to keep your site running smoothly.

1) Plan and Prepare Your Website

Choose a Hosting Provider

Pick a hosting provider that supports PHP and MySQL/MariaDB databases. 

For beginners, Truehost’s Shared Hosting (starting at KSh 199/month) is ideal. Advanced users might prefer our VPS Hosting for more control.

What to Look For:

  • Server location: Truehost’s servers in Kenya ensure faster speeds for local visitors.
  • Uptime: Truehost guarantees 99.9% uptime.
  • Support: 24/7 help via live chat or email.

Register a Domain Name

Your domain (e.g., www.yourstore.co.ke) is your website’s address. Truehost offers free domain registration with some plans.

Organize Your Files

Prepare your PHP files, images, and scripts. For example:

? my_website  

  ├── index.php  

  ├── contact.php  

  ├── styles.css  

  └── images/

Plan Your Database (If Needed)

Dynamic sites (like blogs or stores) need a database. Use tools like MySQL Workbench to design tables for users, products, or posts.

2) Set Up Your Truehost Account

i) Sign Up: Visit Truehost.co.ke, choose a plan, and complete registration.

ii) Access cPanel: For Shared Hosting, use Truehost’s cPanel to manage files, databases, and email.

iii) VPS Dashboard: For VPS plans, use SSH to configure your server.

3) Upload Your Website Files

Option A: Using File Manager (Beginner-Friendly)

  1. Log in to Truehost’s cPanel.
  2. Open File Manager → Navigate to public_html.
  3. Upload a ZIP file of your website folder and extract it.

Option B: Using FTP (Advanced)

i) Download FileZilla (free FTP tool).

ii) Enter Truehost’s FTP credentials:

  • Host: ftp.yourdomain.com
  • Username/Password: Provided in your welcome email.

iii) Drag files from your computer to public_html.

4) Create and Configure Your Database

For Shared Hosting:

  1. In cPanel, open MySQL Databases.
  2. Create a Database: Name it something like mywebsite_db., where mywebsite is the name of your domain.
  3. Add a User: Assign a username and password.
  4. Link User to Database: Grant “All Privileges.”

Update Your PHP Code:

<?php  
$servername = "localhost";  
$username = "mywebsite_user";  
$password = "SecurePassword123!";  
$dbname = "mywebsite_db";  

// Connect to the database  
$conn = new mysqli($servername, $username, $password, $dbname);  
?> 

For VPS Hosting:

i) Connect via SSH:

ssh root@your_server_ip  

ii) Install MySQL:

sudo apt install mysql-server  
sudo mysql_secure_installation  

iii) Create a database and user:

CREATE DATABASE mywebsite_db;  
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';  
GRANT ALL PRIVILEGES ON mywebsite_db.* TO 'user'@'localhost';  

5) Configure File Permissions and Security

  • File Permissions:
    • Folders: 755 (read/write/execute for owner, read/execute for others).
    • Files: 644 (read/write for owner, read-only for others).
  • .htaccess: Protect sensitive files with this code:
# Block access to .env files  
<Files .env>  
  Order allow,deny  
  Deny from all  
</Files>  

6) Test Your PHP Website

i) Visit your domain (e.g., https://yourstore.co.ke).

ii) Check for errors:

  • Blank page? Enable PHP error logging in php.ini:
display_errors = On  
error_reporting = E_ALL  
  • Database issues? Verify credentials in your PHP code.

7) Go Live and Maintain Your Site

Fix DNS Propagation Delays

It can take up to 48 hours for your domain to work globally. Use Cloudflare to speed this up.

Schedule Backups

Truehost offers daily backups for Shared Hosting. For VPS, automate backups with:

# Backup database daily  
0 3 * * * mysqldump -u user -p password mywebsite_db > /backups/db_backup.sql  

Boost Security

  • Update PHP versions in Truehost’s cPanel.
  • Use strong passwords (e.g., Ecommerce@2024!).
  • Install a free SSL certificate via Let’s Encrypt.

Example: Hosting a Simple PHP Page

  1. Create index.php:
<?php  
echo "<h1>Welcome to My Nairobi Coffee Shop!</h1>";  
echo "<p>Fresh coffee beans delivered across Kenya.</p>";  
?>  
  1. Upload it to public_html.
  2. Visit your domain. You’ll see:

Welcome to My Nairobi Coffee Shop!
Fresh coffee beans delivered across Kenya.

Why Truehost Makes PHP Hosting Easier

  • 1-Click PHP Install: Set up WordPress, Joomla, or custom PHP scripts in minutes.
  • Africa-Optimized Servers: Faster loading times for Kenyan and East African users.
  • Free Migration: Truehost’s team can move your existing site for free.

Ready to Launch?

Visit Truehost.co.ke to start with a Shared Hosting plan at KSh 199/month or scale up to VPS Hosting as your business grows.

Got questions? Truehost’s support team is just a click away!

Cheapest Domains in Kenya

Get your .Co.ke domain now for just KSh 999 (Back to 1200 in 7 days)

.CO.KE for KSh 999 | .COM for KSh 999

Mysson Victor
Author

Mysson Victor

Digital Marketer and SEO Strategist Nairobi

Mysson is a Digital Marketing Lead and SEO Strategist specializing in organic search growth, conversion optimization, and marketing systems built with artificial intelligence.

His work focuses on search engine optimization, content strategy, WordPress marketing infrastructure, AI driven automation, and online business growth.

Mysson has built and scaled several content driven websites to more than 50,000 monthly visitors through organic search, using advanced keyword research, search focused content creation, and conversion optimization strategies.

His publishing portfolio includes platforms such as The PennyMatters and Moneyspace, where he writes practical guides on personal finance, blogging, technology, and digital growth.

At Cloudoon, the company behind Truehost, Olitt, and CloudPap, Mysson serves as the Digital Marketing Lead, where he oversees SEO strategy, organic growth initiatives, and conversion focused marketing systems across multiple digital products.

Beyond SEO, Mysson designs high converting WordPress landing pages and marketing funnels, combining UX design, search intent, and conversion optimization to improve lead generation and revenue.

He also builds AI powered marketing systems using low code platforms such as Lovable and Google AI Studio, developing tools that automate content workflows, data analysis, and marketing operations.

Through his work in digital publishing and marketing technology, Mysson focuses on turning complex digital strategies into practical systems that help businesses and creators grow online.

View All Posts