How to install AMP (Apache, MySQL, PHP) in OpenSolaris 2009.06


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 :

arno@opensolaris:~$ pfexec pkg install SUNWapch22

This will add a new SMF service :

arno@opensolaris:~$ svcs apache22
STATE          STIME       FMRI
disabled    10:49:33    svc:/network/http:apache22
arno@opensolaris:~$

We just need to enable it…

arno@opensolaris:~$ pfexec svcadm enable apache22

… and verify that Apache is now working opening a Web Browser with URL http://localhost :

apache

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 :

arno@opensolaris:~$ grep php /etc/apache2/2.2/httpd.conf
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 :

arno@opensolaris:~$ more /var/apache2/2.2/htdocs/info.php
<?php PHPinfo(); ?>
arno@opensolaris:~$

And it is working ! php

Let’s try now if we can connect to the MySQL server with this simple PHP page :

arno@opensolaris:~$ more /var/apache2/2.2/htdocs/mysql.php
<?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….. :

mysql

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

VN:F [1.9.3_1094]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)
How to install AMP (Apache, MySQL, PHP) in OpenSolaris 2009.06, 10.0 out of 10 based on 1 rating Sphere: Related Content

  • Facebook
  • Twitter
  • Google Buzz
  • Google Bookmarks
  • LinkedIn
  • Share/Bookmark

Related posts:

  1. How to install MySQL 5.1 on OpenSolaris 2009.06 On this post I’m going to describe all the steps...

Related posts brought to you by Yet Another Related Posts Plugin.

, , , , ,

  1. No comments yet.
(will not be published)