Enterprise Software

Setting up Web-based groupware applications on Solaris

You can put those spare Solaris CPU cycles to work with a Web-based groupware application. Here, Stew Benedict walks you through the running of Apache and guides you along until you have your groupware app up and running.

Okay, now that you have your Solaris box set up on your home or office network, what do you do with it? Most UNIX-like systems can handle much more than just one person's casual use, so why not put those spare processing cycles to work doing something else? In this Daily Drill Down, I'll show you how to set up a Web-based groupware app on your Solaris box.

What you need
I recently upgraded to a SPARCstation 20, with two 50-MHz processors and 160 MB of RAM. I've sold my SPARCstation 2, with all the add-ons, and I hope its next owner will have fun with the enhancements.

We need three things to get started with this technique: a Web server, a database, and a programming language. Being a Linux user as well, and since I’m under certain financial constraints, I tend toward GNU Public License (GPL) solutions. I'm going with Apache as the Web server, MySQL for the database, and PHP to tie it all together. PHP is a nice scripting language that integrates very well with HTML. You can embed it in HTML pages or write pure PHP source code that creates dynamic HTML on the fly. It has built-in support for several databases, including MySQL.

Out first stop will be Freeware for Solaris, to see what it has in the way of precompiled packages for Solaris. This site offers apache-1.3.6 but no MySQL and no PHP. The MySQL site has a binary for Solaris, version 3.22.32. Hmm, nothing at the PHP site, either. Looks like I'll be learning to build from source on Solaris. I’ll just grab the latest version of PHP, version 4.0.2, as a source tarball.

If I’m going to be building from source, I figure I may as well get the GNU c compiler and go that route because I've worked with it quite a bit under Linux. Back to Freeware for Solaris, where I grab gcc-2.95.2.

Installation of freeware
The packages from Freeware for Solaris install in /usr/local, so you need to make sure you have enough room there or set up another partition for it. You may also want to edit your .profile and /etc/skel/local.profile files to add /usr/local/bin to the default path:

To install a package, as root you issue the command:
pkgadd -d name-of-package

You’ll be told the name of the package and where it will install, then you’ll be prompted as to whether you want to continue. Answer the questions, and in a few minutes the installation should be complete.

One caveat: The pkgadd tool uses space in /var/spool/pkg as a temporary workspace during the install, so if your root partition is low on space, the install of a large package like gcc may fail. A workaround is to create a spool directory on a partition with lots of room—say, /home—and then use the following commands:
pkgadd -s /home/spool -d name-of-package
cd /home/spool
pkgadd -d

So, to continue, I enter the following:
pkgadd -d apache-1.3.6-sol7-sparc-local
pkgadd -d gcc-2.95.2-sol7-sparc-local

Next, I add GNU’s make:
pkgadd -d make-3.78.1-sol7-sparc-local

But I rename it so it does not conflict with Solaris's make:
cd /usr/local/bin
mv make gmake

Also, since I'm going to be working with tarballs, I get GNU’s tar and gzip:
pkgadd -d tar-1.13-sol7-sparc-local
pkgadd -d gzip-1.3-sol7-sparc-local

Since Solaris has its own tar, I rename the GNU tar to gtar:
cd /usr/local/bin
mv tar gtar

And while I'm at it, I throw on bash and pine so I can get command-line completion and a little easier-to-use text editor, pico, rather than vi:
pkgadd -d bash-2.03-sol7-sparc-local
pkgadd -d pine-4.05-sol7-sparc-local

Solaris pkgtool
The Solaris pkgtool, like RPM's under Linux, allows for easy removal of packages, too. To remove a package, you must first find its name, like this:
pkginfo | grep apache
application SMCapache  apache
pkgrm SMCapache

Now back to the project
Looking at /usr/local/doc/apache/README.configure, I see that it says to start up the server with the command:
/usr/local/apache/bin/apachectl start

I do this, and I get:
httpd: cannot determine local host name.
Use the ServerName directive to set it manually.
/usr/local/apache/bin/apachectl start: httpd could not be started

Looks like there’s a problem identifying my hostname, so I take a look at /etc/hosts. The entry is:       curly-joe loghost

I add a full domain name entry, which seems to be required on Solaris for some programs, and Apache starts up fine. So the /etc/hosts file now looks like this:       curly-joe curly-joe.ays.net loghost

I telnet to localhost 80 and get this message:
telnet: Unable to connect to remote host: Connection refused

Hmm, let's take a look at /usr/local/apache/conf/httpd.conf. It appears that this is our problem line:
Port 8080

So I change it to 80, and then I restart Apache with:
/usr/local/apache/bin/apachectl restart

I then point my laptop's browser to curly-joe, and I get the screen shown in Figure A.

Figure A
Here you see the famous “It Worked” screen from the Apache browser.

