Installing WordPress on a local Linux system with a LAMP stack provides a convenient environment for testing, development, and learning without publishing the website to the internet. This guide explains how to install Apache, MariaDB, PHP, the required PHP extensions, and WordPress, then complete the setup through your web browser.
Follow the steps below to configure a local WordPress installation on a Linux system such as Debian using Apache, MariaDB, and PHP.
1. Install the LAMP Stack and Required Extensions
Open your terminal and install Apache, MariaDB, PHP, and the necessary PHP extensions for WordPress:
sudo apt update
sudo apt install apache2 mariadb-server php libapache2-mod-php php-mysql php-curl php-gd php-mbstring php-xml php-soap php-intl php-zip
The installed packages provide the components WordPress needs to run:
- apache2: The traditional HTTP web server that processes and serves your web pages and handles
.htaccessfiles. - mariadb-server: The SQL database management system that stores your website content, tables, and settings.
- php: The core PHP programming engine that executes dynamic script code on your server.
- libapache2-mod-php: The Apache module that integrates PHP directly into the Apache process, allowing it to parse
.phpfiles natively. - php-mysql: The database driver enabling PHP scripts to talk to and query your MariaDB database.
- php-curl: The networking extension enabling PHP to execute HTTP requests and fetch remote web assets or API data.
- php-gd: The image manipulation library allowing PHP to create, resize, crop, and optimize image uploads.
- php-mbstring: The multibyte string module that processes non-English character sets, international scripts, and emojis correctly.
- php-xml: The parsing engine used by PHP to process XML structures, RSS feeds, and block editor components.
- php-soap (Optional): The client module enabling PHP to exchange structured data with web services using the SOAP protocol.
- php-intl: The internationalization library providing localized dates, times, currencies, and language formatting.
- php-zip: The archive management module allowing PHP to compress and extract
.zipfiles for plugins and updates.
After installation completes, restart Apache to ensure PHP extensions load:
sudo systemctl restart apache2
2. Create a MySQL/MariaDB Database and User
WordPress requires a database to store site data. Log in to MySQL/MariaDB as the root user:
sudo mysql -u root
Execute the following commands to set up the database and user. Replace wordpress, wp_user, and password as needed:
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
3. Download and Extract WordPress
Navigate to your web root directory and fetch the latest WordPress package from official sources:
cd /var/www/html
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz
Optional: Change the WordPress Folder Name
To change the WordPress folder name, replace mysitename with your desired name, and adjust the command path as needed:
sudo mv wordpress mysitename
Optional: Remove the Downloaded Archive
To remove the downloaded archive and free up disk space:
sudo rm latest.tar.gz
Set WordPress File Ownership and Permissions
Set the proper ownership so the Apache web server user (www-data) can write and manage WordPress files:
sudo chown -R www-data:www-data /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress
4. Configure wp-config.php
Copy the sample configuration file to create your active configuration:
cd /var/www/html/wordpress
sudo cp wp-config-sample.php wp-config.php
Open the file in a text editor:
sudo nano wp-config.php
Find the database settings and update them with the database name, user, and password you created in Step 2:
define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wp_user' );
define( 'DB_PASSWORD', 'password' );
define( 'DB_HOST', 'localhost' );
Save and exit by pressing Ctrl + O, then Enter, followed by Ctrl + X.
5. Complete the GUI Setup in the Browser
Open your web browser and navigate to:
http://localhost/wordpress
Select your preferred language and click Continue.
Enter your Site Title, administrative Username, Password, and Email.
Click Install WordPress.
6. Verify the WordPress Installation
After completing the browser-based setup, you can check the WordPress directory from the terminal:
cd /var/www/html/wordpress
ls -a
Once completed, log in at http://localhost/wordpress/wp-admin to start using your local LAMP WordPress installation.
With the LAMP stack, database, WordPress files, and configuration in place, WordPress is now installed locally and ready for development and testing. The local installation can be accessed through the WordPress dashboard using the administrator account created during the browser setup.
This setup provides a practical way to work with WordPress on Linux without requiring a live web server, while keeping the installation available locally through your Apache web server.
.webp)