A Guide to SAMP (Solaris Apache MySQL PHP)

If you’re looking for a quick way to get Apache/MySQL/PHP running on Solaris in no time then SAMP is for you. While it is probably not the most secure production ready solution, it is a good way to get started quickly. SAMP is installed off the Solaris Companion CD and getting it running only takes a few minutes. The package is SFWsampc and a good place for information on SAMP is /opt/sfw/READMEs. I’ve broken it down into two parts, let’s get started..

————- Configuring MySQL

First we will start with MySQL. Check the /etc/sfw/mysql/README.solaris.mysql file, this file very simply explains how to get MySQL started:

Initialize the database tables:

# /usr/sfw/bin/mysql_install_db

After you run this command take note of the command it gives you to change the MySQL root user. We are going to run this at the end. Ignore what it says about starting the MySQL daemon, we will use the start/stop script they supply with a manifest later.

Create mysql user and group and change data directory group:

# groupadd mysql
# useradd -g mysql mysql
# chgrp -R mysql /var/mysql
# chmod -R 770 /var/mysql
# installf SUNWmysqlr /var/mysql d 770 root mysql

Copy a mysql daemon configuration to /var/mysql:


# cp /usr/sfw/share/mysql/my-medium.cnf /var/mysql/my.cnf

Grab benr’s mysql manifest so we don’t have to use those horrible init scripts. This manifest is already configured to use the /etc/sfw/mysql/mysql.server start/stop script.

# wget http://cuddletech.com/opensolaris/smf/mysql.xml

Move it to the manifest directory, validate it, and import it.

# mv mysql.xml /var/svc/manifest/network
# svccfg validate /var/svc/manifest/network/mysql.xml
# svccfg import /var/svc/manifest/network/mysql.xml

Start MySQL and change the root password.

# svcadm enable mysql
# /usr/sfw/bin/mysqladmin -u root password ‘new-password’

————- Configuring Apache/PHP

Check the /opt/sfw/READMEs/README.SFWmphp file, this tells us how to get PHP running with Apache:

Run post install script. This script copies over our php.ini, libphp4.so module, and sets up our httpd.conf to be PHP aware:

# /opt/sfw/apache/x_postinstall

Use the default PHP aware Apache configuration:

# mv /etc/httpd.conf-php-example /etc/httpd.conf

Grab an Apache manifest, validate, and import it:

# wget http://hell.jedicoder.net/files/http-apache.xml
# mv http-apache.xml /var/svc/manifest/network
# svccfg validate /var/svc/manifest/network/http-apache.xml
# svccfg import /var/svc/manifest/network/http-apache.xml

Browse to http://localhost/phpinfo.php and you’re done.

I’ve included a txt file here.

One Response to “A Guide to SAMP (Solaris Apache MySQL PHP)”

  1. » Blog Archive » CoolStack (Solaris AMP), It’s all about performance Says:

    […] I’ve written before about the SAMP cluster, which is Apache, MySQL, and PHP bundled together that comes off the Solaris Companion CD. Now there is a whole new package out there called the CoolStack Solaris AMP cluster (sparc only for now) which is all the same thing, but its built optimized with Sun Studio 11 and precompiled into one big package so all you have to do is pkgadd. Building with Sun Studio 11 optimizations provides a huge benefit over standard packages because it can increase performance big time. They also have other separate optimized packages like Perl 5.8.8, Tomcat 5.5.17 and Squid 2.5. So here’s how it works: […]