Welcome to the Hindi Tutor QA. Create an account or login for asking a question and writing an answer.
Abhishek in Web Hosting
edited
Ubuntu is an open source software operating system that runs from the desktop, to the cloud, to all your internet connected things.

1 Answer

0 votes
Pooja

WordPress is the most popular open source blogging system and CMS on the Web. It is based on PHP and MySQL. Its features can be extended with thousands of free plugins and themes.

In this tutorial we will install WordPress on Apache2 server and create our first post.

What you’ll learn

  • How to set up WordPress
  • How to configure WordPress
  • How to create first post

Install WordPress

To install WordPress, use following command:

sudo apt update
sudo apt install wordpress php libapache2-mod-php mysql-server php-mysql

If you haven’t installed MySQL before, you will be asked for password for “root” MySQL user. You can leave this field empty.

Configure Apache for WordPress

Create Apache site for WordPress. Create /etc/apache2/sites-available/wordpress.conf with following lines:

sudo nano /etc/apache2/sites-available/wordpress.conf

and ad the lines in this file:

Alias /blog /usr/share/wordpress
<Directory /usr/share/wordpress>
    Options FollowSymLinks
    AllowOverride Limit Options FileInfo
    DirectoryIndex index.php
    Order allow,deny
    Allow from all
</Directory>
<Directory /usr/share/wordpress/wp-content>
    Options FollowSymLinks
    Order allow,deny
    Allow from all
</Directory>

Then, enable this site with sudo a2ensite wordpress, enable URL rewriting with sudo a2enmod rewrite and reload apache2 with sudo service apache2 reload.

sudo a2ensite wordpress
sudo a2enmod rewrite
sudo service apache2 reload

Configure database

To configure WordPress, we need to create MySQL database. Let’s do it!

sudo mysql -u root
CREATE DATABASE wordpress;
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER
-> ON wordpress.*
-> TO wordpress@localhost
-> IDENTIFIED BY '<your-password>';
FLUSH PRIVILEGES;
quit;

Now, let’s configure WordPress to use this database. Open /etc/wordpress/config-localhost.php and write:

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

and ad the lines in this file:

<?php
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', '<your-password>');
define('DB_HOST', 'localhost');
define('DB_COLLATE', 'utf8_general_ci');
define('WP_CONTENT_DIR', '/usr/share/wordpress/wp-content');
?>

Enable MySQL with sudo service mysql start.

sudo service mysql start

Configure WordPress

Open localhost/blog in your browser. You will be asked for title of your new site, username, password and address e-mail. You can choose if you want to make your site indexed by search engines.

You can now login under localhost/blog/wp-login.php. In Dashboard, you will see bunch of icons and options. Don’t worry, it’s easy!

Write your first post

You have probably noticed that “Hello world!” post. We will delete it and write something more interesting…

From Dashboard (localhost/blog/wp-admin/), select “Posts” icon and click on “All Posts”. Mouse over the “Hello world!” post title and select Trash.

To create new post, click on the “Add New” button. You should notice a fancy WYSIWYG editor with simple (but powerful) text formatting options. You may want to switch to Text mode, if you prefer pure HTML.

Let’s write something! It’s as easy, as using text processors that you know from office suites.

Now, click the Publish button. You can now view your brand new post!

That’s all!

You can install one of thousands of available (free and commercial) plugins and themes. You can even configure it as forum (with bbPress plugin), microblogging platform (BuddyPress), eCommerce platform (WooCommerce) or extend existing WordPress features with plugins like JetPack or TinyMCE Advanced.

WordPress manual and documentation is available in the WordPress Codex.You can read it to learn more about WordPress usage, and even something about themes/plugins development.

Related questions

...