Installing WordPress on Solaris 10

I was discussing about how to install MySQL and configure it with Apache and PHP in my earlier articles. This is the 3rd and final article of the series for configuring wordpress on Solaris from scratch. Once the MySQL, Apache and PHP are working together, wordpress (or any CMS) can be installed and configured easily.

Go ahead and download the latest version of wordpress from wordpress.org and extract the archive to apache htdocs directory. You may also extract the archive to any other directory and create a symbolic link in htdocs to that directory. [For this example, I will copy the installation to wordpress directory in htdocs. Hence my site address will be http://hostname/wordpress.%5D

WordPress needs a MySQL user and a database for keeping its data. You may use the mysql user to create the database. But it is advisable to use a separate user for wordpress and grant it all the permissions over its tablespace.

To create a user in MySQL, logon as root or mysql user to MySQL and execute the following command.

CREATE USER ‘anyuser’@’localhost’

IDENTIFIED BY PASSWORD ‘anypassword’;

Now, create a database in MySQL and grant all permissions over that table to wordpress user.

CREATE DATABASE wordpress;

GRANT ALL ON wordpress.* TO 'anyuser'@'localhost'

IDENTIFIED BY ‘wordpressuserpassword’;

Execute the following command to copy existing config file for wordpress and fill in your values.

cd /usr/local/apache2/htdocs/wordpress

cp wp-config-sample.php wp-config.php

Open an editor and edit wp-config.php file for your database details. Look into wordpress configuration manual for editing the entries.

If you are already using your webserver for php files, then you may skip this step. Otherwise, your Apache installation might have not been configured to recognize index.php as an index file. Create a .htaccess file in your web root [/usr/local/apache2/htdocs for example] and add the following line in the file:

DirectoryIndex index.php

Now, your http configuration file for apache might also not have been configured to read the above configuration. To do that, open your apache configuration file (httpd.conf) and replace the following line

AllowOverride None

with

AllowOverride All 

For detailed configuration of AllowOverride feature look here.

Now, your apache has been configured to identify php files as index files, which is essential to run wordpress.

Now, open the following URL in your browser and follow the steps to configure wordress. Details can be found at the wordpress installation manual.

Add a modified date in a wordpress post

Similar to my last post on how to add the author name in a wordpress post, here is one more trick for a multiuser blog. Sometimes, when you are managing website or blog, where multiple users can create or update posts, it is required to have an eye, who and when modified the post.

Some wordpress themes have this support inbuilt and some themes (like the default “Twenty-Eleven” theme or one of my current theme “Bridge” by Blank Themes) does not have this option.

This is what need to be done:

You will find a function, similar to bridge_posted_on() [replace bridge with your theme name] in your functions.php file. This function usually shows the Author name in the post. We will add a similar function below it. The function will look similar to the code below. You may need to do some modification according to the theme you are using.

function bridge_post_modified_on() {
printf( 'Last modified by <span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span> on %4$s',
get_author_posts_url( get_the_author_meta( 'ID' ) ),
sprintf( esc_attr__( 'View all posts by %s', 'bridge' ), get_the_author() ),
get_the_author(),
esc_attr( get_the_modified_date() )
);
}

 

Now, you will find a code similar to the code below, in your content-single.php file. This code brings the title of the blog with author and date info.

<header class="entry-header">
        <h1 class="entry-title"><?php the_title(); ?></h1>
        <div class="entry-meta">
             <?php bridge_posted_on(); ?>
        </div><!-- .entry-meta -->
</header>

Now, call the post_modified_on() function here, that you defined in the functions.php in the above step.

<div class="entry-meta">
    <?php bridge_posted_on(); ?> - <?php bridge_post_modified_on(); ?>
</div><!-- .entry-meta –>

This will show the date modified along with the post date like shown below:

Your Blog Title

Posted on June 14, 2012 by Subrat Pattnaik – Last modified by Another Author on August 8, 2012

You may also call the above function anywhere you want to show the modified date with the author info (like in a search page or archive list page).

Hope this helps.

Showing author name in wordpress post

The default theme for wordpress “TwentyEleven” (along with some other themes like “Bridge” from Blank Themes) does not show the author name in the blog post by default. This is because, these themes are primarily designed for single author blogs.

To show the author name in the posts, edit the style sheet file (style.css) and replace the following code:

.single-author .entry-meta .by-author {
	display: none;
}

with the following code:

.single-author .entry-meta .by-author {
	display: inline;
}

Installing and configuring Apache2 and PHP on Solaris

As we did in our earlier article for installing MySQL, we will follow similar procedure to install and configure Apache2 server and PHP 5 packages on our Solaris x86 box. We will use sunfreeware as the source for all our packages.

Make sure you take a backup of any data/configuration files (if present) in the /usr/local/apache2 directory before proceeding.

Installing Apache2

Download the following packages from sunfreeware.

  • apache-2.2.22
  • expat-2.0.1
  • openldap-2.4.30
  • sasl-2.1.25

Unpack the files and install them using pkgadd command as root user.

Installing PHP5

Download the following packages from sunfreeware.

  • php-5.3.11
  • jpeg-8d
  • curl-7.26.0
  • freetype-2.4.2
  • libidn-1.25
  • libssh2-1.4.2
  • gd-2.0.35
  • freetds-0.91
  • libxml2-2.8.0

Unpack the files and install them using pkgadd command as root user.

After installation, check if all the dependencies are satisfied for PHP using the following command.

# ldd /usr/local/apache2/modules/libphp5.so

If any of the dependencies are not present, please go ahead and install those packages. Unless all the dependencies are installed, Apache server will not start once it is configured to use PHP.

Configuring Apache with PHP

Now we will create a php.ini file using the following command.

# cp /usr/local/php/doc/php/php.ini-production /usr/local/php/lib/php.ini

This PHP installation automatically places the libphp5.so in the apache modules directory. You might have already checked it during PHP installation, while checking for dependency packages.

Then, we have to manually modify the httpd.conf file present in the apache conf directory [/usr/local/apache2/conf], to add the following entries at their respective places.

LoadModule php5_module    modules/libphp5.so
AddType application/x-httpd-php .php

Now, we will start apache server with the following command

# /usr/local/apache2/bin/apachectl start

If all the dependency packages are installed properly, we will see a successful startup message from Apache server.

In case, you see any error at this point, that is most likely due to some missing dependencies. Once the dependent package is installed, you are not going to see the error message.

Test Apache Server

To test if all the above were successful, open your web browser and go to the following address

http://localhost

If everything is okay, you will see a page saying “It works!”.

The default web directory for apache is configured as the following directory.

/usr/local/apache2/htdocs

If you want to place your web files somewhere else, you may create soft links under this directory to point to their actual location.

To check PHP compatibility, create a test PHP file, say index.php and add the following code in it.

<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
  <?php phpinfo(); ?>
 </body>
</html>

Try to open this file using your web browser. Enjoy!!

Installing and Configuring MySQL on Solaris

This is the first part of the 3 part series, installing WordPress on Solaris 10 on x86. Here is a brief idea for what we are going to cover.

  1. Installing and configuring MySQL [this article]
  2. Installing and configuring Apache web server with PHP [part-2]
  3. Configuring wordpress on Solaris [final part]

MySQL come pre-installed on Solaris 10. However, The MySQL that came out with Solaris 10, is an older version (v4.x) and is not compatible with new installations of most other CMSs today (including wordpress). Hence we will use sunfreeware as a source to fetch all required packages and install and configure them to work together.

One major advantage is, all the packages downloaded from sunfreeware have a SMC prefix to it, so that they do not conflict with existing Solaris packages. Also, they install on /usr/local directory, as instead of /usr/sfw or /usr/bin to avoid further complications.

Installing MySQL

For the installation, download the MySQL package along with these additional packages from sunfreeware.

  • mysql-5.0.67
  • libgcc-3.4.6
  • openssl-1.0.1
  • ncurses-5.7
  • libiconv-1.14
  • libintl-3.4.0

This exact version number may not always be available, as they continue to change, once updated packages are available. You may consider looking for a compatible version, usually mentioned below the download link of a package on sunfreeware web site.

Unpack the downloaded files and use pkgadd command to install the packages as root user.

Configuring MySQL

To configure MySQL, we have to do several steps as root user. As root user, create the following directories and change permissions:

# groupadd mysql
# useradd -g mysql mysql
# cd /usr/local
# chown -R mysql:mysql mysql
# chmod -R 770 /var/mysql

Now, we will initialize the MySQL database.

# cd /usr/local/mysql
# scripts/mysql_install_db --user=mysql

Now, test the installation with the following command

# cd /usr/local/mysql/mysql-test
# su mysql -c ./mysql-test-run.pl

We are not going to test all functionalities of MySQL here. However, this test will let you know, if any dependency packages are missing on your Solaris installation. You may stop the test once MySQL stops complaining about any missing dependency packages.

Use the following command to start MySQL

# /usr/local/mysql/bin/mysqld_safe --user=mysql &

You may also create a password for mysql Solaris user (not a MySQL user). However, there is no real requirement for that, as you are not required to login to the mysql user to do any administration.

Additionally, you may configure the MySQL server startup script named mysql.server, present in /usr/local/mysql/share/mysql/ directory and put MySQL database to start during the system startup. I am not going to cover that in detail here, as the primary aim of this article is to configure and start MySQL server. Please read the comments in mysql.server script to configure it properly.

As the last step, cerate a root user password for MySQL using the following command:

mysqladmin -u root password NEWPASSWORD
[Replace NEWPASSWORD with your desired password]