Tuesday Feb 19, 2008

Now with the release of OpenSolaris distribution, Please refer to Setting up AMP Stack for OpenSolaris for steps in configuring Apache, MySQL and PHP runtime in OpenSolaris. 

Couple of days back, Open Solaris Developer Preview 2, was released to the general public. I am told that this preview (aka beta) release is based on the same milestone build (Nevada build 79b) that Open Solaris Developer Express 01/08 was released with. So, naturally I got curious and tried it out on my laptop and here is my feedback

  • On the positive side - Installation experience is very smooth. Also, fonts look sharp and even wireless on my laptop works out of the box as well.
  • On the not so positive side -  Web Stack components like Apache, PHP and MySQL are not installed as part of default install.  So, one will need to manually download and install / configure these components.  Now, the tricky part is knowing the exact name of these packages to download as the current Indiana 'pkg' command is unable to search  by common names like 'apache' or 'php' etc.

After some poking around, I found the list of additional packages available at Indiana repository and from then, it was a breeze to find the right instructions to download and configure these components.  Thought, I would share my experience here.  So, here in this blog, I will go through the list of steps needed to configure a Web Stack (Apache , PHP and MySQL) stack on my Solaris Developer Preview (aka Indiana).

- Using a 'terminal' window, download and install Web Stack components like Apache , PHP and MySQL as shown below.  Note, You will need to have a  high speed internet connection to download and install these packages.

If you are curious as to what we what are we doing here - here is a brief explanation

sriramn@sriram-laptop2:~$  pfexec pkg  install SUNWapch22 SUNWphp524core SUNWphp524usr SUNWmysql5 SUNWapch22m-php5 SUNWphp524-mysql

pfexec - a command that integrates with Solaris RBAC and allows us to run a privileged command provided we have the authorization to do so.  For example, installing a software is a privileged operation and a default user in Open Solaris Developer Preview is provided with this authorization.

pkg - new package command that can download and install specified packages from Indiana package repository.

SUNWapch22 - Apache 2.2

SUNWphp524core SUNWphp524usr -> PHP 5.2.4 core runtime and its dependent header files.

SUNWmysql5  - MySQL 5.0 database core runtime files.

SUNWapch22m-php5 - Glue to bond PHP 5.2.4 runtime within Apache

SUNWphp524-mysql  - Glue to bond PHP 5.2.4 runtime with MySQL database.

For Developer Preview 2 (aka beta) release,  I guess, we need to provide these correct package names to the 'pkg' command. Hopefully, going forward , with subsequent releases, we should be able to get the following command working

pfexec pkg install apache php mysql

Configuring MySQL for Indiana

Though, the above command successfully installed the MySQL database, there are still some some post installation steps necessary. Unlike Solaris Developer Express, where these below steps are automatically done for us, within Solaris Developer Preview 2, we will need to perform the following manual configuration to successfully configure MySQL database within Indiana.  Again, I am hoping that with Developer Preview 3, these steps should no longer be needed.

  • Create MySQL user and group and allocate MySQL data directory '/var/mysql' to this user for security purposes

sriramn@sriram-laptop2:~$  pfexec groupadd mysql

sriramn@sriram-laptop2:~$  pfexec useradd -d /var/mysql -m -g mysql mysql

sriramn@sriram-laptop2:~$  pfexec chown mysql:mysql /var/mysql

sriramn@sriram-laptop2:~$  pfexec chmod 750 /var/mysql /var/mysql/data

  • Now, let us initialize MySQL database and try to start the server. 

sriramn@sriram-laptop2:~$  pfexec su - mysql

sriramn@sriram-laptop2:~$  pfexec /usr/mysql/5.0/bin/mysql_install_db --user=mysql

sriramn@sriram-laptop2:~$  pfexec /usr/mysql/5.0/bin/mysqld_safe &

sriramn@sriram-laptop2:~$  pfexec /usr/mysql/5.0/bin/mysqladmin -u root  password '<provide a password to protect the MySQL database for the 'administrator account'>

Yup - this is all should be required to run Apache , MySQL and PHP within Indiana. With this pre configuration, you should be now ready to deploy either a wiki site like Media Wiki  on Indiana or a content management site like Drupal on Indiana  just as you would with SXDE 01/08.

Technorati Tags: ,,

In my previous blog, I mentioned the availability of components like Apache, PHP and MySQL/PostgreSQL within Open Solaris and also how to setup a wiki site like Media Wiki on Open Solaris . So, here is a very much related one - setting up a content management site like Drupal on Open Solaris.