It worked! The Apache Web server is installed on this Web site!

Finally, we probably want to set up Apache to run as a system daemon that starts/stops at system startup/shutdown:
cp /usr/local/apache/bin/apachectl /etc/init.d/apachectl
ln -s /etc/init.d/apachectl /etc/rc3.d/S99apache
ln -s /etc/init.d/apachectl /etc/rc0.d/K99apache

Okay, one down, two more pieces to go before we can start the project. On to MySQL. This time, it's not a Solaris package for packagetool but a binary tarball. Since I now have gnu-tar, I'll use it to tar and gunzip all in one step:
cp mysql-3.22.32-sun-solaris2.7-sparc.tar.gz /usr/local
cd /usr/local
/usr/local/bin/gtar -xzf mysql-3.22.32-sun-solaris2.7-sparc.tar.gz
ln -s mysql-3.22.32-sun-solaris2.7-sparc.tar.gz mysql
rm mysql-3.22.32-sun-solaris2.7-sparc.tar.gz
cd mysql

This script tells us where to set up the database daemon to run at system boot and also suggests that we set up an admin password with the command:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'

We'll use the highly imaginative dbadmin as our administrative password. Now to start the server, we run the following:
/usr/local/mysql/bin/safe_mysqld &

To see if it works, we can run this:
/usr/local/mysql/bin/mysql -p mysql

We should see the following prompt:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with –A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 3.22.32

Type 'help' for help.

The MySQL command show tables will list the tables in our system, which at this point are just the base system tables:
mysql> show tables;

| Tables in mysql |
| columns_priv |
| db    |
| func   |
| host   |
| tables_priv  |
| user   |
6 rows in set (0.01 sec)

Good, the database daemon is working. Let’s get out of the mysql prompt with:
mysql> quit;

We'll want the mysql daemon to run at system start, and the distribution provides us with a template:
cd /usr/local/mysql
cp support-files/mysql.server /etc/init.d/mysql

You'll need to edit the following line:

Change mysql.pid to hostname.pid, where hostname is your hostname. Now enter the commands that set mysql to run at system start:
chmod +x /etc/init.d/mysql
ln -s /etc/init.d/mysql /etc/rc3.d/S99mysql
ln -s /etc/init.d/mysql /etc/rc0.d/K99mysql

Moving on to PHP
We'll set MySQL aside for the moment and move on to PHP. Again, we'll need to untar the tarball and take a look at the documentation. Put the tarball in an appropriate place, say /usr/local/src, and untar it:
mkdir /usr/local/src
cp php-4.0.2.tar.gz /usr/local/src
cd /usr/local/src
gtar -xzf php-4.0.2.tar.gz
cd php-4.0.2

INSTALL seems like a likely file, and looking at it, it appears that building PHP as a DSO (Dynamic Shared Object) for Apache would be a good way to go. To check to see whether our Apache install has the appropriate support, we need to run:
/usr/local/apache/bin/httpd -l

to list the modules that are compiled into Apache. We need mod_so.c to compile PHP as a DSO. It looks like we have a problem, however, because mod_so.c is not in the list. Perhaps we’d better build Apache from source, too! Now we need to remove our apache package and build up from source:
/usr/local/apache/bin/apachectl stop
pkginfo | grep apache
application SMCapache   apache
pkgrm SMCapache

We'll hop over to the Apache site, get a source tarball of Apache, and untar it into /usr/src as well:
cp apache-1.3.6.tar.gz /usr/src
cd /usr/src
gtar -xzf apache-1.3.6.tar.gz
cd apache_1.3.6

Again, let's take a look at the documentation. INSTALL appears to be a likely file, and I note that mod_so is not enabled by default. Digging through this file a bit, I decide that the thing to do is this:
./configure —prefix=/usr/local/apache —enable-module=so

I get some errors. Some essential programs for compiling are not in my search path. I'm going to resolve this by adding some symbolic links:
cd /usr/local/bin
ln -s /usr/ccs/bin/make make
ln -s /usr/ccs/bin/ar ar

After doing this, the configure process succeeds, and I'm ready to start the build:
cd /usr/src/apache_1.3.6
make install

This all goes well. Let's restart the server and take a look at it from my laptop's browser. Yep, we're running. We'll also check the modules to see if we have what we need for PHP:
/usr/local/apache/bin/httpd –l
Compiled-in modules:

Good! Back to PHP. We want MySQL support in PHP, too, so we need to build that in, as shown here:
cd /usr/local/src/php-4.0.2
./configure —with-mysql=/usr/local/mysql \

Uh-oh, more problems. No lex, and apxs is a Perl script—and we don't have Perl. We also need a copy of bison. We can resolve the lex issue with another symbolic link:
cd /usr/local/bin
ln -s /usr/ccs/bin/lex lex

