It’s time to take the latest release of the world conquering open source CMS for a spin, Mayank Sharma is your guide.
Fancy a project? Then follow Mayank Sharma’s advice to broadcast your website from the garage to show off the robustness of open-source software.
One of the crown jewels of open-source software, WordPress is one of the leading proponents in the growth of read-write web. The nifty little tool helps roll out and serve all kinds of websites – from simple onepage personal blogs to complex portals that put out all kinds of content to users around the world.
Its free price tag and easy-to-use interface make WordPress an ideal choice to power your web presence. It has an extensive back-end management interface that gives you all the power you’d want from a professional content management system but is still docile enough to be mastered by first-timers. In this tutorial, we’ll help you host your own instance of WordPress and take you through the steps involved in personalising it as per your requirements, before throwing it open to the world wide web.
Localhost swag
Our server is powered by Debian, which includes WordPress in its official repositories. You can install it, along with the required dependencies, with: sudo apt-get install wordpress curl apache2 mysql-server The process only asks you to set the password for the MySQL root user.
Once the components have been installed, we’ll define the parameters for our website by configuring an Apache site as follows: # nano /etc/apache2/sites-available/wp.conf Alias /wordpress /usr/share/wordpress Alias /wordpress/wp-content /var/lib/wordpress/wp-content <Directory /usr/share/wordpress> Options FollowSymLinks AllowOverride Limit Options FileInfo DirectoryIndex index.php Require all granted </Directory> <Directory /var/lib/wordpress/wp-content> Options FollowSymLinks Require all granted </Directory>
This file tells the Apache web server that it should serve the WordPress installation when someone visits the /wordpress directory on our server, such as http:// 192.168.3.200/wordpress, and where it’ll find the actual content. After creating the Apache site, enable it with: a2ensite wordpress and bring it online with: service apache2 reload
Database kung fu
Next we must point Apache to the WordPress database. The configuration file that does this must have the
hostname or IP address of the Apache server. This arrangement lets you host multiple WordPress installations from the same server. In our case, create the following file: # nano /etc/wordpress/config-192.168.3.200.php <?php define(‘DB_NAME’, ‘wordpress’); define(‘DB_USER’, ‘wordpress’); define(‘DB_PASSWORD’, ‘the-mysql-password’); define(‘DB_HOST’, ‘localhost’); define(‘WP_CONTENT_DIR’, ‘/var/lib/wordpress/ wp-content’); ?>
We’ll now create and populate this WordPress database with a little SQL magic. Create a temporary file (~/ wordpress.sql) with the following lines: CREATE DATABASE wordpress; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE, DROP,ALTER ON wordpress.* TO wordpress@localhost IDENTIFIED BY ‘yourpasswordhere’; FLUSH PRIVILEGES;
Here we’re asking MySQL to create the database and then grant the permissions to the WordPress user to make modifications to this database and all the tables underneath it. At the very end, we tell the server to reload the grant tables with these permissions. Now we’ll use this file to create the database with: cat ~/wordpress.sql | mysql --defaults-extra-file=/etc/mysql/ debian.cnf
The debian.cnf file is a file that’s been automatically generated for our Debian server to interact with the
MySQL installation from within scripts. Now you’re all set. Fire up a web browser and navigate to the WordPress installation, which in our case is at http://192.168.3.200/
wordpress. Because this is a new installation, you’re automatically redirected to WordPress’s famous fiveminute install page. You’re prompted for basic information about your WordPress website, such as its title, along with the credentials of the WordPress administrator.
Bootstrap your website
Your WordPress installation is now up and running. You can now log in to the WordPress administration dashboard using the credentials you’ve just specified. At this stage, your WordPress installation is very vanilla. You can take a look by heading over to http://192168.3.200/wordpress. Before you can add any content to the website, though, you need to spend some time doing a few housekeeping chores. Log in to the Dashboard and head over to the Settings option in the navigation menu on the left, which opens up a list of submenus.
The General section houses settings that define the basic structure of the website. You can change the site’s title and description that you provided in the welcome screen earlier. You can also customise other aspects, such as selecting a timezone, along with the appearance of the date and time on your website.
One important setting in this section is the Membership option. If you wish for other people to register on your website, make sure you toggle the Anyone Can Register checkbox. After enabling the membership option, you can use the pull-down adjacent to the New User Default Role setting to select the role that you want new users to have when they register for user accounts in your blog. The list enables you to add everyone from simple readers to contributors and even administrators.
Next up is the Writing section, which helps you customise some settings when you’re composing a post, including a few formatting options and the default category for the post. Then there’s the Reading section, which hosts a number of parameters to influence the appearance of your website. For example, by default
WordPress displays the latest post on the front page when someone visits your website. But you can instead ask it to display a static page. If you plan to continue displaying
posts, you can change the maximum number that are displayed on each page. The last option controls whether your website is indexed by a search engine or not. Usually you wouldn’t want to toggle the Discourage Search Engines From Indexing This Site checkbox, unless you’re only hosting the website for a limited number of people who have the direct address of your website.
The Discussion section is an interesting one, because it helps you handle comments. Refer to the walkthrough
(below) to make the most of the settings in this section. Next up is the Media section, where you can configure the options for how WordPress resizes your images when adding them to its media library. Use the page to specify the dimensions for each of the three supported sizes. Finally, there’s the Permalinks section. All posts in
WordPress are assigned their own URL, which is known as a permalink, because it’s meant to be a permanent pointer to the post. By default, a blog post permalink in
WordPress looks like www.example.com/?p=123/ where the numerical bit is the unique ID of the post. You can leave
the permalinks in this format or make them user-friendly by selecting an alternative from the options in the Permalinks section. Review each one and choose one that suits you.
An ambidextrous website
WordPress is a very powerful system for managing websites. With plugins, you can turn it into a Swiss army knife for publishing content. WordPress plugins come in all shapes and sizes. They can turn your installation into a fullfeatured gallery for posting images, an online store to sell your products, or even a social networking website.
The WordPress plugin repository hosts both free and paid plugins. A couple are even bundled with the default installation, including Akismet, which is useful for quashing spam. To use the plugin, you need to get yourself an API key by signing up for a free Wordpress.com account.
To find additional plugins, head to Plugins > Add New. When you find a plugin you like, click the corresponding Install Now button. The plugin asks you for your webhost’s FTP credentials to directly download and install the plugin. On a localhost installation, you can manually download the plugin into any computer from WordPress’s online repository ( https://wordpress.org/plugins/) and then upload them to your installation by heading to Plugins > Add New > Upload Plugin.
Alternatively, you can also ask WordPress to directly download the plugin instead of using FTP. For this, edit the WordPress configuration file (/ etc/wordpress/ config-192.168.3.200.php in our case) and add the following line into it: define(‘FS_METHOD’, ‘direct’);
Also, make sure the user who runs the Apache service has the read/write permissions on the wp-content folder. When you now click on the Install button, WordPress directly downloads and installs the plugin into your installation. Note, however, that while this is convenient, it shouldn’t be used in production servers.
We’ve covered the most important elements you need to host a website. How head to the Appearance section in the Dashboard to customise the look and feel of the website. From here, you can browse, add and customise themes ( see walkthroughbelow), just as you did with plugins, create and edit menus, and upload a header image, as well as an optional one for the background. It’s all fairly intuitive and well documented on http://wordpress.org and on several third-party websites and sources.