EASIER, FASTER, SAFER...for Beginners and Experts on Sun ZFS, Java, Solaris, VirtualBox for ISV and Partners

Hi,

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

For MySQL:

$ 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

Comments:

Please note that the part about having to manually register (svccfg import) Apache and MySQL with smf is a bug in IPS. As soon as that gets fixed, it will happen automatically when installing the packages.

Posted by Jyri Virkki on August 12, 2008 at 04:13 PM CEST #

thanks Thierry!

do you know where the root web directory live?
i setup amp locally on my laptop and it works great using your instructions. But i don't know the directory to put all of my php files and run them. i know in Ubuntu that the directory live in /var/www

thanks,
tom

Posted by tom on December 17, 2008 at 03:04 AM CET #

I had the same problem as tom. The file:
/etc/apache2/2.2/httpd.conf
defines DocumentRoot as:
"/var/apache2/2.2/htdocs"

Posted by Jaco Vosloo on July 10, 2009 at 09:07 PM CEST #

Thanks a lot! I was looking for some tips about AMP. It's really useful!
Cheers.

Posted by Yigit Ozdamar on July 31, 2009 at 09:28 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed