In this tutorial, we will explain How to install WordPress in Ubuntu. WordPress is a free and open-source content management system based on PHP & MySQL. Features include a plugin architecture and a template system. It is most associated with blogging but supports other types of web content including more traditional mailing lists and forums, media galleries, and online stores.


You will need:

  • A VPS running Ubuntu
  • LAMP Stack installed on it

If you don’t know how to install LAMP Stack check out our tutorial for it.

Step 1 – Create a Database

You will need a database for WordPress to store information. First, sign into MySQL:

mysql -u root -p

Enter the password that you set during MySQL installation.

Next, create a database by running this command:

CREATE DATABASE new_wordpress;

After, we need to create a new user account:

CREATE USER [email protected] IDENTIFIED BY 'passw0rd';

And we will grant all privileges on the new_wordpress database:

GRANT ALL PRIVILEGES ON new_wordpress.* TO [email protected] IDENTIFIED BY 'passw0rd';

Flush privileges to get changes:


Use this command to exit


Step 2 – Download WordPress

Now its time to download WordPress. First download latest version from WordPress website.

cd /tmp
curl -O

After downloading, extract latest.tar.gz files.

tar xzvf latest.tar.gz

Now move extracted files to web directory:

mv ~/wordpress/* /var/www/html

Create an upload folder to store uploaded files:

mkdir /var/www/html/wp-content/uploads

And get permissions to WordPress files:

sudo chown -R www-data:www-data /var/www/html
sudo find . -type d -exec chmod 755 {} \;
sudo find . -type f -exec chmod 644 {} \;
sudo chmod 640 /var/www/html/wp-config.php

Step 3 – Setup Configuration File

Now we need to set up the configuration file. First, open the browser and go to http://localhost/wp-admin/setup-config.php

Next, choose the WordPress language and click on the Continue button.

After, click Let’s go! if you know the following items:

  1. Database name
  2. Database username
  3. Database password
  4. Database host
  5. Table prefix (if you want to run more than one WordPress in a single database)

Enter your database connection details that you have created in Step 1 and click Submit.

After that you will give an error “Sorry, but I can’t write the wp-config.php file.”

So, copy and paste the following text into wp-config.php:

nano /var/www/html/wp-config.php

Enter Ctrl+X, after type Y and hit Enter to save it.

After you’ve done that, click “Run the installation.

Step 4 – Installation

You have successfully setup configuration file, now its time to Run the installation.

Now just fill in the information below based on your preferences.Don’t worry, you can always change these settings later.

Click on Install WordPress button and you will get this.

Click on Login and enter Username & Password.

After a successful login, the browser will show the WordPress Dashboard.

You have successfully installed WordPress in Ubuntu.