Installing AMP on OpenSolaris
By Thierry Manfe on Aug 11, 2008
I needed to install AMP on my OpenSolaris laptop to do some PHP development, and I thought some people would be interested to know how to do this.
Here we go.
AMP is available from the OpenSolaris Web Stack project, which also includes other open source components such as Perl, Ruby, Memcached, Lighthttpd, etc.
The nice thing with OpenSolaris is that - assuming my laptop is connected to the Internet - I can use the Package Manager to automatically download and install AMP on my laptop. I access the Package Manager through the menu System/Administration.
Once the Package Manager is launched, I make sure that the Repository is set to opensolaris.org and I do a search on amp:
The amp and amp-dev packages are now listed in the selection area, the latest being a subset of the first that includes additional development tools that I do not need for my work. So I select the amp package and press the Install/Update button.
Apache is now installed in /usr/apache2, MySQL in /usr/mysql, and PHP in /usr/php5.
The runtime configuration files for Apache are located in /etc/apache2 and the default htdocs is located in /var/apache2/2.2/. The data directory where MySQL actually stores its data is located in /var/mysql/data.
The mysql group and user for MySQL and the webservd group and user for Apache exist by default in OpenSolaris. No need to create them. I can list them using the Users and Groups tool that is accessible from the OpenSolaris menu System/Administration:
No need to run the mysql_install_db utility. MySQL can be directly populated - once started, using the mysql utility:
$ /usr/mysql/bin/mysql --user=root < createSomeData.sql
Finally, I want to register AMP in the Service Management Facility (a.k.a. SMF). By doing so I can manage Apache and MySQL like any OpenSolaris service: if I enable them, they are automatically started during OpenSolaris boot (if I disable them, they won't be). Before starting Apache or MySQL, SMF also checks that the services required by them - e.g. the network - are actually running.
The registration is straightforward. For Apache, I just type:
$ svccfg import /var/svc/manifest/network/http-apache22.xml
$ svcadm enable network/http:apache22
$ svccfg import /var/svc/manifest/application/database/mysql.xml
$ svcadm enable application/database/mysql:version_50
I am done!
The XML files used to register Apache and MySQL are installed automatically when downloading AMP.
Now that the services are registered I can also stop/restart Apache MySQL using the svcadm command:
$ svcadm disable/restart apache22 $ svcadm disable/restart mysql