There are many tutorials on installing and configuring WordPress. Most WordPress installations are done with help of web hosting tools like cPanel and others.

Those tools hide the complexity of installing and configuring WordPress. They allow anyone without knowledge of installing WordPress to easily purchase domain names, run the script and in no time WordPress is up and functioning.

For those those who know how to install Linux, including Ubuntu.. this brief tutorial is going to show you how to easily install and configure WordPress on a Ubuntu host.

This setup will require users to have Ubuntu installed and have root access to install and modify programs.

To get started, the first thing is to install a web server… WordPress requires a webserver to function. There are many webserver one can choose from to run WordPress. The most popular one is Apache2.

This tutorial is going to use Apache2 instead of Nginx or another webserver.

To install Apache2, run the commands below.

sudo apt-get install apache2

After installing Apache2, run the commands below to start Apache2 webserver.

sudo systemctl start apache2

The next thing is to install a database server. WordPress also needs a database to function. It uses databases to store its content. There are also many opensource databases to install. The most popular opensource database is MySQL.

This tutorial will be installing MySQL. To install it run the commands below.

sudo apt-get install mysql-server mysql-client

Next, run the commands below to start the database server up.

sudo systemctl start mysql

After running the above commands and installing MySQL, run the commands below to configure it.

sudo mysql_secure_installation

When prompted, follow the guide below.

Next, choose Yes for the rest of the prompts until you’re done.

  • Enter current password for root (enter for none): Type root password
  • Change the root password? N
  • Remove anonymous users? Y
  • Disallow root login remotely? Y
  • Remove test database and access to it? Y
  • Reload privilege tables now? Y

After that, continue with the database setup to configure a database for WordPress.

Run the commands below to sign onto the database. When prompted for a password, type the root password you created in the earlier tutorial on LAMP.

mysql -u root -p

Next, run the commands below to create a new database called wpdb.

CREATE DATABASE wpdb;

Next, run the commands below to create a new database user calledwpuser with a new password.

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

Then run the commands below to give the user full access to the newly created database you created earlier.

GRANT ALL ON wpdb.* to [email protected];

Finally, run the commands below to refresh the database permissions table and exit.

FLUSH PRIVILEGES;

exit

The next software to install is PHP and other PHP modules. WordPress using PHP to function.. To install PHP run the commands below.

sudo apt-get install php5 libapache2-mod-php5 php5-mysql php5-curl php5-gd php5-intl 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 that installing Apache2, MySQL and PHP, the final step is to go and grab the latest copy of WordPress. To do that, follow the steps below.

To install WordPress, use the commands below to download the latest version.

cd /tmp/ && wget http://wordpress.org/latest.tar.gz

Then run the commands below to extract the downloaded file.

tar -xvzf latest.tar.gz

Since the default Apache2 root directory on Ubuntu server is at/var/www/html, we need to copy WordPress content to that location, the root directory. Everything in that directory is what the webserver will retrieve.

To copy WordPress content to Apache2 root directory, run the commands below.

sudo mv wordpress/* /var/www/html/

One thing to verify is to make sure a test page called index.html isn’t in the root directory. If you see it there, delete it. This can become a bit of a confusion to new users.

sudo rm /var/www/html/index.html

Next, make a copy of wp-config-sample.php and create a new wp-config.php file in the root directory. The new file will contain WordPress database connection parameters.

sudo cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php

After that, open and edit the new file using the commands below.

sudo vi /var/www/html/wp-config.php

Then make the changes in the file by entering the WordPress database, username and password you created earlier. Then save the file and exit.

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wpdb‘);

/** MySQL database username */
define(‘DB_USER’, ‘wpuser‘);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘password‘);

Finally, change the permission of WordPress folder so that it functions correctly. To do that, run the commands below.

sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/

Restart Apache2 webserver by running the commands below.

sudo systemctl reload apache2

You’re now ready to access WordPress page. Open your browser and browse to the server name or IP address. You should see WordPress default setup page like the one below.

wordpress ssl installation

Finally, go and browse to the server using its IP or hostname and WordPress default configuration page should appear.. Continue with configuring WordPress and you should be done.

Enjoy!