Tuesday Feb 09, 2010

Check out latest development build of Web Stack

If you are using Cool Stack or Web Stack for your AMP (Apache, PHP and MySQL) stack needs on either Solaris 10 or Red Hat Enterprise Linux, then you might want to check out the latest development build update of Web Stack. This build delivers PHP 5.2.12 , Apache 2.2.14 etc. 

For more information on how to update to this build, please refer to my earlier blog on this topic. If you run into any issues, please use our forum for any trouble shooting tips.

Thursday Jul 30, 2009

Installing AMP stack within GlassFish Web Stack 1.5...

Now that  Sun GlassFish Web Stack 1.5 release is done, let me walk you through the steps involved in setting up your AMP (Apache 2.2, MySQL 5.1 and PHP 5.2) stack working together. One of the other cool features of Sun GlassFish Web Stack 1.5 release , besides Web Stack Enterprise Manager, is its ability to support

  • installation via native packages (SVR4 Packages for Solaris 10 and RPM for RHEL5.2). This is typically the preferred way in large enterprises. This installation will require root privileges and provides integration with Solaris 10 SMF etc.
  • installation via IPS (Image Packaging System). This installation is typically preferred by developers and in enterprises where you have access to internet to download and install binaries from internet on your production machine !. This installation does not require 'root' privileges and all files (including web server document root and MySQL data directory) is configured under your installation directory. So, you might find it very intuitive to install, use , develop and even take it with you.

 Installing Web Stack 1.5 as a native package / rpm

  • Visit our Sun Web Stack 1.5 download page and 'click on Native components (does not include java component)' link to download our native packages. If you wonder, what is "java components" in this above link . Well, we refer "java components" as components like Tomcat, Hudson, GlassFish 2.1. Since, this blog is about setting up a PHP/MySQL based web site, you can reduce your carbon foot print by avoiding those extra bulky downloads..
  • unzip the downloaded tar ball and install by running the following command (you will need root privileges)

sriramn@sriramn:~$ sudo ./install amp

Now, if you are running on Solaris 10 and don't want to install on all local zones, then you could even do some thing like

sriramn@sriramn:~#  ./install -XG amp

For more information with related to this installation, please check out our Installation Guide. Once you have completed this installation, you might want to refer to our Getting Started Guide as to how to survive with our stack. This guide should help you with basic information like where to find our configuration files, how to start/stop servers etc.

Installing Web Stack 1.5 as IPS (Update Center)

IPS (Image Packaging System) is an open source technology built on Python and is the core underlying framework on how packages are delivered within OpenSolaris. This work was initially done for OpenSolaris.  Now, as with any open source projects, another open source project - Update Center has successfully ported this work for platforms like Solaris 10 and Linux.

Now, GlassFish Web Stack 1.5 release uses this Update Center open source project to deliver a minimal Python runtime and Update Center technology as part of initial download. Then you will need to fire up the Update tool GUI to download and install components that interests you.

Unlike OS native packages, Update Center technology does not verify or warn if you do not have installed any underlying dependent libraries that Web Stack 1.5 stack requires. So, we strongly recommend you to visit our System Package dependency link to ensure that you have these packages installed on your system.

Here is a quick walk through on how to get your AMP stack up and running with this: 

  • Visit our Sun Web Stack 1.5 download web page and download 'click on IPS based Packaging' link
  • Now, you will need to unzip the downloaded tar ball and fire up the update tool GUI. You will need to download some thing like

sriramn@sriramn:~$ unzip  webstack-image-1.5-b09-redhat-i586.zip

sriramn@sriramn:~$ cd webstack1.5

sriramn@sriramn:~/webstack1.5$ ./bin/updatetool 

(Note: You will need GUI configured or DISPLAY set properly to successfully run the above command.)

(Note: If you do not have GUI/X11 configured on your Solaris / Linux machine, then you can do some thing like below to install

from command line.)

sriramn@sriramn:~/webstack$ ./pkg/bin/pkg list  -> to list all the component available

Now, firing up the GUI, will welcome you with a nice GUI like this below

Now, you will need to click on 'Available Add-ons' to see all the Web Stack components listed (as shown below).

Note: If your company requires HTTP Proxy to be configured to access the internet, you will need to click on 'Preferences' windows and appropriately configure proxy information before proceeding any further.

Now, select Apache HTTP Server, PHP , PHP MySQL Connector, PHP APC and MySQL Community Server(5.1.30 version) components from this above list  and click on Install . You should see a confirmation window like below and if you see all the components that you need, click on 'Install' again. 

If you do not have GUI / X11 configured on your Solaris / Linux machine, then you could very well do some thing like below to install AMP stack from command line. 

sriramn@sriramn:~/webstack1.5$ ./pkg/bin/pkg list -a  -> to list all the component available

sriramn@sriramn:~/webstack1.5$ ./pkg/bin/pkg install sun-apache22 sun-php52 sun-php52-apc sun-mysql51 sun-php52-mysql -> to install and configure Apache, PHP and MySQL within your home directory.

sriramn@sriramn:~/webstack1.5$ ./bin/setup-webstack

At the end of this installation, you should have a fully configured Apache , PHP and MySQL runtime within your home directory/webstack1.5 directory.

You can now start the Apache and MySQL server by running the following command from your command line:

  sriramn@sriramn:~/webstack1.5$ ./bin/sun-apache22 start -> by default Apache should now run at port 10080

  sriramn@sriramn:~/webstack1.5$ ./bin/sun-mysql51 start -> by default MySQL server should now run at port 13306

