For those who want to learn how to install WordPress in Ubuntu, this post will help them. This post will tell users what to do in order to get WordPress working in Ubuntu.

For most beginners, they may never have to worry about this. Most host providers will make installing WordPress very easy and there won’t be the need to first prepare the operating system before installing WordPress. Everything that will be needed to get WordPress working will have been installed before new users sign up for services.

For the few who want to learn how it’s done, this post will get you started. What this post is going to show you is how to install all the requirements and prepare Ubuntu for WordPress.

While using tools like Cpanel will get you too install WordPress, doing it manually may be challenging for some. There’s no automated tool or script to help you. You must install the web server, database server and PHP modules. Then you must configure these services. It may sound terrifying, but easy to accomplish as long as you follow the steps below.

For this blog post, I am using VirtualBox with Ubuntu guest machine on my local computer. You can do the same.

To get started, follow these steps:

  • Install Apache Web Server

Apache is an important component in the mix. Without Apache or another web server, you can’t run a WordPress blog or website. So the first thing is install Apache in Ubuntu.

To do that, run the commands below.

sudo apt-get install apache2

 

  •  Install MySQL Database server

MySQL is another critical component, and without it, you won’t run WordPress. WordPress uses this server to store settings, link profiles, usernames and passwords and other data.

To install MySQL Database Server in Ubuntu, run the commands below.

sudo apt-get install mysql-server mysql-client

After running the commands above, you may be prompted to create MySQL database root password. Create one and remember it. You’ll need it later to configure MySQL databases.

 

  • Install PHP & Modules

The last component of this is PHP. WordPress depends on PHP as well. Without PHP, you can’t run WordPress.

To install PHP and other packages, run the commands below.

sudo apt-get install php5 php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

 

After installing all the packages required to run WordPress, begin configuring each one of them.

 

  • Configuring Apache Web server

To run WordPress on Apache, you must put WordPress content in the appropriate folder for it to function correctly. In Ubuntu, the default DocumentRoot for website content is at /var/www/html.

Download WordPress content and put it into /var/www/html.

Run the commands below to get WordPress latest.

wget http://wordpress.org/latest.zip

 

Then run the commands below to extract it. Then copy the content into the default root directory at /var/www/html/

unzip latest.zip

sudo cp -rf wordpress/* /var/www/html/

 

Now that WordPress content is in the right location, let’s go and configure our database. We’re doing to create a new database, user and give it permission to our WordPress database we’ll create.

First let’s create our WordPress database. To do that, sign onto MySQL Server by running the commands below.

mysql -u root -p

When prompted enter the password you create earlier. Once logged in, run the commands below to create our first database named wordpress.

CREATE DATABASE wordpress;

Next, run the commands below to create a database user.

CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'myPassword';

Next, run the commands to give wpuser (WordPress user) access to the database

GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';

 

That’s it! The database side of the setup is done. We’ll need to update WordPress configuration file with these database info.

 

  • Finalizing the setup

 

Now that w’eve installed all the required packages and servers, copied WordPress content to the default DocumentRoot and created a database and user, it’s now time to configure WordPress to access and database which will be used to store content data.

To do that, change into the DocumentRoot (/var/www/html/)  and rename the file wp-config-sample.php to wp-config.php. Run the command below to do that.

sudo cp wp-config-sample.php wp-config.php

After the file is renamed, open wp-config.php and specify the database name, user and password as shown in the image below.

 

wordpress-ubuntu-setup

 

Save the file and you’re done.

Open your web browser and type localhost to bring up WordPress site. Then enter the website info and click Install WordPress

 

wordpress-ubuntu-setup-1

 

Enjoy!