Installing / Configuring Web Stack within Open Solaris

If you haven't already, you might want to download and install Open Solaris Developer Express 01/08

To simplify the initialization and configuration steps required for Apache and MySQL within Open Solaris, engineers within Web Stack project like Ludovic Champenois have done an amazing job of creating a a 'initialize' script so as to successfully setup the Web Stack Environment within couple of minutes. Here is a screen snap shot of the Web Stack Initialize 'script' posted in Ludovic Champenois's Blog

Once the Web Stack 'initialize' script completes successfully, you are now ready to start Web Stack Apache 2 and MySQL service as shown here . This is pretty much all is needed to host your web site and start developing and deploying PHP scripts.

However, to use PHP 5.2.4 database shipped within Open Solaris, we will need this below temporary work around to force PHP runtime to use MySQL 5.0 based client library.

        Open a terminal and become root from your Open Solaris box and run the following command (as a temporary work around)

 

root> ln -sf /usr/mysql/5.0/lib/mysql/libmysqlclient.so.15.0.0  /usr/mysql/5.0/lib/mysql/libmysqlclient.so.12


Note: The above mentioned work around is needed only for Open Solaris Developer Express and Open Solaris Developer Preview 2. This issue has been resolved in recent builds of Open Solaris and this temporary work around is not needed if you are using Nevada build 83 or above.

Installing Drupal

Now, you might want to download the latest version of Drupal from their web site and unpack the downloaded tar ball to Apache 2.2 document root location.

These below commands show how to unpack and set up under Apache 2.2's document root.

root> cd /var/apache2/2.2/htdocs

root> /usr/sfw/bin/gtar zxvf  <location of the downloaded tar ball>

Let us go ahead and create a symbolic link of the unzipped drupal tar ball to a valid name

root> ln -sf drupal-6.0 drupal


Configuring Apache for Drupal

Drupal actively uses '.htaccess' file within its installation. However, default apache configuration file, as part of security measure, has disabled the '.htaccess' file support. So, let us go ahead and create a drupal specific configuration.
   
    Note: We will need to create a drupal specific apache configuration file at '/etc/apache2/2.2/conf.d/drupal.conf' so that Apache can load Drupal specific configuration after system restart as well. So, using a command line terminal window become root so as to save the below contents into /etc/apache2/2.2/conf.d/drupal.conf' as shown here.



root> cat > /etc/apache2/2.2/conf.d/drupal.conf

<Directory /var/apache2/2.2/htdocs/drupal>
   AllowOverride All
   RewriteEngine on
   RewriteBase /drupal
</Directory>

<After pasting the above lines into your terminal window, press CTRL-D to save the above contents into drupal.conf>


Configuring PHP for Drupal

Drupal requires PHP configuration to have support to include the current directory in the include path. So, let us edit the default /etc/php5/5.2.4/php.ini and make the following change

    Open a command line terminal window and edit /etc/php5/5.2.4/php.ini file. Note: You will need to either edit this file as 'root' or use 'pfexec' command to ensure that you have the privilege to edit this file

     Now search for 'include_path = ' in this file and edit this line to reflect like below.  Note: This should be the line that doesn't have ';' in the front.

                include_path = "./:/usr/php5/5.2.4/include/php" 

Finally, restart Apache Service from the command line. This ensures that PHP runtime, loaded within Apache, is now aware of the changes that we just did within the 'php.ini' and 'drupal.conf' file.

 

root> /usr/apache2/2.2/bin/apachectl restart

Configuring MySQL for Drupal

Drupal requires a separate database to be created and available for its use. For more information on how to configure this database, please check out the INSTALL.mysql.txt file found under <drupal installation location> (For example, in our case, the file is under /var/apache2/2.2/htdocs/drupal-6.0/INSTALL.mysql.txt). 

Please note that within Open Solaris, MySQL 5 is located under /usr/mysql/5.0/bin/ directory. You will need to be either as root as login as 'mysql' user to successfully create this database.

Configuring Drupal 

Finally, proceed to configuring Drupal and complete the rest of the Drupal configuration by visiting http://localhost/drupal . For more information on this configuration, also refer to 'INSTALL.txt' file found under /var/apache2/2.2/htdocs/drupal directory. 



Technorati Tags: , , ,

This blog copyright 2009 by natarajan