Your cart is currently empty!
How to Install WordPress on Ubuntu
Thinking of starting a WordPress site on your own server? Ubuntu makes it possible—and it’s easier than you might think. Here’s how you do it from scratch, no fluff, no jargon, just the steps.
What You’ll Need
- An Ubuntu server (18.04, 20.04, or 22.04 work great)
- A user account with sudo privileges
- Internet connection
Ready? Let’s get started.
1. Update Your Server
Start with the basics: make sure your server is up to date.
sudo apt update
sudo apt upgrade -y
2. Install LAMP Stack
WordPress needs a web server, database, and PHP. That’s what LAMP is: Linux, Apache, MySQL, PHP.
Install Apache
sudo apt install apache2 -y
Enable Apache to start on boot:
sudo systemctl enable apache2
Install MySQL
sudo apt install mysql-server -y
Secure your database:
sudo mysql_secure_installation
Follow the prompts. Set a strong root password.
Install PHP
sudo apt install php libapache2-mod-php php-mysql -y
3. Create a MySQL Database for WordPress
Log into MySQL:
sudo mysql -u root -p
Once inside, run:
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'your_password_here';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Replace 'your_password_here'
with a strong password.
4. Download WordPress
Switch to the web root:
cd /var/www/html
Remove the default index file (if needed):
sudo rm index.html
Download and extract WordPress:
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzf latest.tar.gz
sudo mv wordpress/* .
sudo rm -rf wordpress latest.tar.gz
5. Set Permissions
Set the correct file permissions:
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html
6. Configure WordPress
Copy the sample config file:
sudo cp wp-config-sample.php wp-config.php
Edit it:
sudo nano wp-config.php
Find these lines and update them with your database details:
define('DB_NAME', 'wordpress');
define('DB_USER', 'wpuser');
define('DB_PASSWORD', 'your_password_here');
define('DB_HOST', 'localhost');
Save and exit (CTRL+X
, then Y
and Enter
).
7. Complete Installation in Your Browser
Now go to http://your_server_ip/
in your browser. You’ll see the WordPress setup screen.
Follow the prompts—choose your site title, admin username, and password. That’s it.
Final Tips
- Security: Set up a firewall (UFW), use strong passwords, and keep your server updated.
- SSL: For a public site, use Let’s Encrypt to enable HTTPS.
- Backups: Schedule regular backups of both files and your database.
Ready to launch? You just set up WordPress on Ubuntu. Now you’re in full control of your site.
Tech enthusiast and content creator passionate about making technology simple for everyone. I share practical tips, guides, and reviews on the latest in computers, software, and gadgets. Let’s explore the digital world together!