Now, you should be able to install applications like Joomla, Drupal, MediaWiki by simply unzipping these applications under Apache document root (~/webstack1.5/var/apache2/2.2/htdocs) directory

 For example, installing applications like Joomla / Drupal or MediaWiki should simply involve going to Apache document root and unzipping the application and following through the installation process within your browser (http://localhost:10080/joomla etc)

  sriramn@sriramn:~/webstack1.5$ cd var/apache2/2.2/htdocs

  sriramn@sriramn:~/webstack1.5/var/apache2/2.2/htdocs$tar zxvf ~/tmp/joomla\*.gz

Most of the open source components are designed to be built and installed on the same machine. So, building a stack and making it run on different machine takes a bit of work but getting the same stack to be installed at multiple locations takes lots and lots of work. Well, we are doing this release for the first time and would love to hear your feedback and this took us lots and lots of effort to get it right.

You will find all our start/stop scripts under ~/webstack1.5/bin/sun-\* (or wherever you installed /bin). Similarly, you will find all the configuration files under ~/webstack1.5/etc/\* (or wherever you installed /etc). 

Hope you like what you see . If you run into issues, we encourage you to write back to us at our Forum.

Wednesday Jul 29, 2009

GlassFish Web Stack 1.5 is available now ..

If you didn't know already, GlassFish Web Stack is an open source project within OpenSolaris and offers production support (also available as free download) for open source web tier components like Apache Web Server, PHPMySQL, Tomcat, Hudson etc on Solaris 10 Update 5 (or above) and on RedHat Enterprise Linux 5.2 (or above). 

GlassFish Web Stack 1.5 , the latest update in this series, is available as of today and includes updated version components along with Enterprise Administration / Monitoring capability. Please refer to our Getting Started Guide for more information on how to get  your site quickly up and running using GlassFish Web Stack .

Some of the highlights of this release are :

You can try out GlassFish Web Stack 1.5 from here. GlassFish Web Stack 1.5 component runtime  is available as a free download for Solaris and Redhat Enterprise Linux and we hope you will choose Sun for your production support requirements.

Thursday Jul 16, 2009

Running PHP as CGI in OpenSolaris 2009.06

As part of Web Stack project, we deliver an integrated AMP stack within OpenSolaris where Apache 2.2.x, PHP 5.2.x and MySQL 5.1 is integrated together to work seamlessly. In this environment,
  • Apache is configured to run in pre-fork model
  • PHP is loaded as a module (mod_php5) within Apache (pre-fork) MPM.
  • Apache (worker) MPM model is not supported with PHP.

This particular scenario will work great for majority of users.

However, if you are one of those minority folks, who is interested in running PHP as CGI say with Apache 2.2 (worker) MPM, then here is what you need to do :

Configure Apache Server to start in worker (MPM) mode. This should provide you with better performance. This is how you can run Apache 2.2 in worker mode within OpenSolaris.

sriramn@opensolaris:~$ svcadm disable -s http:apache22

sriramn@opensolaris:~$ svccfg -s setprop http:apache22 httpd/server_type=worker

sriramn@opensolaris:~$ svcadm refresh http:apache22

sriramn@opensolaris:~$ svcadm enable -s http:apache22

Af course, to actually see any performance improvement, you will need to copy mpm.conf from samples directory(/etc/apache2/2.2/samples-conf.d/mpm.conf) to  /etc/apache2/2.2/conf.d/mpm.conf  and then tune this file accordingly.

Now that we have got Apache 2.2 worker MPM configured, if you try to run any PHP script within your document root directory, you will notice that they don't work. This is because, PHP module is not loaded if Apache is configured to run in worker MPM. (Remember, PHP modules and different extensions are not completely thread safe.) .

Now to get PHP scripts working again, here is what I did :

Copy PHP CGI script to the Apache's cgi-bin directory

sriramn@opensolaris:~$ pfexec cp /usr/php/bin/php-cgi  /var/apache2/2.2/cgi-bin/

sriramn@opensolaris:~$ pfexec chown webservd:webservd /var/apache2/2.2/cgi-bin/php-cgi

Now, you might want to create a file under /etc/apache2/2.2/conf.d/php-cgi.conf with the below content

#Create a alias for every location where you want to keep your PHP script.
ScriptAlias /contents/ "/var/www/contents/"
ScriptAlias /drupal/  "/var/www/drupal/"
AddHandler  php-cgi  .php
Action          php-cgi  /cgi-bin/php-cgi
<Directory /var/www/contents/>    
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
<Directory /var/www/drupal/>
Options Indexes FollowSymLinks
Order allow,deny
Allow from all

(updated above content to reflect the feedback received from Jeff's comments to my earlier blog. Thanks a lot, Jeff.)

Here's a better example:

# Create the Alias for every php application that you want to deploy

Alias /phpapp /var/www/contents/

Alias /drupal /var/www/drupal/

ScriptAlias /php-cgi /usr/php/5.2/bin/php-cgi

<‚ĀěDirectory /usr/php/5.2/bin/>
 Order allow,deny
 Allow from all

<Location "/phpapp">
 Order allow,deny
 Allow from all
 AddHandler php-cgi .php
 Action php-cgi /php-cgi

<Location "/drupal">
 Order allow,deny
 Allow from all
 AddHandler php-cgi .php
 Action php-cgi /php-cgi

Finally, you will need to restart the server to allow this above configuration to be loaded. Now, server should be ready to process any php files as 'cgi' script under /var/www/contents directory

Hope you find this useful.


Sharing what little I know


« July 2016