Matt Ingenthron's Stream of Consciousness

All | Automotive Enthusiasm | General | Java | Music | Net Culture | OpenSolaris | PhonePics
« Previous day (Feb 4, 2008) | Main | Next day (Feb 6, 2008) »
20080205 Tuesday February 05, 2008

OpenSolaris Web Stack: Setting Services on Apache

Solaris Express Developer Edition 01/08 (a.k.a. SXDE 01/08) has been released! One of the features of the new release is the integration of much of the work from the Web Stack project

So you're probably wondering, what is different or better about the Web Stack (including, but not limited to Apache, MySQL and PHP) integrated into OpenSolaris. Well, the code is the same stuff available at the various project sites. This, of course, is by design. Though it is Open Source of one license or another, there's no real value in deviating from what the upstream communities have released.

Still, there are some interesting places OpenSolaris can add value. OpenSolaris has things like DTrace, SMF, lots of security features, etc.

Jyri has already written about how easy it is to run PHP on OpenSolaris, including SXDE 01/08. Assume for a moment though that what you want is a 64-bit Apache with mod_proxy. Well, how do you set that up?

The team has done a great job of integrating the web stack components. One example is using svccfg to make changes to how a service is set up to run. So, let's look at modifying the service configuration of Apache. First, we start it:

# svcs http:apache22
STATE          STIME    FMRI
disabled       19:35:01 svc:/network/http:apache22
# svcadm enable http:apache22

The process is up and running, but is it 32 or 64 bit? Hmmm. Let's find out. First we need to know what the process is. We could grep for http or something like that, but there's a better way to see which processes are associated with a service:

# svcs -p http:apache22
STATE          STIME    FMRI
online         19:54:30 svc:/network/http:apache22
               19:54:30     1154 httpd
               19:54:31     1155 httpd

Okay, now we see the processes. How do I find out if it's 32 or 64 bit? pargs(1) can tell tell us what the binary is, then we can look at the file:

# pargs -x 1154
1154:   /usr/apache2/2.2/bin/httpd -k start
AT_SUN_PLATFORM 0x08047fda i86pc
AT_SUN_EXECNAME 0x08047fe0 /usr/apache2/2.2/bin/httpd
AT_PHDR         0x08050034 
AT_PHENT        0x00000020 
AT_PHNUM        0x00000007 
AT_ENTRY        0x0806cc10 
AT_SUN_LDDATA   0xfeffa000 
AT_BASE         0xfefc0000 
AT_FLAGS        0x00000000 
AT_PAGESZ       0x00001000 
AT_SUN_AUXFLAGS 0x00000002 
AT_SUN_HWCAP    0x0043dc6f SSSE3 | AHF | CX16 | MON | SSE3 | SSE2 | SSE | FXSR |
 MMX | CMOV | SEP | CX8 | TSC | FPU
# file /usr/apache2/2.2/bin/httpd
/usr/apache2/2.2/bin/httpd:     ELF 32-bit LSB executable 80386 Version 1 [FPU], dynamically linked, stripped

Okay, it's just 32-bit. Since it's so nicely integrated, perhaps there is a service property to switch it. Let's see what service properties we have to mess with:

# svcprop http:apache22
httpd/enable_64bit boolean false
httpd/server_type astring prefork
httpd/stability astring Evolving
httpd/startup_options astring ""
httpd/value_authorization astring solaris.smf.value.http/apache22
network/entities fmri svc:/milestone/network:default
network/grouping astring require_all
network/restart_on astring error
network/type astring service
filesystem-local/entities fmri svc:/system/filesystem/local:default
filesystem-local/grouping astring require_all
filesystem-local/restart_on astring none
filesystem-local/type astring service
autofs/entities fmri svc:/system/filesystem/autofs:default
autofs/grouping astring optional_all
autofs/restart_on astring error
autofs/type astring service
startd/ignore_error astring core,signal
general/action_authorization astring solaris.smf.manage.http/apache22
general/enabled boolean false
general/value_authorization astring solaris.smf.value.http/apache22
general/entity_stability astring Evolving
start/exec astring /lib/svc/method/http-apache22\ start
start/timeout_seconds count 60
start/type astring method
stop/exec astring /lib/svc/method/http-apache22\ stop
stop/timeout_seconds count 60
stop/type astring method
refresh/exec astring /lib/svc/method/http-apache22\ refresh
refresh/timeout_seconds count 60
refresh/type astring method
tm_common_name/C ustring Apache\ 2.2\ HTTP\ server
tm_man_httpd/manpath astring /usr/apache2/2.2/man
tm_man_httpd/section astring 8
tm_man_httpd/title astring httpd
tm_doc_apache_org/name astring apache.org
tm_doc_apache_org/uri astring http://httpd.apache.org
restarter/logfile astring /var/svc/log/network-http:apache22.log
restarter/contract count 95
restarter/start_pid count 1139
restarter/start_method_timestamp time 1202270070.318463000
restarter/start_method_waitstatus integer 0
restarter/auxiliary_state astring none
restarter/next_state astring none
restarter/state astring online
restarter/state_timestamp time 1202270070.320630000

