WordPress is a popular open source content management system, most commonly used as a blogging tool, based on PHP5 and MySQL.

Cloud Installation

WordPress has an optimized juju charm available for high performance and ease of management. Refer to this page for deployment instructions.

Local LAMP Installation

WordPress runs on the LAMP (Linux, Apache, MySQL, PHP) stack of applications.

First you need to install and configure LAMP. See the ApacheMySQLPHP page.

Enable the Universe repository

Install WordPress

WordPress can be manually installed by downloading the .tar.gz available at the WordPress.org official website, and uncompressing it inside /var/www (or a sub-folder).

Alternatively, the package wordpress is available through the universe repositories. Use any method to install the package, such as the Software Center, or running apt-get install from a terminal:

 sudo apt-get install wordpress

The installation places the files in the /usr/share/wordpress folder. So that Apache2 knows where to find the installation folder, make a symbolic link to the Apache2 www folder:

sudo ln -s /usr/share/wordpress /var/www/html/wordpress

Before running the mysql script described below you need to install MySQL if you don't have it yet:

sudo apt-get install mysql-server

Then uncompress and install WordPress using the supplied script:

sudo gzip -d /usr/share/doc/wordpress/examples/setup-mysql.gz
sudo bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress localhost

This script creates the MySQL database and user wordpress for the URL localhost. If you will be hosting a virtual host and/or already know your URL, it is best to name your database the same as your URL. Also if you plan on hosting multiple blogs with different virtual hosts, each needs a differently named database, which would be achieved in the same way. For example, if your URL is wordpress.mydomain.org, then the command would be

sudo bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress_mydomain_org wordpress.mydomain.org

If you will be using a virtual host, create your apache2 virtual host file in the /etc/apache2/sites-available folder. When you are finished, enable it by making a symbolic link from that virtual host file to the sites-enabled folder. However, this can be dangerous until you have secured your WordPress installation against malicious anonymous users on the Internet, so should only be done after the initial installation is complete and anonymous user creation is turned off. Whenever you change your virtual hosts, you must restart Apache2:

sudo /etc/init.d/apache2 restart

Now, browse to "http://localhost/wordpress" in your browser (or http://''wordpress.mydomain.org''/wordpress if you are using a virtual host), and proceed with the Wordpress "five minute installation process", which will allow you to set up the first administrator account.

  • wordpress-installation.png

WordPress will notify you through the Dashboard if an update is available. For automatic updates to occur, the folder and all its files and subfolders must be owned by www-data:

 chown -R www-data /usr/share/wordpress

Once installed, to change the url of your site, link the file /etc/wordpress/config-localhost.php to /etc/wordpress/config-my.url.com.php as well as changing the URL in the wordpress configuration Options menu. For example, if the target URL for WordPress was blog.canonical.com

sudo ln -s /etc/wordpress/config-localhost.php /etc/wordpress/config-blog.canonical.com.php

And change the URLs in Settings -> General with the desired address:

  • wordpress-url.png

The "WordPress Address" is where the installation is stored, whereas the "Site Address" will be the one you and your visitors will access the site through, so these two addresses may differ depending on your configuration and preferences.

If you work locally and want to install custom themes manually copying your theme directly in the wp-content/themes folder, be sure you create a symbolic link for it as well:

sudo ln -s /var/www/wordpress/wp-content/themes/your_theme/ /var/lib/wordpress/wp-content/themes/your_theme

Troubleshooting

While trying to install a plugin on your local installation of wordpress, if you get an error like "An error occurred while updating... Could not create directory .../wp-content/upgrade/...", it could be because the default configuration file in /etc/wordpress directory does not point to an existing or writable content directory. This can also cause errors that prevent uploading media (like images) or pictures that are uploaded but do not show correctly in your browser.

Follow these steps to resolve this issue:

sudo vi /etc/wordpress/config-localhost.php

Your configuration file name may be different from config-localhost.php.

Ensure that WP_CONTENT_DIR points correctly to where wordpress installed wp-content directory is. For example

define('WP_CONTENT_DIR', '/var/www/wordpress/wp-content');

WordPress.org, official website, from which the software can be downloaded in a compressed tarball or zipfile. It also includes an extensive wiki (the "Codex"), as well as a support forum and theme and plugin gallery.

WordPress.com, official free hosted solution provided by the developers Automattic, who also provide serveral other WordPress-related services.

WordPress (last edited 2014-08-29 08:27:09 by cyd11)