Unable to Install mkpasswd on CentOS 6.4

I was surprised to find the mkpasswd utility missing from my new installation of CentOS 6.4.

Yum has a feature called whatprovides, which can be used to find out which installable package provides some feature, utility or file. The below demonstrates its use. You just need to prefix ‘*/’ to the utility name that your searching for.

[root@server ~]# yum whatprovides */mkpasswd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base/filelists_db                                                                                                                     | 5.9 MB     00:00     
extras/filelists_db                                                                                                                   |  10 kB     00:00     
updates/filelists_db                                                                                                                  | 2.8 MB     00:00     
expect- : A program-script interaction and testing utility
Repo        : base
Matched from:
Filename    : /usr/bin/mkpasswd

[root@server ~]# 

The output shows us that the expect package contains the mkpasswd utility.

[root@server ~]# yum install expect

Now I can quickly and easily generate strong passwords from the Linux command line. For example, the following command produces a password using the default set of arguments.

[root@server ~]# mkpasswd

A default password is 9 characters long. Each password will have at least 2 digits (numbers); 2 upper and 2 lowercase alphabetic characters; plus 1 special character, which in our example is an asterisk (‘*‘).

“Spinning up” a Rackspace Cloud Server

Assuming you’ve already created yourself a Rackspace cloud account and that you’ve just logged in, you will see a list of cloud servers (if you have any yet). These are your current servers. If a server is listed here, you will be getting charged for it at an hourly rate. Even if you shutdown your server through the Operating System! To avoid getting charged for something you are not using, take a snapshot and then delete it. You can always build a new server instance from that snapshot at a later point in time when it is required.

Servers tab
Servers tab

To create a new server, you simply click “create server“, then provide the following information.

Server name:

Once filled out, kick the build process off by clicking “create server” at the bottom of the page.

Select flavour and instance type
Select flavour and instance type

The server will then go into “building” state until complete when it then goes into “active". Although it only takes a few minutes to be deployed, you are free to continue using other parts of the website. You can even spin up more servers while you wait if you want!!

Building server
Building server

And that is it! Your first cloud server! Easy!

Your new server details
Your new server details

How to connect to your new cloud server depends on what Operating System you chose to install, Windows or Linux? If you chose Linux, you will need to use SSH. If Windows, you can use RDP. Here we chose CentOS – which is essentially just a free, re-branded release of Red Hat Enterprise Linux. If using SSH, issue below command.

[root@server ~]# ssh root@

Don’t forget to replace with the public IP address of your cloud server!

Installing WordPress on a Rackspace Linux Cloud Server

Assuming you’ve already “spun-up” a Linux cloud server of your choice, the first thing to do is update the system. I’m using CentOS because it’s free and binary compatible with Red Hat Enterprise Linux (RHEL).

SSH onto your box with the below command, replacing the IP address with that of your server. You will need to accept the key when prompted.

Gentoo-20121221 ~ #

ssh root@

The authenticity of host ' (' can't be established.
RSA key fingerprint is d3:18:87:29:fe:05:4d:13:ee:75:76:g8:c0:d8:1z:81.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (RSA) to the list of known hosts.
root@'s password:
[root@hagman ~]#

Then update the system and reboot if needed.

[root@hagman ~]# yum check-update
[root@hagman ~]# yum update
[root@hagman ~]# reboot

Install the required software:

  • The Apache web server
  • MySQL database server
  • PHP

Fortunately this can be done with one command.

[root@hagman ~]# yum install mysql-server httpd php php-mysql

Make sure that php-common is also pulled in as a dependency before confirming the installation. If unsure, you can run:

[root@hagman ~]#

rpm -qa | grep php


Configuring MySQL

Here we start the MySQL server process, secure it, and then connect to the database and prepare it for the WordPress installation. Lastly we add the service to the default run-level. We validate that all services start on boot towards the end of this document, when we reboot to test the WordPress installation for the final time.

The below command will start the service.

[root@hagman ~]# service mysqld start

Now we secure MySQL.

[root@hagman ~]#


Enter current password for root (enter for none):
Set root password? [Y/n]: Y
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

All done! If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

[root@hagman ~]#

Now we create a database for WordPress to use. First we need to create a system user to grant with privileges on the database.

[root@hagman ~]# useradd wordpress-db-usr
[root@hagman ~]# passwd wordpress-db-usr
[root@hagman ~]# mysql -p
Enter password: root_mysql_password