For Perl and bison, it’s back to the Freeware for Solaris site. Now we run:
pkgadd -d perl-5.005-sol7-sparc-local
pkgadd -d bison-1.28-sol7-sparc-local

We go back to finish the configuration, and we can build PHP:
make install

Now we restart Apache and watch for any error messages:
/usr/local/apache/bin/apachectl restart

To test whether PHP is working, create the file php-info.php in /usr/local/apache/htdocs with the following line:
<? phpinfo(); ?>

Point your browser to http://hostname/php-info.php, where hostname is your host's name, and you should see a whole page of information describing your server, your Apache server, and your PHP installation. If all you see is the source code as shown above, take a look at /usr/local/apache/conf/httpd.conf and make sure the following lines are in place and as shown. I found I had to edit a couple of lines, uncommenting and changing the application type from php3 to php:
LoadModule php4_module  libexec/libphp4.so
# http://www.php.net) will typically use:
AddType application/x-httpd-php .php3 .php
AddType application/x-httpd-php-source .phps

Figure B shows the screen at this point.

Figure B
This screen shows a good deal of information about your system.

Whew! Still with me? Now the entire infrastructure is in place to install our groupware app. This may have seemed like a major hassle, but with these three tools—Apache, MySQL, and PHP—you've just put in place everything you’ll need to build a multitude of interesting Web-based applications.

On to the groupware apps
For the groupware app, I've selected phpGroupWare. The phpGroupWare application is becoming a top intranet/groupware tool and application framework. This application is written in the PHP programming language, which makes it ideal for developers who write add-on apps.

Unlike the other source code we worked with, PHP apps are scripts and need no compiling. Take the downloaded tarball and untar it in your Web server's public area:
cp phpGroupWare-09072000.tar.gz /usr/local/apache/htdocs
cd /usr/local/apache/htdocs
gtar -xzf phpGroupWare-09072000.tar.gz
rm phpGroupWare-09072000.tar.gz
cd phpgroupware
cp header.inc.php.sample header.inc.php

Now you need to edit this file to reflect your setup. Use whatever editor you like—vi, pico, etc. In particular, look for these lines:
$phpgw_info["server"]["include_root"] = "/path/to/phpgroupware/inc";

For our setup, this would be:
$phpgw_info["server"]["include_root"] = \

Then move to the inc directory and copy or modify:
cp globalconfig.inc.php.sample globalconfig.inc.php

There are a number of settings in this file. Some of the more important ones are listed below:
$phpgw_info["server"]["server_root"] = \

/* This is the temp directory where file uploads will go. */
/* For security reasons, do a chown nobody.nobody and chmod 700 */
/* or what ever your webserver is running as. */

$phpgw_info["server"]["temp_dir"] = "/usr/local/apache/tmp";|

$phpgw_info["server"]["files_dir"] = \
$phpgw_info["server"]["encryptkey"] = "alpha123";

/* These are the settings environment and url */
$phpgw_info["server"]["site_title"] = "phpGroupWare";
/* name of the server phpGroupWare runs on */
$phpgw_info["server"]["hostname"] = "curly-joe";

curly-joe is my hostname—yours will vary./* Path (URL) that phpGroupWare is install in. */
$phpgw_info["server"]["webserver_url"]  = "/phpgroupware";

/* These are the settings for the database system */
$phpgw_info["server"]["db_host"] = "localhost";   
$phpgw_info["server"]["db_name"] = "phpgroupware";
$phpgw_info["server"]["db_user"] = "phpgwuser";
$phpgw_info["server"]["db_pass"] = "phpgwpasswd";

$phpgw_info["server"]["db_type"] = "mysql"

$phpgw_info["server"]["auth_type"] = "sql";

There are also options for LDAP, but we'll leave that alone for now.// This is if you would like to allow the sessionid to be
// set as a cookie.
// options are True or False
$phpgw_info["server"]["usecookies"] = False;

/* These are the settings for the email system */
$phpgw_info["server"]["mail_server"] = "localhost";
$phpgw_info["server"]["mail_server_type"]  = "POP3"; //imap or POP3
$phpgw_info["server"]["mail_suffix"] = "ays.net";
/* standard is for IMAP servers that require only
the user name. */
/* vmailmgr is for IMAP servers that require this format user@doman.com */
/* If unsure use the standard format */
$phpgw_info["server"]["mail_login_type"] = "standard";

/* These are the settings for smtp server */
$phpgw_info["server"]["smtp_server"] = "localhost";
$phpgw_info["server"]["smtp_port"] = "25";

Using POP3
We're going to use POP3 for e-mail. To my surprise, I didn't find any POP3 server installed or on my CDs. Taking a quick Google search, it looks like the common approach is to set up qpopper, from Qualcomm:
cp qpopper3.1.tar.gz /usr/src
cd /usr/src
gtar -xzf qpopper3.1.tar.gz
cd qpopper3.1
make install

