Installing WordPress – introduction and download
In this series of posts I’m going to cover one of the first steps you need to take before you can start developing with wordpress, which is the process of installing WordPress.
Before I get into the detail, I’ll just add that there is also the option of creating a complete containerisedĀ WordPress development environment using Docker, which I’m going to cover in a later article. However, I’m a great believer in understanding the nuts-n-bolts of a system, and this install covers those and is a good starting point before getting into the complexities of Docker.
There are a few steps involved in the basic install process, and the actual commands you issue are dependent on the operating system you are installing wordpress on. I’m going to describe the process used to install wordpress on a Linux host, since that is the most likely scenario in the real world – wordpress runs on a server and most servers in the world run a variety of Linux.
Of course one of the simplest options is to run WordPress in a hosted environment where you don’t have shell access and the install is taken care of with a ‘one click’ install, but to be honest if you are intending to develop your own modules or add your own code that is probably not the best environment to use. I find that although that environment is great for setting a site up and getting it running quickly, if you are intending to get your hands dirty with development it’s best to understand how all the pieces fit together and have full control.
So that means using a server and obviously buying a server is a huge cost, and one which most people couldn’t justify. A great option for most people is one of the virtualised server offerings from companies like Digital Ocean – for only a few pounds a month you can have a machine easily capable of running WordPress and the option to upgrade your machine when you build a really popular site! (Or delete it if you don’t!)
Before we get started, there are a few assumptions made in this article. I’m going to assume you have the Linux server (or a personal laptop for development) we just discussed set up which has the required packages installed and that you have shell access to it. On this server you have an account which allows you to issue commands as root – i.e. you can use the ‘sudo’ command. It’s also likely that you have a reasonable understanding of the basics of Linux like changing directories, running an editor etc.
In a later article I will cover the process of setting up a digital ocean server so if you need assistance with that come back in a few weeks and look for that article.
Installing WordPress
The basic process of installing wordpress can be broken into some discrete steps:
- Downloading and uncompressing the wordpress software
- Creating a mysql database and database user for wordpress
- Configuring wordpress to use the database
- Configuring a web server to work with the installation.
- Running the wordpress install
- Setting up DNS records to point to your installation
It’s possible if you are setting up a development site on a personal laptop that you may not need all of these steps but I’ll go through them and explain how the step may not be required in some circumstances. Because the whole process can be involved but I want to explain it properly, this article will deal with the first part – downloading and un-compressing the wordpress software – later articles will deal with the other stages and be linked from the list above.
Downloading the WordPress package
The wordpress software package is available in a variety of formats from the wordpress.org site atĀ https://wordpress.org/download/. For this article I’m going to use the .tar.gz version, which is normally a bit smaller than the zipped version.
To carry out the steps which follow, you are going to need to be logged into your server and at the command prompt.
The first decision to make is to decide which directory on the machine you want to install the wordpress software in. It is possible to use the webserver document root but I always avoid that option because it can lead to a messy setup when you start having multiple sites or other software.
So my preferred option is to create a directory in /usr/local for all my websites and I would do that with this command.
sudo mkdir -p /usr/local/sites/my-site-name.co.uk sudo chown simon:simon /usr/local/sites/my-site-name.co.uk/ -R
Things to note are that because the /usr/local directory is not owned by your user you need to use theĀ sudo
command so that you have permission. The -p option is just so that the mkdir command will create any parent directories if they don’t exist.
The final part of the directory is the URL you are intending to access the site on. There is no requirement to name the directory the same as the URL you are eventually going to use – it is simply useful to do this so you know which site is located in each directory. Although this may not be necessary when you install your first site, if you progress to running several sites this will be a useful convention to follow.
The second command is used to change the ownership of the directory to your user on the server. This is something which is just a convenience while we are configuring the site – we will change it later but it means we don’t need to keep using sudo for the next few commands. If you are following this you would need to substitute your username in place of the ‘simon:simon’ in the command.
With the directory created we move into it
cd /usr/local/sites/my-site-name.co.uk
now we need to download the wordpress tar.gz file from the main wordpress site. The latest version is kept under the filename latest.tar.gz so we use
wget https://wordpress.org/latest.tar.gz
Assuming this works properly you will see a progress bar as the file is downloaded and once it is finished you will have a new file called latest.tar.gz in the directory.
To inflate the file we use the tar command
tar xzvf latest.tar.gz
This will print a list of files as the wordpress software is expanded on the disk and a couple of seconds later the process will be complete. At this point you can delete the latest.tar.gz file if you want.
So that is the first part of the install done – in the next part I’ll cover the creation of a database and a database user for the wordpress install we’ve just created.