WordPress is a comprehensive content management system (CMS) powering a lot of the websites that you visit daily.
If you'd like to get started developing WordPress websites but are not ready to pay for a server on the cloud, you can run and host your WordPress site locally on your PC. Here's everything you need to know about installing WordPress on Linux.
Why Use WordPress?
According to WordPress, 40% of the websites in the world are built using WordPress. These are impressive stats, and you might be wondering, “Why is WordPress so popular?”
Here are some key reasons why many people choose WordPress to power their websites:
- User-friendly: WordPress comes with an intuitive and easy-to-use dashboard that makes it effortless to create and manage websites. This also makes it easier to learn the framework.
- Versatile: You can use WordPress to create a wide range of websites such as blogs, online stores, company landing pages, etc.
- Customization: Two core elements of WordPress sites are themes and plugins. These allow you to customize and modify the look of your website to your liking.
- Cost-effective: WordPress is open-source and free to use and makes economic sense when developing websites. Plus, it is relatively easy to find WordPress developers which makes it cheaper.
Here are the steps to install WordPress on Ubuntu:
1. Set Up a LAMP Stack
A LAMP stack is a collection of four main software packages required for WordPress to run effectively. LAMP stands for Linux, Apache, MySQL, and PHP.
- Linux is the operating system on which you'll deploy your WordPress websites.
- Apache is an open-source web server application used to serve web pages and other content on the internet. It facilitates the connection between the server and your web browser. It's one of the most widely used web servers known for its stability, flexibility, and extensibility.
- MySQL is a powerful, open-source, and cross-platform relational database management system (RDBMS) that is widely used for managing and storing structured data. It's used for keeping and persisting your website information.
- PHP is a server-side programming language used for developing websites. You can develop the core WordPress software and its themes and templates using PHP. In addition, it handles all business logic on your WordPress website.
XAMPP is a great LAMP stack that bundles all these software packages together. In case you don't have a LAMP stack on your PC, it is relatively easy to set up.
First, download XAMPP for Linux.
Download: XAMPP
When the download is complete, go to the Downloads directory, then give the newly downloaded XAMPP file execution permissions with:
cd ~/Downloads && sudo chmod 777 xampp-linux-x64-*-installer.run
Start the XAMPP installer using:
sudo ./xampp-linux-x64-*-installer.run
You'll be presented with a graphical installer, so just follow along to finish the installation.
Once installed, you can start or run XAMPP with:
sudo /opt/lampp/lampp start
After you start XAMPP, you can go to the following URL using your web browser: localhost. If you configured everything properly, you'll be greeted with a screen similar to the following:
Remember that WordPress is cross-platform, so you can also install it locally on Windows or macOS.
2. Downloading WordPress on Linux
With the LAMP stack set up, you can proceed to download the latest WordPress version.
By default, WordPress will be downloaded to your Downloads directory. Next, go into the Downloads directory using the cd command:
cd ~/Downloads
Unzip the newly downloaded WordPress archive using the unzip utility as follows:
unzip wordpress-*.zip
Download: WordPress
3. Configuring WordPress on Linux
Create a folder within the /opt/lampp/htdocs directory that corresponds to the name of the website that you want to create. The folder name is what you will use in the URL for navigating to your WordPress site locally.
Go into the opt directory and create a folder named muo. Feel free to use any name of your liking.
cd /opt/lampp/htdocs && sudo mkdir muo
Copy the contents of the WordPress folder that you unzipped previously into your website directory.
sudo cp -R ~/Downloads/wordpress-*/wordpress/* /opt/lampp/htdocs/muo
Remember to replace the WordPress version in the preceding command with the correct version.
Change the owner of the site and all its content from root to www-data using:
sudo chown www-data:www-data -R /opt/lampp/htdocs/muo/
Also, change the write permissions so that you can easily work with your WordPress site locally.
sudo chmod 777 -R /opt/lampp/htdocs/muo
Don't use the preceding write permissions on production environments because they are not restrictive enough, but they are okay for testing and local development.
4. Installing WordPress on Linux
Your WordPress website needs a database for storing and persisting website configurations and user details. Fortunately, XAMPP has already installed a MySQL database for us.
You can access the database from your browser by visiting the URL: localhost/phpmyadmin.
Click on the New button on the left-hand side pane and specify a name for your database. Then, click Create. I've named mine muo to correspond to the site name.
Visit the URL localhost/muo to start configuring your website. Replace muo with your website's folder name that you specified in the third step.
On the next page, you should provide the database name and other details. The default MySQL username is root and there is no password so just leave it blank.
Click the Submit button and follow the prompts that follow.
Finally, provide the site title, username, a strong password, and your email address. Then, click on the Install button.
On the next page, you will log in to the WordPress admin panel which allows you to customize and build your website to your liking.
Securing Your WordPress Site Is Important
WordPress is great for developing a wide range of websites. And best of all, it is easy to get started with and install on your local PC.
When you want to deploy your WordPress website in production, you must secure your website to avoid data breaches and exploitation.