Once successfully logged in as the root database user, create the database and grant privileges. Pay close attention to the characters used, “`“, instead of “” most of the time.

mysql> CREATE DATABASE `wp-db`;
mysql> GRANT ALL PRIVILEGES ON `wp-db`.* TO `wp-db-usr`@localhost IDENTIFIED BY 'wp_user_db_passwd';
mysql> EXIT

Lastly we add the MySQL daemon to the boot process.

[root@hagman ~]# service mysqld status
mysqld (pid 4073) is running...
[root@hagman ~]# chkconfig mysqld --list
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off

[root@hagman ~]# chkconfig mysqld on

[root@hagman ~]# chkconfig mysqld --list
mysqld 0:off 1:off

2:on 3:on 4:on 5:on

[root@hagman ~]#

Configure Apache

Now we need to start Apache but to avoid seeing a warning message like the one below, we need to first set the ServerName directive in the httpd.conf.

[root@hagman ~]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 2001:4800:7814:0:9948:8a2e:ff05:172f for ServerName

To set the directive, open up the Apache configuration file with a text editor.

[root@hagman ~]# service httpd status
httpd is stopped
[root@hagman ~]# nano /etc/httpd/conf/httpd.conf

Uncomment out the ServerName directive to look like this:

ServerName localhost

Now start (or restart if already running) the Apache service.

[root@hagman ~]# service httpd start
Starting httpd: [ OK ]

Now lets add Apaches httpd process to the default run-level.

[root@hagman ~]# chkconfig httpd --list
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

[root@hagman ~]# chkconfig httpd on

[root@hagman ~]# chkconfig httpd --list
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@hagman ~]#

Install WordPress and Configure Apache

If you plan on creating multiple vhost sites, create a separate directory to hold the WordPress files. The below commands do just that. We also download the latest version of WordPress, extract it, clean up a little and then the last line just removes the (hopefully empty) folder called wordpress.

[root@hagman ~]# mkdir /var/www/html/pikedom-wp
[root@hagman pikedom-wp]# cd /var/www/html/pikedom-wp
[root@hagman pikedom-wp]# wget http://wordpress.org/latest.tar.gz
[root@hagman pikedom-wp]# tar -xzvf latest.tar.gz
[root@hagman pikedom-wp]# rm -v latest.tar.gz
[root@hagman pikedom-wp]# mv -v wordpress/* .
[root@hagman pikedom-wp]# rmdir -v wordpress/

We also need to change the permissions so that apache has both owner and group access rights over the whole site.

[root@hagman pikedom-wp]# chown -Rv apache:apache /var/www/html/pikedom-wp

Here we create a WordPress configuration file from the supplier sample. We also remove the read permission for other.

[root@hagman pikedom-wp]# cp wp-config-sample.php wp-config.php
[root@hagman pikedom-wp]# chmod -v o-r wp-config.php
[root@hagman pikedom-wp]# nano wp-config.php

I changed the below parts.

define('DB_NAME', 'wp-db');
define('DB_USER', 'ifiwerepm-db-usr');
define('DB_PASSWORD', 'wp_user_db_passwd');
define('DB_HOST', 'localhost');

define('AUTH_KEY',         'BhewLNMhybYW[LaGOwHup&rqc;ZDtD6TTrjL;tkPo4LrYglmpS' );
define('SECURE_AUTH_KEY',  'q:rA7YIJaFljQCypOsbnLz{nOdBwmxO8PB;biyt?uYEOhQUfaL' );
define('LOGGED_IN_KEY',    'JKNZK:onwheckZfsljyX[xeQ6aLJHc]hz-hJSBA4woMBQxRuzT' );
define('NONCE_KEY',        'TpoRX?XbN$ZpFrGryr"kiCiF6QbZgFjVDRaC/xPgl6UozabJwn' );
define('AUTH_SALT',        'HtXyIleIlTt2EnVuyqwZgG-khhI{NtHVBT9wf.fY?CrXefBJqo' );
define('SECURE_AUTH_SALT', 'BHlKtVFPLlOF(sqcy'R{zSFDTmhCio4vg6Wa%rgfIShtOhskfX' );
define('LOGGED_IN_SALT',   '7jSeHszKlCluRzW@=qkyAaqD_dDFd*gFplguHBNtqBABVVu1rV' );
define('NONCE_SALT',       'TqnfxC7TPae6UhfzA>ZuwAmbHDnNiYteLCI}ziJazbJHxDqN:w' );

$table_prefix  = 'pikedom_';

Now we create an Apache configuration file for the site.

nano /etc/httpd/conf.d/pikedom-wp.conf

Create something like this. Save and exit.

ServerAdmin test@test
DocumentRoot /var/www/html/pikedom-wp
ServerName www.pikedom.com

# Logging
ErrorLog /var/log/httpd/wordpress-error-log
CustomLog /var/log/httpd/wordpress-access-log common

Note, the email address, test@test gets included in any error messages sent to the client. Official documentation recommends that you create an email address for that specific purpose. www-admin@yourdomain.com for example.

Reboot and Check Services

Now reboot to check that everything still works.

shutdown -r now

From another computer, try to access the site by entering the IP address in a web browser.

If all went well, you should see a page similar to the below.


All you need to do now is configure your DNS settings so that others can find your site by typing the domain name instead of the IP address.

If you do not get the response you were expecting, make sure that Apache and MySQL are still running. If not, you need to make sure the services are starting at boot.