To install qpopper (I chose this directory, where some of my other add-on services reside), issue the following:
cp popper/popper /usr/local/sbin/

Then, edit /etc/inetd.conf, adding this line:
POP3 stream tcp nowait root /usr/local/sbin/popper qpopper -s

Next, restart inetd:
/etc/rc2.d/S72inetsvc stop
/etc/rc2.d/S72inetsvc start

To test it, try the following:
telnet localhost 110
Connected to localhost.
Escape character is '^]'.
+OK Qpop (version 3.1) at curly-joe starting.
USER stew
+OK Password required for stew.
PASS mypassword
+OK stew has 1 visible message (0 hidden) in 3219 octets.
+OK Pop server at curly-joe signing off.
Connection closed by foreign host.

Back to phpGroupWare
Okay, back to phpGroupWare. We were editing globalconfig.inc.php. The next few lines deal with a news (NNTP) server. I'm not going to get into that topic in this Daily Drill Down, but keep in mind that the software offers this capability. There is also a line for the FTP server, set at localhost, which should be fine. If you or another user have switched over to bash as a shell, be sure to edit /etc/shells and add the line:

Otherwise, the FTP daemon will deny you access.

This finishes the configuration from the phpGroupWare end, but there’s a little bit of database administration we need to do to get the database created and set up. We must add the user phpgwuser, with the password phpgwpasswd, as a valid user in MySQL:
/usr/local/mysql/bin/mysql –p
Enter password: dbadmin
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3159 to server version: 3.22.32

Type 'help' for help.

mysql> insert into user values
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y') ;
mysql> insert into user values
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y') ;

This gives full database rights to the user phpgwuser from any host. The user can create, destroy, and modify databases. This user is required to enter a password to access the database. Depending on your application, you may not want to give the user quite this much power, but we'll leave it like this for now. We now must reload to make the changes take effect:
/usr/local/mysql/bin/mysqladmin -p reload

Now, create the phpgroupware database:
/usr/local/mysql/bin/mysqladmin -p create phpgroupware
cd /usr/local/apache/htdocs/phpgroupware/doc
/usr/local/mysql/bin/mysql -u phpgwuser -p phpgroupware < create_tables.mysql

The authors also suggest enabling a couple of Perl scripts to kill off sessions where people forgot to log out. Another script cleans up old temp files. Both require the DBI.pm Perl module for database access, which did not come in our Perl package. I won’t get into installing that in this Daily Drill Down—I think you've had enough. You can disable cron in the phpgroupware admin page, and sessions will be cleaned up on login/logout.

One last little change we need to make is to tell Apache to recognize index.php, as well as index.html, as the default page when accessing a directory. Edit /usr/local/apache/conf/httpd.conf and change the line:
DirectoryIndex index.html

to read
DirectoryIndex index.html index.php

Then, run:
/usr/local/apache/bin/apachectl restart

Now that you're up and running, point your browser to:

where hostname is your box's hostname. The documentation for phpGroupWare is included for your enjoyment.

To get into the application itself, point your browser to:
Username: demo
Password: 1234

You will be prompted to change your password. Go to the preferences area (the icon with the little gears) and set a new password.

At first, it looks like nothing is there. You can go to the admin area and enable or disable apps. I turned off nntp, since we did not set it up. Poke around and try the applications. The icons in the upper-right corner control access to everything. Open the address book and add yourself in.

You'll probably want to add some more users as well. You can specify which applications are available to each user. I added myself (stew) and hit a minor problem in creating the user directory. To avoid this problem, do the following:
cd /usr/local/apache/htocs/phpgroupware/files
chmod 707 users

Read your e-mail; upload and download files. Try the calendar app and to-do list, but most of all, have fun! Remember, the software is still beta, so you may hit an occasional bug. I know I did. If you want to follow the progress of phpGroupWare, there are some mail lists you can sign up for. There’s quite a bit of interest in this app in the open source community, so I'm sure you’ll see it grow in stability and capability. It's no Lotus Notes, but I think it does enough to coordinate a small group of people and their activities. Best of all, it's free!

We've covered a lot of ground in this Daily Drill Down, and we added a lot of new features to our Solaris box. Now we have a Web server, a database server, POP e-mail services, a nice Web-development language in PHP, plus Perl and Gnu's gcc for other development projects. Java also comes standard with Solaris, so we can experiment a bit with applets served up by our new Apache server.

Now that you've seen what you can do with MySQL and PHP, you may come up with your own ideas. Or you can browse the Web for other applications to put on your Web server.
The authors and editors have taken care in preparation of the content contained herein but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.

Editor's Picks

Free Newsletters, In your Inbox