In this new post I’m going to explain how to install Apache Web Server 2.2 with MySQL5.1 and PHP5.2 on last version 2009.06 of OpenSolaris.
In fact there is a special package for that : amp. We can install such package and nothing more, but I prefer to install each aplication separately. Look at this link if you want to use the amp package.
1- Apache 2.2
To install the Apache Web Server just install the SUNWapch22 package :
This will add a new SMF service :
STATE STIME FMRI
disabled 10:49:33 svc:/network/http:apache22
arno@opensolaris:~$
We just need to enable it…
… and verify that Apache is now working opening a Web Browser with URL http://localhost :

2- MySQL 5.1
To set up MySQL, have a look to my previous post : How to install MySQL 5.1 on OpenSolaris 2009.06
3- PHP 5.2
We need to install the following packages :
- SUNWphp52 : the core of the PHP Server 5.2,
- SUNWapch22m-php52 : the PHP 5.2 module for Apache Web Server V2.2,
- SUNWphp52-mysql : the PHP 5.2 module for MySQL.
After installing those packages with pkg install, we need to add the use of the PHP module in the Apache configuration file httpd.conf by adding this line :
Include /etc/apache2/2.2/conf.d/php5.2.conf
arno@opensolaris:~$
Let’s try now that PHP is working by creating the phpinfo page in the /var/apache2/2.2/htdocs directory :
<?php PHPinfo(); ?>
arno@opensolaris:~$
And it is working ! 
Let’s try now if we can connect to the MySQL server with this simple PHP page :
<?php
$username=”root”;
$password=”root”;
$database=”mysql”;
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( “Unable to select database”);
$query = ‘SELECT user,host FROM user’;
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
echo “User: “.$row['user'].” – Host: “.$row['host'];
}
?>
arno@opensolaris:~$
And yes we can….. :

And you can start now to develop your web aplications !
There is an interesting Sun/MySQL course for that :
Developing Dynamic Web Applications with MySQL and PHP (SQL-4405)
Arnaud
Sphere: Related ContentNo related posts.
Related posts brought to you by Yet Another Related Posts Plugin.

Core Networks homepage
Oracle University
#1 by Juan on February 16, 2011 - 21:31
Thank you.
I just started playing with OpenSolaris 2009.6, and although I had already installed amp and web stack, I was still not able to run PHP.
Thanks to your guide, I was able to finish some of the steps I was missing.
Thanks again!