Installing and Configuring WordPress Richard Boakes rjb@boakes.org Introduction A talk based on experiences A view from orbit with zoom where necessary A necessarily incomplete view covering just the bits I use avoiding the obvious An invitation to get involved Richard Boakes 31 May 2016 2 Introduction (You) You are: a) Poised to install this second b) Planning on installing soon c) Might install one day d) Just vaguely interested e) Catching up on email Richard Boakes 31 May 2016 3 Agenda Key Features Reasons to use WP Installing WordPress Pre-Requisites Getting the code The Famous 5-minute Install Updating WordPress Content Backups Extending WordPress Finding and Using Plugins Particularly Useful Plugins Creating and Extending Plugins Closing thoughts Integrating with WordPress The Future of WordPress Richard Boakes 31 May 2016 4 Key Features An editor For weblog articles & For static pages. Runs on many common hardware & OS combinations. Win32/64, Linux, Solaris Adheres to open standards e.g. XHTML, RSS, ATOM, CSS, XML-RPC. Sound program architecture. Handles all visitor interaction Including comments, trackbacks & pingbacks. Sanitized and Salted. Robust anti-spam solutions. Over 3 yrs & 300,000 spams. None were published. Export and Import mechanisms Easy to backup and restore. Easy to move your data if you don’t get on with it. Easy to maintain. Easy to adapt. Easy to extend. Richard Boakes 31 May 2016 5 Installing WordPress Pre-Requisites Required Web Server Apache – v2 with rewrite module enabled PHP – v4.3 MySQL –v4.0 Optional a subversion client Richard Boakes 31 May 2016 7 Decide where you are working Work on the server, over SSH Great when hacking about & setting up. Only mildly scary on a live service Take temp copies for safety Work on a client Great if it’s a private or local site For servers: Manually upload using sftp, etc. Use sync tool Richard Boakes 31 May 2016 8 Locate your httpd.conf Windows C:\Program Files\Apache Group\Apache2\conf Linux /etc/apache2/httpd.conf Mac OS X /etc/apache2/httpd.conf Richard Boakes 31 May 2016 9 Remember your DocumentRoot DocumentRoot is defined in httpd.conf common values are: /home/www/yourserver/htdocs /Library/WebServer/Documents You’ll need it later Richard Boakes 31 May 2016 10 Configure httpd.conf Enable PHP (Win) LoadModule php5_module "C:/Program Files/PHP/php5apache2.dll“ Enable PHP (Linux) LoadModule php5_module libexec/apache2/libphp5.so Enable PHP index pages DirectoryIndex index.php index.html Richard Boakes 31 May 2016 11 Configure httpd.conf Allow .htaccess override <Directory /> Options FollowSymLinks AllowOverride All Order deny,allow Deny from all </Directory> Richard Boakes 31 May 2016 12 Configure PHP On Windows The MSI does everything for you you need to specify the MySQL extension On Mac OS X An extra step is sometimes needed cp /etc/php.ini.default /etc/php.ini sudo chmod +w /etc/php.ini sudo /usr/sbin/apachectl restart On linux ??? (lets see what breaks) Richard Boakes 31 May 2016 13 Locate your MySQL Windows C:\Program Files\MySQL\MySQL Server 5.0\bin\ Linux (apt-get) /usr/bin/ Mac OS X /usr/local/mysql-5.1.32-osx10.5-x86/bin/ Got root? find it with sudo find / –name mysql Richard Boakes 31 May 2016 14 Configure MySQL Login to mysql mysql -u adminusername -p Enter password: Create a database for wordpress to use mysql> CREATE DATABASE mydbname; Query OK, 1 row affected (0.00 sec) Richard Boakes 31 May 2016 15 Configure MySQL Create a DB user for WordPress mysql> GRANT ALL PRIVILEGES ON mydbname.* TO “myusername"@“myhostname“ IDENTIFIED BY “mypassword"; Query OK, 0 rows affected (0.00 sec) Force the changes through mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.01 sec) mysql> EXIT Richard Boakes 31 May 2016 16 Get the code either download the code from http://wordpress.org/download/ unpack it to your DocumentRoot or Navigate to your DocumentRoot, and svn co http://svn.automattic.com/ wordpress/tags/2.7.1 wordpress Richard Boakes 31 May 2016 17 Configure WordPress Copy the sample config file cp wp-config-sample.php wp-config.php Edit your new config file define('DB_NAME', mydbname'); define('DB_USER', myusername'); define('DB_PASSWORD', mypassword'); define('DB_HOST', ‘myhostname'); … and make up 4 random auth keys… Richard Boakes 31 May 2016 18 The moment of truth… Visit http://yourserver/wordpress/ Richard Boakes 31 May 2016 19 Congratulations! You up and running (hopefully) …but Vulnerabilities arise so update regularly. Things go wrong so make backups Richard Boakes 31 May 2016 20 Updating WordPress! When an update is released either download the code unpack it copy it into your existing folder or Use subversion to switch to the latest stable tagged build i.e. svn switch http://svn.wordpress.org/the/tagged/version Richard Boakes 31 May 2016 21 Content Backups Use mysqldump to backup mysqldump.exe -uroot –ppassword --all-databases >c:\backup.sql And recover using mysql mysql.exe -uroot –ppassword <c:\backup.sql Or use a plugin… Richard Boakes 31 May 2016 22 Extending WordPress Admin Screen http://yourserver/wordpress/wp-admin Richard Boakes 31 May 2016 24 Pretty Permalinks Default URLs are not descriptive http://example.com/?p=1 Pretty Permalinks are better http://example.com/helloworld Open the Settings/Permalinks Select “Custom Structure” Enter /%postname% Save changes Richard Boakes 31 May 2016 25 Quick notes on publishing Adding content Adding tags Editing a published article Renaming a published article Richard Boakes 31 May 2016 26 Widgets Add handy things to your pages In the admin interface Open Appearance / Widgets Add widget plugins for more capabilities e.g. Twitter Richard Boakes 31 May 2016 27 Finding and Using Plugins How to find http://wordpress.org/extend/plugins Search Engines How to install Web Automated installation Web upload Command line Manual installation SVN installation Richard Boakes 31 May 2016 28 Particularly Useful Plugins Anti-spam Akismet (installed) BadBehaviour Identity OpenID Anti-slashdot WPSuperCache Richard Boakes 31 May 2016 29 Creating and Extending Plugins Source Control Subversion over HTTP The Plugin Format Descriptive Header PHP Code Actions (aka Events, Hooks, Callbacks) do_action(“my_action”); add_action(“action_name”, “function_name”)’ Richard Boakes 31 May 2016 30 A NeSC Plugin <?php /* Plugin Name: NeSCPlugin URI: http://nesc.ac.uk/made/up/url Description: This adds the word NeSC to every page on the admin screen Author: Rich Boakes Version: 0.1 */ function nesc_tagline() { echo "<p class='floaty'>" . wptexturize( "NeSC" ) . "</p>"; } function nesc_css() { echo "<style type='text/css'>.floaty { position: absolute; top: 5em; right: 5em; }</style>"; } add_action('admin_head', 'nesc_css'); add_action('admin_footer', 'nesc_tagline'); ?> Richard Boakes 31 May 2016 31 Integrating with WordPress XML-RPC interface editing articles, publishing, moderating comments For example: iphone.wordpress.com Richard Boakes 31 May 2016 32 The Future of WordPress 3.6million downloads of v2.7 GNU Public License v2 Three releases per year features are voted for by the user community Further Help WordCampUK Cardiff, 18-19 July 2009 (a weekend) http://uk.wordcamp.org Web http://wordpress.org IRC #wordpress Richard Boakes 31 May 2016 33 Where to find out more WordCampUK Cardiff, 18-19 July 2009 (a weekend) http://uk.wordcamp.org Web http://wordpress.org IRC #wordpress Or ask me rich@boakes.org Richard Boakes 31 May 2016 34