The Ultimate Guide to Installing WordPress on Ubuntu: A Simple, Step-by-Step Tutorial
in WordPress Plugins on December 16, 2025
Easy Guide: Installing WordPress on Ubuntu
This tutorial provides a straightforward method to install WordPress on an Ubuntu server. Follow these steps to get your WordPress site up and running.
First, let’s understand the concept of LAMP, which stands for Linux, Apache HTTP Server, MySQL database, and PHP language. We’ll be using the Apache server in this guide.
Step-by-Step Installation
1. Update and Install Apache and MySQL
Update your Ubuntu repository and install Apache and MySQL:
sudo apt update
sudo apt install apache2
sudo apt install mysql-server
2. Configure MySQL Server
After installation, configure the MySQL server. You’ll need to set a password for the root user.
Enter MySQL with sudo privileges:
sudo mysql
Create a root user (replace ‘Password’ with your desired password):
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Password';
Apply the changes:
FLUSH PRIVILEGES;
Exit MySQL:
exit;
Log in again as root to verify:
mysql -u root -p
3. Create a WordPress Database and User
Create a database for WordPress and grant a user permissions.
Create a database named ‘wordpress’:
CREATE DATABASE wordpress;
Create a user (replace ‘Password’ with your desired password):
create user 'user'@"localhost" IDENTIFIED BY 'Password';
Grant permissions to the user:
# Grant permissions
grant all on wordpress.* to "user"@"localhost" with grant option;
# Apply changes
flush privileges;
# Exit MySQL
exit;
4. Install PHP and Required Extensions
Install PHP and necessary PHP extensions:
sudo apt install php libapache2-mod-php php-mysql
sudo apt install php-curl php-gd php-xml php-mbstring php-xmlrpc php-zip php-soap php-intl
5. Install WordPress
Download and extract the latest WordPress package:
curl -O https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
6. Move WordPress Files
Move the WordPress files to the Apache’s default directory (/var/www/html/).
sudo mv wordpress/* /var/www/html/
7. Set Directory Permissions
Modify the permissions of the /var/www/html/ directory:
sudo chmod -R 777 /var/www/html/
8. Configure Apache
Point Apache to index.html:
sudo mv /var/www/html/index.html /var/www/html/index~.html
9. Restart Apache
Restart the Apache service:
sudo service apache2 restart
10. Complete the Installation via Web Browser
Access your server’s domain or IP address in a web browser. You will be prompted to enter the database name (wordpress), username (user), and password (your chosen password). The other fields can be left as default. Proceed with the WordPress installation.
(Optional) Remove Unwanted WordPress Widgets
You can remove or comment out the following code snippets from the file to remove specific widgets.wp-includes/widgets/class-wp-widget-meta.php
Remove “Entries feed” and “Comments feed”:
<li><a href="<?php echo esc_url( get_bloginfo( 'rss2_url' ) ); ?>"><?php _e( 'Entries feed' ); ?></a></li>
<li><a href="<?php echo esc_url( get_bloginfo( 'comments_rss2_url' ) ); ?>"><?php _e( 'Comments feed' ); ?></a></li>
Remove “WordPress.org”:
echo apply_filters(
'widget_meta_poweredby',
sprintf(
'<li><a href="%1$s">%2$s</a></li>',
esc_url( __( 'https://wordpress.org/' ) ),
__( 'WordPress.org' )
),
$instance
);
wp_meta();
Key Takeaways
- Ensure you have a LAMP stack (Linux, Apache, MySQL, PHP) installed.
- Secure your MySQL installation by setting a strong password for the root user.
- Create a dedicated database and user for your WordPress installation.
- Set the correct file permissions for WordPress to function properly.
- Restart the Apache server after making configuration changes.
FAQ
- Q: I’m getting a database connection error. What should I do?
A: Double-check your database credentials (database name, username, password, host) in the wp-config.php file. Also, ensure that the MySQL server is running. - Q: My website is showing a “Forbidden” error.
A: This is often a permissions issue. Make sure the Apache user has read access to the WordPress files. - Q: How do I update WordPress?
A: You can update WordPress through the WordPress dashboard (Appearance -> Updates). It’s always a good idea to back up your database and files before updating. - Q: Where is the wp-config.php file?
A: The wp-config.php file is located in the root directory of your WordPress installation (e.g., /var/www/html/).