CoachingUgosay

How to Install WordPress with Git on Localhost (Ubuntu & Windows)

Soundiraraj M

Soundiraraj M

Senior WebCoder

Video Thumbnail

Introduction

When you’re starting your career in web development, the first step is always learning how to set up your environment properly. Installing WordPress locally is not just about “running a CMS on your computer.” It’s about learning the same professional practices companies use:

  • Working safely in a local setup
  • Tracking your changes with Git
  • Understanding how development differs on Linux (Ubuntu) and Windows

In this guide, I’ll walk you through everything step-by-step, as if we’re doing it together in a lab.


Why Local Setup + Git?

Before diving into commands, let’s understand why we do this.

  • Local environment → You don’t need hosting or domain names; everything runs offline.
  • Safe testing → Break things locally without worrying about a live website.
  • Git version control → Helps you track changes, roll back if you make mistakes, and collaborate with teammates.
  • Cross-platform setup → Some of you will use Ubuntu (Linux) while others prefer Windows. Companies expect you to be comfortable in both.

1. Prerequisites (Before You Start)

Make sure you have these basics installed:

  • PHP (7.4 or higher)
  • MySQL or MariaDB
  • Apache/Nginx web server
  • Git
  • Composer (optional, for managing PHP dependencies)

2. Setting Up WordPress on Ubuntu

If you’re using Ubuntu Linux, you first need a LAMP stack (Linux, Apache, MySQL, PHP).

👉 I recommend following this detailed step-by-step guide here:
🔗 How to Install LAMP Stack on Ubuntu

Once your LAMP stack is ready:

Step 1: Create a Database

Open MySQL in terminal:

sudo mysql -u root -p

Now create a database and user:

CREATE DATABASE wordpress_db;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 2: Download and Configure WordPress

cd /var/www/html
sudo wget https://wordpress.org/latest.zip
sudo apt install unzip
sudo unzip latest.zip
sudo mv wordpress mysite
sudo chown -R www-data:www-data mysite

Now open a browser and go to:

http://localhost/mysite

Follow the on-screen WordPress installer.


3. Setting Up WordPress on Windows

If you’re on Windows, you have two choices:

Option 1: XAMPP (Beginner Friendly)

  • Download XAMPP from the official site:
    🔗 https://www.apachefriends.org/index.html
  • Install it → Open the XAMPP Control Panel → Start Apache and MySQL.
  • Go to C:\xampp\htdocs\ and create a folder called mysite.
  • Download WordPress from wordpress.org, extract it into mysite.
  • Open http://localhost/phpmyadmin and create a database.
  • Finally, run http://localhost/mysite in your browser to complete installation.

Option 2: WSL (Windows Subsystem for Linux)

For students who want to get hands-on Linux experience on Windows:

  • Install Ubuntu from Microsoft Store.
  • Open WSL → follow the same Ubuntu LAMP steps above.

4. Git Setup for WordPress

Once WordPress is running, let’s make it professional with Git.

Step 1: Initialize Git

cd mysite
git init
git add .
git commit -m "Initial WordPress setup"

Step 2: Connect to GitHub (or GitLab)

git remote add origin https://github.com/username/mysite.git
git branch -M main
git push -u origin main

Step 3: Create .gitignore

Inside your project, create a .gitignore file to avoid committing unnecessary files:

wp-config.php
wp-content/uploads/
node_modules/
vendor/

This prevents sensitive configs and bulky uploads from going into Git.


5. Best Practices (What Companies Expect)

  • Always work on a separate branch (e.g., feature/login-page).
  • Never commit real credentials inside wp-config.php.
  • Use .env files for database passwords and secrets.
  • Remember: Git tracks code, not your database. Use plugins like WP Migrate DB or tools like phpMyAdmin export when sharing databases.

Conclusion

By now, you’ve:

  • Installed WordPress locally on Ubuntu or Windows
  • Set up a database and environment
  • Connected your project to Git for version control

This is exactly how a real-world developer prepares their system before building client projects. Once you’re confident in this setup, you’re ready to move on to theme development, plugin usage, and custom blocks.


👉 Next in the series, we’ll cover: Using Predefined Themes Setup.

More articles

How to Run LLMs Model Locally (Step-by-Step Guide)

Learn how to run LLMs model locally with Python. Step-by-step guide to set up dependencies, download models, and run inference on your machine without cloud costs.

Read more

Pantheon: Managed Hosting for WordPress & Drupal Sites

What is Pantheon? Explore Pantheon hosting, its features, pricing, pros & cons for WordPress and Drupal sites.

Read more

Connect with Us

Got questions or need help with your project? Fill out the form, and our team will get back to you soon. We’re here for inquiries, collaborations, or anything else you need.

Address
12, Sri Vigneshwara Nagar, Amman Kovil
Saravanampatti, coimbatore, TN, India - 641035