Simple Steps To Installing And Configuring A Website Using WordPress And Ubuntu

In this tutorial we cover how to install and configure WordPress on a Ubuntu server. I will assume you already have Apache, MySQL, PHP (LAMP), and phpMyAdmin running on your Ubuntu machine. This tutorial will help you get your own WordPress website running on your home network. If you are setting this up on a hosted service you will need to make sure you have your DNS already setup and use the domain instead of the IP address when configuring WordPress. 

If you need help on setting up an ubuntu server or installing the LAMP stack on your ubuntu machine (desktop or server), check out some of the following articles.

 

How to install ubuntu 10.04 LTS as a web server:

http://mixeduperic.com/ubuntu/how-to-install-ubuntu-server-1004-web-serv...

How to install Ubuntu 11.04 as a web server:

http://mixeduperic.com/ubuntu/how-to-install-and-configure-ubuntu-1104-a...

How to install the LAMP stack on Ubuntu:

http://mixeduperic.com/ubuntu/how-to-install-lamp-on-ubuntu-linux-apache...

How to install phpMyAdmin:

http://mixeduperic.com/ubuntu/how-to-install-phpmyadmin-on-ubuntu-1004-l...

 

 

 

 

 

What is WordPress:


WordPress is a free and open source blogging tool and content management system (CMS) based on PHP and MySQL. WordPress is currently the most popular CMS in use on the Internet. WordPress has a large number of themes and plug-ins available both free and paid. The community is very large so a lot of people are around to help solve any problems that may come up.

 

Below you will see what the default front-end looks like after a fresh install. The look and feel can always be modified with a different theme

 

 

Default wordpress site

 

 

Here is a look at the defualt admin dashboard:

 

 

Example of WordPress Admin Dashboard

 

 

Example Post

 

 

 

Installing WordPress:


Once you have your ubuntu system setup with Apache, MySQL and PHP, logged into your system we can download WordPress to the /tmp directory.

Change to the /tmp directory by using the cd command.

Note: Files in /tmp will be deleted when the system is rebooted. This should not matter as long as you don't reboot your machine before coping your downloaded files to the needed location. 

cd /tmp

 

 

 

On your ubuntu system change directories to /tmp

 

 

Download the Wordpress zip package using wget.

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

Note: Wordpress always has the newest release called latest.zip so the command above should  always pull the most current version. 

 

 

Download the latest.zip of WordPress using wget

 

 

By default ubuntu does not have unzip installed by default, we will need to install this so we can unzip the WordPress zip file (latest.zip).

sudo apt-get install unzip

 

 

Install unzip

 

 

Enter your password

 

 

Enter your password to install unzip

 

 

Unzip the wordpress (latest.zip) file.

unzip latest.zip

 

 

unzip latest.zip wordpress

 

 

You should now have a folder called wordpress. Let's change into that directory.

cd wordpress/

 

 

change directory into the new unziped wordpress folder

 

 

 

This tutorial is assuming this is a fresh web server and no other websites are running on it. We will copy the files to Apache's root directory /var/www/. If you do have other websites running you can create a directory inside /var/www/ and put your wordpress files inside that directory. Make sure you adjust the steps below to fit your needs if you already have sites on your server.

 If you are not sure if other sites are running on your machine you can use the ls commnd to list the files in the /var/www/ directory. The only file you should see is index.html, which is a default file used to test Apache. 

 

 

Display the contents of /var/www/ - Apache root dir to make sure no other sites are installed

 

 

 

 

You should just see a single file - index.html

 

 

