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

2 thoughts on “Installing and configuring Apache2 and PHP on Solaris

  1. hadwi says:

    miss afew file
    – libcrypto.so.1.0.0
    – libssl.so.1.0.0
    – libmysqlclient.so.15

    so..where i can find this file, cause i cannot find the file on sunfreeware..please help..thank’s

  2. libcrypto and libssl are a part of openssl package. This package is availbale on SunFreeware.

    As per your question about libmysqlclient, I see the libmysqlclient is a part of mysql package.

    $ strings mysql-5.0.67-sol10-sparc-local | grep libmysqlclient.so.15.0.0
    1 s none mysql/lib/mysql/libmysqlclient.so=libmysqlclient.so.15.0.0
    1 s none mysql/lib/mysql/libmysqlclient.so.15=libmysqlclient.so.15.0.0
    1 f none mysql/lib/mysql/libmysqlclient.so.15.0.0 0755 bin bin 449408 46517 1222430549
    1 s none mysql/lib/mysql/libmysqlclient.so=libmysqlclient.so.15.0.0
    1 s none mysql/lib/mysql/libmysqlclient.so.15=libmysqlclient.so.15.0.0
    1 f none mysql/lib/mysql/libmysqlclient.so.15.0.0 0755 bin bin 449408 46517 1222430549

    Also note that, the earlier version of mysql package (mysql-5.0.3x or earlier) for Solaris did not have libmysqlclient in it. If you are using an earlier version of MySQL, you may consider switching to a newer version. You may check out the following article for Installation of MySQL, which is also a part of this series.

    Installing and Configuring MySQL on Solaris

    Hope this helps.

Leave a comment