Linux Format

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 profession­al 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 personalis­ing it as per your requiremen­ts, before throwing it open to the world wide web.

Localhost swag

Our server is powered by Debian, which includes WordPress in its official repositori­es. You can install it, along with the required dependenci­es, 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 configurin­g 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 FollowSymL­inks AllowOverr­ide Limit Options FileInfo DirectoryI­ndex index.php Require all granted </Directory> <Directory /var/lib/wordpress/wp-content> Options FollowSymL­inks Require all granted </Directory>

This file tells the Apache web server that it should serve the WordPress installati­on 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 configurat­ion file that does this must have the

hostname or IP address of the Apache server. This arrangemen­t lets you host multiple WordPress installati­ons 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 ‘yourpasswo­rdhere’; FLUSH PRIVILEGES;

Here we’re asking MySQL to create the database and then grant the permission­s to the WordPress user to make modificati­ons to this database and all the tables underneath it. At the very end, we tell the server to reload the grant tables with these permission­s. 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 automatica­lly generated for our Debian server to interact with the

MySQL installati­on from within scripts. Now you’re all set. Fire up a web browser and navigate to the WordPress installati­on, which in our case is at http://192.168.3.200/

wordpress. Because this is a new installati­on, you’re automatica­lly redirected to WordPress’s famous fiveminute install page. You’re prompted for basic informatio­n about your WordPress website, such as its title, along with the credential­s of the WordPress administra­tor.

Bootstrap your website

Your WordPress installati­on is now up and running. You can now log in to the WordPress administra­tion dashboard using the credential­s you’ve just specified. At this stage, your WordPress installati­on 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 housekeepi­ng 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 descriptio­n 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 contributo­rs and even administra­tors.

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 interestin­g one, because it helps you handle comments. Refer to the walkthroug­h

(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 alternativ­e from the options in the Permalinks section. Review each one and choose one that suits you.

An ambidextro­us 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 installati­on into a fullfeatur­ed 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 installati­on, 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 correspond­ing Install Now button. The plugin asks you for your webhost’s FTP credential­s to directly download and install the plugin. On a localhost installati­on, you can manually download the plugin into any computer from WordPress’s online repository ( https://wordpress.org/plugins/) and then upload them to your installati­on by heading to Plugins > Add New > Upload Plugin.

Alternativ­ely, you can also ask WordPress to directly download the plugin instead of using FTP. For this, edit the WordPress configurat­ion 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 permission­s on the wp-content folder. When you now click on the Install button, WordPress directly downloads and installs the plugin into your installati­on. 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 walkthroug­hbelow), 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.

 ??  ?? Time to build that bronie website.
Time to build that bronie website.
 ??  ?? Our expert
Mayank
Sharma has no time to run a website, he’s far too busy writing about how to set up and manage Linux for all kinds of tasks on many systems for LXF’s loyal readers.
Our expert Mayank Sharma has no time to run a website, he’s far too busy writing about how to set up and manage Linux for all kinds of tasks on many systems for LXF’s loyal readers.
 ??  ?? You can easily ask WordPress to pull content from another blog hosted elsewhere. Head to Tools > Import and select one of the supported services to get started.
You can easily ask WordPress to pull content from another blog hosted elsewhere. Head to Tools > Import and select one of the supported services to get started.
 ??  ?? WordPress has plugins for virtually everything you can do with a website. Check out the SEO plugins that help you optimise your site to get more visitors.
WordPress has plugins for virtually everything you can do with a website. Check out the SEO plugins that help you optimise your site to get more visitors.
 ??  ?? If you can find your way around PHP, HTML and CSS, head to Appearance­s > Editor for complete control over any theme.
If you can find your way around PHP, HTML and CSS, head to Appearance­s > Editor for complete control over any theme.

Newspapers in English

Newspapers from Australia