There's a lot of stuff because of the various dependencies and other variables that SMF needs for some of the other magic. That one labeled "httpd/enable_64bit" looks like the one we need though. Let's change it using svccfg:

# svccfg -s http:apache22
svc:/network/http:apache22> listprop httpd/*
httpd/server_type          astring  prefork
httpd/stability            astring  Evolving
httpd/startup_options      astring  
httpd/value_authorization  astring  solaris.smf.value.http/apache22
httpd/enable_64bit         boolean  false
svc:/network/http:apache22> setprop httpd/enable_64bit=true
svc:/network/http:apache22> listprop httpd/*
httpd/server_type          astring  prefork
httpd/stability            astring  Evolving
httpd/startup_options      astring  
httpd/value_authorization  astring  solaris.smf.value.http/apache22
httpd/enable_64bit         boolean  true
svc:/network/http:apache22> exit

Now, when we change these service properties, we need to apply the changes by refreshing the service and then restarting it. Then we can see if we got the desired effect:

# svcadm refresh http:apache22
# svcadm restart http:apache22
# svcs -p http:apache22
STATE          STIME    FMRI
online         20:44:40 svc:/network/http:apache22
               20:44:40     1683 httpd
               20:44:41     1684 httpd
               20:44:41     1685 httpd
               20:44:41     1686 httpd
               20:44:41     1687 httpd
               20:44:41     1688 httpd
               20:44:41     1689 httpd
# pargs -x 1683
1683:   /usr/apache2/2.2/bin/amd64/httpd -D 64bit -k start
AT_SUN_PLATFORM 0xfffffd7fffdfffcf i86pc
AT_SUN_EXECNAME 0xfffffd7fffdfffd5 /usr/apache2/2.2/bin/amd64/httpd
AT_PHDR         0x0000000000400040 
AT_PHENT        0x0000000000000038 
AT_PHNUM        0x0000000000000008 
AT_ENTRY        0x000000000042d450 
AT_SUN_LDDATA   0xfffffd7fff3fa000 
AT_BASE         0xfffffd7fff394000 
AT_FLAGS        0x0000000000000000 
AT_PAGESZ       0x0000000000001000 
AT_SUN_AUXFLAGS 0x0000000000000002 
AT_SUN_HWCAP    0x000000000041dc77 SSSE3 | CX16 | MON | SSE3 | SSE2 | SSE | FXSR
 | MMX | CMOV | AMD_SYSC | CX8 | TSC | FPU
# file /usr/apache2/2.2/bin/amd64/httpd
/usr/apache2/2.2/bin/amd64/httpd:       ELF 64-bit LSB executable AMD64 Version 1 [SSE FXSR CMOV FPU], dynamically linked, stripped

Looks good. Apache, as you may know, has both prefork and worker models. I happened to spot in there that there is a property for that. Since all of the modules I'm using are thread safe, I think I'll turn it to worker...

# svccfg -s http:apache22
svc:/network/http:apache22> listprop httpd/*
httpd/server_type          astring  prefork
httpd/stability            astring  Evolving
httpd/startup_options      astring  
httpd/value_authorization  astring  solaris.smf.value.http/apache22
httpd/enable_64bit         boolean  true
svc:/network/http:apache22> setprop httpd/server_type=worker
svc:/network/http:apache22> exit
# svcadm refresh http:apache22
# svcadm restart http
svcadm: Pattern 'http' matches multiple instances:
        svc:/network/http:squid
        svc:/network/http:apache22
# svcadm restart http:apache22

Very nice, now I can go edit my httpd.conf and enable proxying!

I went from 32 to 64 bit, and changed MPMs all without having to go rebuild Apache, edit rc files, etc. Plus, the current configuration is always easy to find with svcprop.

Once other projects, like Visual Panels, come along we should then see a nice GUI way of understanding and editing our services. The other nice advantage is if I have a large number of systems I want to configure the service on in a similar way, SMF makes it simple to replicate that service configuration to other systems. Alternatively, I could just jumpstart them and apply a service config.

You may be asking, but what about that stuff in httpd.conf? Well, remember our goal here in the Web Stack project is to integrate nicely with those upstream projects. Admins know how to edit their httpd.conf files, and it wouldn't add much value to start making that many modifications to the Apache HTTP Server. The philosophy is integrate with the features in OpenSolaris, but stay true to the community that produced the code.

Download and play with SXDE 01/08 or one of the Project Indiana builds after it synchs up with the latest code, or join us over in the OpenSolaris Web Stack project.

( Feb 05 2008, 11:42:39 PM PST ) Permalink Comments [3]

Calendar

RSS Feeds

Search

Links

Navigation

Referers