When you hear someone talking about WordPress installation on Linux, you think: Why would I do that when there’s an easier way?
However, after years of experimenting with various hosting configurations, we can personally vouch that Linux is, without a doubt, one of the better decisions you’ll ever make for your WordPress site. Yes, it may look scary at first, but stick with us in this guide. We guarantee you’ll be asking yourself why you didn’t install WordPress on Linux.
Why Choose Linux for WordPress?
Here’s something most people don’t realize: Linux is basically the backbone of the internet. While everyone’s talking about fancy managed hosting or Windows servers, Linux quietly powers most of the web’s biggest sites. We’ve been using Ubuntu for our WordPress projects for years now, and honestly? It just works.
- W3Techs reports that 57.0% of all websites use Linux. w3techs.com
The thing that makes Linux unique is its stability. Your website won’t suddenly crash at 3 AM due to some strange Windows update. Also, the community support is phenomenal. Every time we’ve had a problem, there’s always someone who’s had the same issue and posted their fix.
The real magic happens when you combine Linux, Apache, MySQL, and PHP – the LAMP stack. These million-plus sites have tested it in battles over the decades. It’s like having a high-performance engine in the trunk of your car.
What You Will Need to Have Before You Install WordPress on Linux
Before we install WordPress on Linux, ensure you have everything that is required.
Linux Server
After reviewing the list of Linux version history, we recommend using Ubuntu 22.04 LTS. It’s the “Honda Civic” of Linux distributions – it’s solid and does the trick. It’s reliable, well-supported, and ideal for beginners.
Sudo Access
You’ll require administrative access. If you’re doing this yourself on your own server, you likely already have it. If not, speak to your system administrator.
Network Setup
Ensure you can SSH into your server and that it can host web pages. A static IP address will give you less trouble later on, and you should set up your firewall to enable web traffic.
Suppose you’ve got all that, fine. Let’s start installing WordPress on Linux.
11 Easy Steps to Install WordPress on Linux
| Step | What You Need to Do to Install WordPress on Linux |
Why It Matters |
|
1 |
Update your server | Keeps things secure and avoids package conflicts |
|
2 |
Install Apache | It’s the web server that shows your site to the world |
|
3 |
Install MySQL | Stores your posts, users, and settings |
|
4 |
Install PHP + extensions | Runs WordPress behind the scenes |
|
5 |
Download WordPress | Gets the latest version directly from WordPress.org |
|
6 |
Move WordPress to the web folder | Makes it accessible in your browser |
|
7 |
Set up Apache site config | Tells Apache how to handle your WordPress site |
|
8 |
Create a database for WordPress | Gives WordPress a place to store its data |
|
9 |
Connect WordPress to the database | Let WordPress know how to access your data |
|
10 |
Run the setup in your browser | Finish installing and creating your admin account |
|
11 |
Log in to the WordPress dashboard | You’re done! Time to start building your site |
Step 1: Update Your Linux System
First things first – let’s ensure your system is up to date. This is like checking your car’s oil before a long road trip. It prevents weird issues down the road:
bash sudo apt update && sudo apt upgrade -y
Grab a coffee while this runs. It might take a few minutes, but once you update your setup, it will be successful for sure.
Step 2: Apache Web Server
Apache is like the front door of your website – it’s what visitors interact with first. It’s been the most popular web server for decades, and for good reason. Let’s install it:
bash sudo apt install apache2 -y
Want to check if this Apache install server code worked? Open your browser and type in your server’s IP address. To see an Apache’s default “It works!” page is a success indicator in this case.
Step 3: Install MySQL for the WordPress Database
WordPress requires a storage location to store all your content, user accounts, and settings. That’s where MySQL comes in – think of it as your website’s filing cabinet. Let’s install it:
bash sudo apt install mysql-server -y
Now, let’s secure it (this is important – don’t skip this step):
bash sudo mysql_secure_installation
This wizard will walk you through setting up a root password and removing some default settings that could be security risks. Take your time with this – good security habits start here.
Step 4: Install PHP and Required Extensions
PHP is what makes WordPress actually work. Without PHP, your site would have static HTML files only and wouldn’t function. PHP is crucial for WordPress:
bash sudo apt install php libapache2-mod-php php-mysql php-curl php-xml php-mbstring php-zip -y
Let’s confirm everything is installed perfectly:
bash php -v
If you see a version number, you’re golden! PHP is ready to power your WordPress site.
Step 5: Download WordPress for Linux
Time for the main event – getting WordPress itself. We’ll download it directly from the official source:
bash cd /tmp wget https://wordpress.org/latest.tar.gz tar -xvzf latest.tar.gz
A folder called ‘wordpress’ will now be created in your /tmp directory. If you ever need to remove a directory and are unsure, refer to our guide on how to remove a directory on Linux.
Step 6: Move WordPress to Apache’s Web Directory
Now, we need to move WordPress to a location where Apache can access it. It’s kind of like shifting into a new house; you have to place things in the right spot:
bash sudo mv /tmp/wordpress /var/www/html/wordpress
Now, open your browser and type: http://server-of-your-ip/wordpress. It will display the setup screen, and everything should be working as expected.
Step 7: Set Up Apache for WordPress
Let’s make a configuration file for your WordPress site:
bash sudo nano /etc/apache2/sites-available/wordpress.conf
Paste:
apache <VirtualHost *:80> DocumentRoot /var/www/html/wordpress <Directory /var/www/html/wordpress> AllowOverride All Require all granted </Directory> </VirtualHost>
Enable your new site and disable the default one:
bash sudo a2ensite wordpress.conf sudo a2dissite 000-default.conf sudo systemctl reload apache2
Step 8: Create a MySQL Database for WordPress
Let’s give WordPress its database:
bash sudo mysql -u root -p
Then, enter the following commands in MySQL:
sql CREATE DATABASE wordpress; CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'your_strong_password'; GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress_user'@'localhost'; FLUSH PRIVILEGES; EXIT;
Use a robust password and store it securely.
Step 9: Link WordPress to the Database
Now, we need to connect our CMS to the database to complete the WordPress installation on Linux:
bash cd /var/www/html/wordpress sudo cp wp-config-sample.php wp-config.php sudo nano wp-config.php
Find these lines and update them:
php define( 'DB_NAME', 'wordpress' ); define( 'DB_USER', 'wordpress_user' ); define( 'DB_PASSWORD', 'your_strong_password' ); define( 'DB_HOST', 'localhost' );
Step 10: Complete WordPress Installation on Linux
Now it’s time to complete the installation:
Go to: arduino http://your-server-ip/wordpress
You will be able to see the WordPress installation wizard. Fill in your site title, admin user, and password. After completing the process, WordPress will be fully installed and ready to use.
Step 11: Log in to Your New WordPress Site
Once the WordPress installation on Linux is complete, you will be diverted to the login page. Log in using your admin information to see your WordPress dashboard.
Conclusion: How to Install WordPress on Linux
And voila! You’re finished. You’ve got WordPress installed and running on Linux, have a firm foundation with the LAMP stack, and have created something to be proud of. That once-daunting technical barrier is now a working website that you get to own.
The great part of this design is that someone else’s limitations do not limit it. Want to push something to its limit? Certainly! Want to install a custom PHP module? Sure! That level of control and flexibility is why Linux is ideal for serious WordPress enthusiasts.
The process may have seemed intimidating at first, but now you have the experience and the ability to do it all over again. And let us tell you, it keeps getting easier and easier. Welcome to the fantastic world of self-hosted WordPress on Linux – you’ll enjoy the freedom!