Before we copy the contents from the unzip wordpress directory we will want to remove the test index.html file. (Note: Only run the next command if you don't have any other websites running on your server.)

sudo rm /var/www/index.html

 

 

Remove default index test file from Apache root directory

 

 

Now let's copy our files to the Apache root directory /var/www/. (Issue the following command inside the wordpress dir)

sudo cp –r * /var/www/

 

 

copy contents from wordpress unzip directory to Apache root directory /var/www/ on your ubuntu system

 

 

Since we used the sudo commnad the owner of the files will be root. We will need change the owner to the wp-content directory to www-data (Apache User and group). This will allow us to have permission to upload files, download themes and plug-ins from the admin interface. 

sudo chown -R www-data:www-data /var/www/wp-content/

 

 

Change owner of /var/www/wp-content/ directory to www-data

 

 

 

 

 

Creating A MySQL database and user:


WordPress use a database to hold all the websites data and user information. We will set this database up using phpmyadmin.

To access phpMyAdmin you will need to know the IP address or domain name of your server. In my case it is 192.168.11.198

If you want to use a domain name on your home network you can add a static entry on the machine that will be accessing the site. Another option is to setup an  internal DNS server so you don't have to manually set it on every device on your network. Check out http://mixeduperic.com/ubuntu/seven-easy-steps-to-setting-up-an-interal-... on how to setup internal domain server on your home network. 

One other note. It is a good idea and best practice to have your server setup up with a static IP address. For steps on how to do this check out: http://mixeduperic.com/ubuntu/how-to-set-a-static-ip-address-on-a-ubuntu...

 

Open your browser and enter the the IP address or domain name of your server followed by /phpmyadmin

Example: http://ServerIpAddress/phpmyadmin or in my case it would be http://192.168.11.198/phpmyadmin

 

 

Login Page of phpMyAdmin

 

 

login to phpmyadmin

Click on the Privileges tab

 

 

Landing page of phpMyAdmin

 

 

Click on the Add a new User link (Located in the middle of the page)

 

 

Click on Add a new User link (Located in the middle of the page)

 

 

Create a user name for your database

For Host enter localhost

I use the generate password option since you only need to use this password once during the setup of your site.

Note:If you use the generate password option make sure you copy or write down the password that was generated sinc we will need that in a few steps. 

 

Setup Database name and password in phpMyAdmin

 

 

Scroll down to the section that says Database for user and select the Create database with the same name and grant all privileges.

 

 

Scroll down to database for user and select Create database with same name and grant all privileges radio button

 

 

Click the Go button at the bottom of the page

 

 

Click Go (Located at the bottom of the page)

 

We now have the database created. 

Tip: phpMyAdmin is a great tool but can also be a target for hackers and bots for brute force attacks. You can add an extra layer of security to phpMyAdmin by only allowing access from a specific IP address. Check out the following tutorial on how to do this: http://mixeduperic.com/ubuntu/how-to-restrict-phpmyadmin-ip-address.html

 

 

 

Configuring Wordpress:


We are almost ready to start creating content to our new site. We just need to make a few configurations. 

Open your brower and type the IP address or domain name followed by /wp-admin/install.php. 

Example: http://ServerIpAddress/wp-admin/install.php or in my case http://192.168.11.198/wp-admin/install.php

Click Create a Configuration File 

 

Click Create A Configuration File

 

 

Click Let's Go!

 

 

Click Let's Go

 

 

Enter your database name (If you followed the steps above it should be the same as the user you created)

Enter your database user name.

Enter the password you generated or created above in phpMyAdmin.

 

 

Enter You database login information

 

 

You will now see a message saying that it could not create the wp-config.php file. We will want to copy the code and then we will create the wp-config.php file to put this code in.

 

 

can't write the wp-config.php

 

 

Let's jump back to the terminal of the ubuntu server and create that file using the nano text editor. 

 

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

 

 

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

 

 

Blank wp-config.php file

 

 

Paste the code provided to you from the web installer into this file.

 

 

wp-config.php data pasted in

 

Hit CTRL + X to exit nano

Enter "Y" to save the file

 

 

Hit CTRL + x and then Y to save the file in nano

 

 

Hit Enter to finish saving the file as /var/www/wp-config.php.

 

 

Hit Enter to save the file as /var/www/wp-config.php

 

 

Jump back to your brower and click Run the install

 

 

Click Run the install

 

 

We are now to the easy part. We just need to create a name for the site, an admin user and password and define if we want the site to be index from google. If this site is host on your home network and is not exposed to the internet with a port forward, google and other search engines will not see your site so they can't index it. 

 

Set your basic site config with username and title

 

Below is an example of my configuration.

 

Example Config

 

 

Click Install wordpress.

You should see something saying success! 

 

 

Wordpress install success!

 

 

You can now login with the username and password you just created.

 

 

Example admin login page

 

To administrat your WordPress website you can access the admin login with /wp-admin.

Example: http://ServerIpAddress/wp-admin or in my example http://192.168.11.198/wp-admin

 

You should now have a basic website ready to create content. To setup clean URLs using permalink settins in WordPress check out http://mixeduperic.com/ubuntu/5-simple-steps-to-configure-wordpress-to-use-permalinks-on-an-ubuntu-server.html

 

If you enjoyed this post, please share it on your favorite social network by clicking on the “Share / Save” bar below.

 

 

Other useful articles:


How to change the default SSH port on Ubuntu:

http://mixeduperic.com/ubuntu/how-to-install-lamp-on-ubuntu-linux-apache...

How to start and stop Apache web server and MySQL on Ubuntu:

http://mixeduperic.com/ubuntu/how-to-start-stop-and-restart-apache-and-m...

Monitor Apache web logs in real time with apachetop

http://mixeduperic.com/ubuntu/monitor-apache-web-traffic-in-real-time-wi...