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.

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!!