Share this page:
Wordpress is a great tool for building web sites. It's been around for a long time and has a lot of useful features. Wordpress is very popular, so there are a huge number of plugins and themes available for it. Many of them are free, but some of the more sophisticated add-ons are commercial. The range of plugins covers everything from performance optimization to social networking and e-commerce.
To install Wordpress, set up your server as a LAMP server and install Apache, MySQL and PHP.
Log into the MySQL server with the following command:
Enter these commands to set up the Wordpress database:
The first command creates the database, and the second one creates a user account that can be used by Wordpress. The new account is granted access privileges on the new database. The privileges table needs to be flushed, and then you can exit from the MySQL client shell.
Download and unpack the latest version of Wordpress into your home directory:
Change to the newly created wordpress directory:
Create a configuration file by copying the sample configuration, and edit the new config file in nano:
Near the top of this file you'll see definitions of the database name, database user name, and the database password. Change these values to match the database name, user name and password that you stored in the database earlier.
Type control-o and press return to save changes. Type control-x to exit nano.
Copy the Wordpress files to the Apache web root directory:
Next, remove the default Apache page:
Now visit your server's IP address in a web browser. You should see this set up page:
Once you've filled in these details, login to Wordpress:
Now you should be able to see the Wordpress dashboard:
Take some time to look around the dashboard. You can change your site's theme in the Appearance menu, and adjust options in the settings menu.
Consider adding plugins to your Wordpress installation to improve performance. Wordpress is a large piece of software, so it's worth adding a caching plugin to speed up page load times. WP Super Cache is a popular choice. The Google XML Sitemap plugin generates an XML sitemap which you can register with Google. Visit the Wordpress site to see some of the most popular plugins.
When you add posts to your site, you may want to add images. You will need to upload image files to your site, so you need to set up a directory where Wordpress can store uploads. Create the uploads directory with this command:
Apache needs to be able to write to this directory in order to save files in it. This command changes the ownership of the uploads directory:
This command sets the directory's permissions so that Apache can read and write the directory:
For security reasons it's bad practice for Apache to have permission to write to files and directories in the web root directory. If Apache is hijacked by hackers, and it has write access to the web root directory, then hackers will be able to modify content on the site. Instead, files should be owned by root, and be readable by other users, but not writable.
This can be a problem when you're setting up a Wordpress site, and you need to install plugins and themes since Apache needs to be able to store files in the web root directory. A simple solution is to change the owner of Wordpress's files to www-data during development, and then change the owner back to root when the site is live.
While you're stilll working on setting up your site, use this command to make Apache the owner of the web root directory:
Once the site is set up, change the owner of Wordpress files back to root:
Don't forget that the uploads directory needs to be owned by www-data: