Saturday, April 22, 2017

Sessions & Process Groups

In the very start of the endeavor to the daemons' underground world it's inevitable to be acquainted with a few, perhaps new, essential concepts about processes in terms of how they are collected within the system.

Without further digressions, processes are collected into process groups. But there's an elaboration on top of this leading to another concept called sessions, which is associated to the historical concept of job control from a time lacking the pletora of GUI terminals if not, perhaps, just the rare and crude xterm which some ancient seems to inconditionally love.

Although not really a big mistery, the descriptions about these concepts (process groups, sessions and their related) seems unecessarily convoluted in Intro(2) and termio(7I), which can partially obfuscate understanding its central apparatus. My intention is, thus, to address these obstacules by attempting to streamline some ideas and clarify some of these concepts definitions and descriptions:

PROCESS GROUP
A collection of processes that begins when created by a given process which is thereof defined as its process group leader. The process group ends when the last process in the process group ends of leaves the process group.

During its lifetime it's uniquely identified by a positive integer called the process group ID (PGID), which exactly matches the process ID (PID) of its process group leader and furnishes a way of signaling all its member processes as a whole.

Any process that is not a process group leader may create a new process group or a new session (becoming itself the process group leader and, eventually, the session leader of the newly created entity) or yet may join another process group in the same session.

Each process in the system is a member of a single process group and every newly created process joins the process group and session of its parent (process).
SESSION
A collection of process groups that begins when created by a given process which is thereof defined as its session leader. The session ends when the last process in the session ends of leaves the session

During its lifetime it's uniquely identified by a positive integer called the session ID (SID), which exactly matches the process ID (PID) of its original session leader. The original session leader is also the process group leader for the session's originally first process group, hence its process ID (PID) matches its session ID (SID) and its process group ID (PGID) and, as such, the session ID (SID) also matches its originally first process group ID (PGID).

A session is capable of being biunivocally (one-to-one) associated to a terminal (the controlling terminal, /dev/tty according to tty(7D)) by the session leader (the controlling process) which establishes the connection. As sessions are inherited by new processes created within it, so are the controlling terminals, although this association can be broken if these new processes establish a new session (setsid(2)). The controlling terminal can send/handle certain (typically quit and interrupt) signals to the process groups in the (controlling process') session that, in general, will cause them to stop, unless they have made arrangements to mask this out or are orphaned process groups.

Orphaned process groups are those that share the controlling terminal but whose processes' parents do not belong to any other process group in the same session.

Among the process groups in the session, the controlling terminal will distinguish one of them as the foreground process group, thereby exclusively granting it certain terminal access prerrogatives, and treat all the other process groups in that (controlling process') session as background process groups. By default, the controlling process' (session leader's) process group is assigned as the foreground process group.
 
As for a real world example of a few of these concepts in action applied to a daemon creation you may be interested in browsing the output from truss applied to a sample daemon creation code around the fork() and setsid() system calls and associated PIDs and PPIDs numbers.
 

Friday, April 21, 2017

Daemons listing

Without entering into any further detail about what a daemon is, I'll just show how to list them under a privileged (root) Solaris terminal by means of the standard shell command ps(1):

# ps -o user,uid,pid,ppid,pgid,sid,tty,args -t '?' \
    |(IFS=''; read H; echo "$H"; sort -k5 -k3 \
    |grep filtering_options account )
 
    USER   UID   PID  PPID  PGID   SID TT COMMAND
    root     0     1     0     0     0 ?  /usr/sbin/init
    root     0     3     0     0     0 ?  fsflush
    root     0     7     0     0     0 ?  intrd
    root     0     6     0     0     0 ?  kmem_task
    root     0     2     0     0     0 ?  pageout
    root     0     9     0     0     0 ?  postwaittq
    root     0     0     0     0     0 ?  sched
    root     0     8     0     0     0 ?  vmtasks
    root     0   770     0     0     0 ?  zpool-depot
    root     0   788     0     0     0 ?  zpool-export
    root     0     5     0     0     0 ?  zpool-rpool
    root     0    96     1    13    13 ?  /lib/svc/bin/...
    root     0    13     1    13    13 ?  /lib/svc/bin/svc.startd
    root     0   751     1    13    13 ?  /lib/svc/method/iscsid
    root     0  1862  1353    13    13 ?  /usr/lib/...
    root     0  1353  1341    13    13 ?  /usr/lib/...
    root     0   106     1    13    13 ?  /usr/lib/pfexecd
    root     0   155     1    13    13 ?  /usr/lib/rad/rad -sp
    root     0   164     1    13    13 ?  /usr/lib/rad/rad -sp
    root     0  1341     1    13    13 ?  /usr/sbin/gdm-binary
    root     0    15     1    15    15 ?  /lib/svc/bin/...
  netcfg    17    42     1    42    42 ?  /lib/inet/netcfgd
  netadm    16    45     1    45    45 ?  /usr/sbin/ibmgmtd
   dladm    15    53     1    53    53 ?  /usr/sbin/dlmgmtd
  netadm    16    66     1    66    66 ?  /lib/inet/ipmgmtd
  daemon     1    74     1    74    74 ?  /lib/crypto/kcfd
    root     0    84     1    83    83 ?  /lib/inet/in.mpathd
  daemon     1   149     1   149   149 ?  /usr/lib/utmpd
    root     0   178     1   178   178 ?  /usr/sbin/vbiosd
    root     0   185     1   185   185 ?  /usr/lib/zones/...
    root     0   200     1   200   200 ?  /usr/lib/sysevent/...
    root     0   332     1   332   332 ?  /usr/lib/dbus-daemon ...
    root     0   430     1   430   430 ?  /usr/lib/devfsadm/...
  netadm    16   648     1   648   648 ?  /lib/inet/nwamd
    root     0   688     1   688   688 ?  /usr/lib/picl/picld
    root     0   757     1   757   757 ?  /usr/lib/inet/ntpd ...
    root     0   786     1   786   786 ?  /usr/sbin/nscd
  daemon     1   800     1   800   800 ?  /usr/sbin/rpcbind
    root     0   813     1   813   813 ?  /usr/lib/inet/in.ndpd
    root     0   842     1   840   840 ?  /opt/VirtualBox/...
    root     0   843     1   843   843 ?  /usr/lib/inet/...
    root     0   856     1   856   856 ?  /usr/lib/hotplugd
    root     0   860     1   860   860 ?  /usr/lib/autofs/...
    root     0   862   860   860   860 ?  /usr/lib/autofs/...
    root     0   866     1   865   865 ?  /usr/sbin/...
    root     0   870     1   870   870 ?  /usr/sbin/cron
    root     0   876     1   876   876 ?  /usr/lib/hal/...
    root     0   899   878   876   876 ?  /usr/lib/hal/...
    root     0   895   878   876   876 ?  /usr/lib/hal/...
    root     0   977   878   876   876 ?  /usr/lib/hal/...
    root     0  1160   878   876   876 ?  /usr/lib/hal/...
    root     0  1184   878   876   876 ?  /usr/lib/hal/...
    root     0  1206   878   876   876 ?  /usr/lib/hal/...
    root     0  1219   878   876   876 ?  /usr/lib/hal/...
    root     0  1236   878   876   876 ?  /usr/lib/hal/...
    root     0   878   876   876   876 ?  hald-runner
    root     0   942     1   941   941 ?  /usr/lib/ssh/sshd
    root     0   983     1   983   983 ?  /usr/sbin/syslogd
    root     0  1019     1   987   987 ?  /usr/sbin/auditd
   smmsp    25  1005     1  1005  1005 ?  /usr/lib/inet/...
    root     0  1006     1  1006  1006 ?  /usr/lib/inet/...
    root     0  1024     1  1024  1024 ?  /usr/lib/fm/fmd/fmd
    root     0  1126     1  1125  1125 ?  /usr/bin/python2.7 ...
    root     0  1140     1  1140  1140 ?  /usr/sbin/cupsd -C ...
noaccess 60002  1228     1  1228  1228 ?  /usr/lib/fm/notify/...
    root     0  1232     1  1232  1232 ?  /usr/lib/devchassis/...
noaccess 60002  1234     1  1234  1234 ?  /usr/lib/fm/notify/...
    root     0  1349     1  1348  1348 ?  /usr/lib/rmvolmgr -s
     ocm    62  1639     1  1639  1639 ?  /usr/lib/ocm/ccr/...
     gdm    50  1652     1  1649  1649 ?  /usr/bin/dbus-launch
...


A basic description of each chosen column is on the aforementioned manpage, but it was driven by an interest towards daemon programming. One will note that the main filtering criteria is the absence ('?') of a controlling terminal (TT) and that the output was sorted first by process groups (PGID) and then by process ids (PID). Perhaps one will also note (with the help of Intro(2) manpage) that in this listing each process is a member of the first process group in/of each session because its PGID and SID are equal.
    

Monday, April 17, 2017

VirtualBox VM autostart

The VirtualBox VM autostart feature first appeared in version 4.2.0. It's intended purpose is not only to automatically start selected virtual machines upon the host system startup, but to automatically and gracefully stop them upon the host system shutdown. But, of course, unless perhaps the VM is interactive, the stop part of the intent is fictional, specially on headless Solaris server systems. Thus for the stop part the feature acts like a placebo, at least for Solaris hosts.

I've been almost comfortable with headless startups for some time so I've never feel inclined to use the autostart, but now on version 5.1.18 I'm using VirtualBox frequently enough to justify taking some time to set it up and relax about manually starting (but not stopping!) VMs, now a tedious task.

There is a bare minimum documentation about this feature, as it's the case with many other features. In general, there are some mistakes and many omissions in the community provided documentation. Eventually it shall catch up but it would be wise not counting so much on it, anyway...

In a Solaris host environment the solution mechanism is elegant (yet unfortunately there some bugs requiring workarounds) as the autostart feature has been integrated/encapsulated into a SMF service:

Friday, April 14, 2017

Projects

A project is a great Solaris facility essential to network-wide system architecture and administration. In essence it's rather simple but in general it's less-known or frequently misunderstood or underestimated by many engineers, unfortunately. Later on defining projects, in order to take full advantage of them (and their tasks) it's necessary to enable extended accounting, but that will be a topic for a later post.

A project is a collection of network-wide (physical or virtual) hosts processes that share a same tag defined as the project-id which is shared by a collection of internetwork-ed Solaris (physical or virtual) systems. Within each participating host those corresponding processes are further gathered on tasks by means of a common task-id. In the scope of a single host, a project has always one or more subordinate tasks.

The project-ids are gathered in a project database which can be local (/etc/project) or remote (NIS, LDAP or DNS). On this post I'll cover just the local case, but you can grasp an idea of how to implement it on NIS by reading other posts of mine.

For an appropriate project setup, it's useful to distinguish host's processes that derive from a login event from those that do not, because when a login is involved there's an additional way of defining the initial project to be associated with that login, and thus its main process and all its child/derived processes. In general, when processes are launched, the selected project will be deduced from the account which is used to launch the process according to the defined associations in the standard project database of the system.

By the way, a process is tied to a single project-id (project), but be aware that a user or a group can be assigned to multiple project-ids (projects). The processes that a user launches can be associated with any project that this user is associated to (either explicitly by user-name or implicitly by groups memberships) in the standard project database of the system. Of course, the super-user can assign any process to any project.

The raw view of the out-of-the-box project database is as follows:

$ cat /etc/project
system:0::::
user.root:1::::
noproject:2::::
default:3::::
group.staff:10::::


This database can also be listed more verbosely as:

$ projects -l
system
    projid : 0
    comment: ""
    users  : (none)
    groups : (none)
    attribs:
user.root
    projid : 1
    comment: ""
    users  : (none)
    groups : (none)
    attribs:
noproject
    projid : 2
    comment: ""
    users  : (none)
    groups : (none)
    attribs:
default
    projid : 3
    comment: ""
    users  : (none)
    groups : (none)
    attribs:
group.staff
    projid : 10
    comment: ""
    users  : (none)
    groups : (none)
    attribs:


As introduced, for logins events there's an extended user attribute "database" in /etc/user_attr which may or may not list the initial (but previously defined) project to be assigned to any user's processes since upon login. If no project is specified in /etc/user_attr then the search for the assignment will proceed to /etc/project looking for a match in the following order:

  1. user.user-name
  2. group.user-group
  3. The special project called default (if present)

If no suitable project is not found, then the login event or process launch is denied.

Now let's try a few examples in order to get better acquainted with projects. Let's define the marketing project for the john account in /etc/user_attr:

# usermod -K project=marketing john

And to verify it:

# getent user_attr john
john::::project=marketing


or

# userattr project john
marketing

To remove any project for the john account in /etc/user_attr:

# usermod -K project= john

Assuming the primary group of the john account as mkt01, the (fall-back) alternatives in /etc/project for not using /etc/user_attr could be:

# projadd user.john
# projects -l user.john
user.john
        projid : ...
        comment: ""
        users  : (none)
        groups : (none)
        attribs:

or

# projadd group.mkt01
# projects -l group.mkt01
group.mkt01
        projid : ...
        comment: ""
        users  : (none)
        groups : (none)
        attribs:


or none of the above, as long as the default project is present:

# projects -l default
default
        projid : 3
        comment: ""
        users  : (none)
        groups : (none)
        attribs:


Now, another very important application of the project database is for the workloads that do not derive from a login event, but rather are typically started as services or similar background processes, such as the Apache HTTP server. Such "special kind" of workloads, when well planned and administered typically take advantage of projects for both extended accounting and resource control.

As an example, let's set up a dedicated project to an Apache HTTP server that has been just installed and is running under the webservd account. Well, that's not quite exactly the case because, in reality, what traditionally happens is that a root process is launched and forks some child processes that are assigned to a different low-privileged webservd (or other) account that (hopefully) cannot log in to the system. At first, one might think that the following output is due to no project being assigned anywhere for the webservd account, but that's only partially true:

$ id -p webservd
uid=80(webservd) gid=80(webservd) projid=3(default)


$ ps -o user,pid,ppid,project -p "`pgrep -f httpd`"
    USER   PID  PPID  PROJECT
    root   559     1  system
webservd   577   559  system
webservd   591   559  system
webservd   593   559  system
webservd   604   559  system
webservd   607   559  system
webservd   616   559  system

  
These output are expected. The id command is deducing the project for new processes that would be launched in the event of a successful webservd log in to the system, which, of course, (and hopefully) will never happen. And it's truly expected that in a standard (out-of-the-box) setup the default project gets selected in the absence of any other explicit project assignments. But for the ps command listing the explanation is different. In this last case, all httpd child processes (577, 591, 593, 604, 607 and 616) derive from the same parent process (559) which was launched as root, thus inheriting the the system project that is associated to root. In Solaris, this launch actually happens from an SMF service (svc:/network/http:apache22) method which encapsulates the standard Apache HTTP server Control Interface (/usr/apache2/2.2/bin/apachectl; APACHECTL(8)) but unfortunately omits setting a project upon firing the service.

Fixes for problems such as the one above exemplified are certainly possible, but at first it's necessary to define a new project workload (www, for instance). As good practice, not that it's actually required (due to what was explained above), the webservd account should be assigned to this new project. One way to accomplish the task takes a single projadd -U command but for demonstration purposes I'll split it into a projadd followed by a projmod -a -U:

# projadd -c "World Wide Web" www
# projects -l www
www
        projid : 100
        comment: "World Wide Web"
        users  : (none)
        groups : (none)
        attribs:


# projmod -a -U webservd www
# projects -l www
www
        projid : 100
        comment: "World Wide Web"
        users  : webservd
        groups : (none)
        attribs:


By the way, if after creating a project it became necessary to alter some of its attributes and if there are processes already running under this project, it's possible to force them to update their project assignment by means of a projmod -A command. If one is uncertain and no processes are running yet under the project (as on the Apache HTTP server example above; no one is running assigned to the www project), just a harmless warning message is displayed:

# projmod -A www
projmod: Updating ... succeeded with following warning message.
WARNING: No process found ... The project is not updated.


Now focusing on the possible fixes to the issue of having background processes running under undesired projects such as the system project in the example above, there a two solutions that I know:

1) The simpler, but less than ideal "fix" is to "manually" move the processes to the desired project. The move does not required the inconvenience of restaring the processes (in this example, the Apache HTTP server processes). The disadvantage is that it does not integrate well in an automated management as it's not integrated into SMF. The "fix" consists on issuing the following command:

# pgrep -f httpd | xargs -t -l newtask -p www -c
newtask -p www -c 577
newtask -p www -c 616
newtask -p www -c 559
newtask -p www -c 591
newtask -p www -c 593
newtask -p www -c 607
newtask -p www -c 604


Et voilĂ !

# ps -o user,pid,ppid,project -p "`pgrep -f httpd`"
    USER   PID  PPID  PROJECT
    root   559     1  www
webservd   577   559  www
webservd   591   559  www
webservd   593   559  www
webservd   604   559  www
webservd   607   559  www
webservd   616   559  www


2) The more complicated "fix" is to deal with SMF. On this post I won't go too deep in how to properly or ideally accomplish the task. I'll just indicate the central change that has to be done letting clear that by not following the proper procedures to "patch" the SMF service, the "fix" could be lost when applying future updates or when performing system upgrades. I wish I'll have time to dedicate a post on how to properly do this, but for now I suggest doing just the following:

Identify the involved SMF method:

# svccfg -s apache22 listprop start/exec
start/exec astring     "/lib/svc/method/http-apache22 start"


# ll /lib/svc/method/http-apache22
-r-xr-xr-x   1 root  bin  ... /lib/svc/method/http-apache22


Edit the method and hard-code the /usr/bin/newtask command with the desired project (www) in the indicated line (138) as highlighted below:

# chmod 775 /lib/svc/method/http-apache22

# grep -n apachectl /lib/svc/method/http-apache22
138:... /usr/bin/newtask -p www ${APACHE_BIN}/apachectl ... 2>&1


# chmod 555 /lib/svc/method/http-apache22

The next time the service restarts everything shall be fine and under the new project. If, in addition, an immediate change is required but a standard restart would risk disturbing the services, just apply the solution (1) in addition.
 

Wednesday, April 12, 2017

Apache 2.2 - 1st steps

This posts follows the AMP stack installation. But of course in terms of infrastructure it's almost certain that the installation should have been done on a non-global zone and most probably on an immutable zone, as well as on dedicated ZFS file systems and with some sort of role assignment and so on and on... But for now the focus is just bringing Apache 2.2 on-line for serving some static (basic) content over HTTP.

Let's now check a few changes (additions to the system) that the AMP stack installation does in terms of the Apache 2.2 installation.

The most fundamental man page that gets installed is apache22(1M), which among other things reminds us about the following:
Both 32-bit and 64-bit versions of the servers are installed. It also includes two of the most popular MPMs - Prefork and Worker. By the time you read this, maybe the following link will still point or redirect you to the original authors' full documentation of this version: https://archive.apache.org/dist/httpd/docs/httpd-docs-2.2.31.en.pdf.
A new credential is created:

# grep web /etc/passwd /etc/group
/etc/passwd:webservd:x:80:80:WebServer Reserved UID:/:
/etc/group:webservd::80:


# passwd -s webservd
webservd  LK 


# id -p webservd
uid=80(webservd) gid=80(webservd) projid=3(default)


A new dedicated SMF service gets installed:

# svcs -a | grep apache
disabled       18:59:49 svc:/network/http:apache22


# svccfg -s apache22 listprop httpd/*
httpd/enable_64bit        boolean     false
httpd/server_type         astring     prefork
httpd/stability           astring     Evolving
httpd/startup_options     astring    
...

 
Three important directories are created:
 
  • /etc/apache2/2.2/
  • /usr/apache2/2.2/
  • /var/apache2/2.2/

# tree -d /etc/apache2/2.2/
/etc/apache2/2.2/
├── conf.d
│   └── php
├── original
└── samples-conf.d

4 directories


# tree -d /usr/apache2/2.2/
/usr/apache2/2.2/
├── bin
│   ├── 64 -> amd64
│   └── amd64
├── build
│   ├── 64 -> amd64
│   └── amd64
├── include
├── libexec
│   ├── 64 -> amd64
│   └── amd64
├── man
│   ├── man1
│   └── man8
└── manual
    └── mod

15 directories


# tree -d /var/apache2/2.2/
/var/apache2/2.2/
├── cgi-bin
├── error
│   └── include
├── htdocs
├── icons
│   └── small
├── libexec
│   ├── 64 -> amd64
│   └── amd64
├── logs
└── proxy


11 directories

And here is the "full listing" of their initial contents:
(apache22(1M) describe each of them in more detail)
 
# ll -R /etc/apache2/2.2/
/etc/apache2/2.2/:
total 172
-rw-r--r-- 1 root bin  ... mime.types
-rw-r--r-- 1 root bin  ... magic
-rw-r--r-- 1 root bin  ... httpd.conf
-rw-r--r-- 1 root bin  ... envvars
drwxr-xr-x 2 root sys  ... original
drwxr-xr-x 3 root sys  ... conf.d
drwxr-xr-x 2 root sys  ... samples-conf.d


/etc/apache2/2.2/original:
total 35
-r--r--r-- 1 root bin  ... httpd.conf


/etc/apache2/2.2/conf.d:
total 30
-rw-r--r-- 1 root bin  ... modules-64.load
-rw-r--r-- 1 root bin  ... modules-32.load
-rw-r--r-- 1 root bin  ... fcgid.conf
-rw-r--r-- 1 root bin  ... dtrace.conf
-r--r--r-- 1 root bin  ... php.conf
drwxr-xr-x 2 root sys  ... php


/etc/apache2/2.2/conf.d/php:

total 5
-rw-r--r-- 1 root bin  ... php5.3.conf
lrwxrwxrwx 1 root root ... php.conf -> php5.3.conf


/etc/apache2/2.2/samples-conf.d:
total 92
-r--r--r-- 1 root bin  ... vhosts.conf
-r--r--r-- 1 root bin  ... userdir.conf
-r--r--r-- 1 root bin  ... ssl.conf
-r--r--r-- 1 root bin  ... reqtimeout.conf
-r--r--r-- 1 root bin  ... proxy_scgi.conf
-r--r--r-- 1 root bin  ... multilang-errordoc.conf
-r--r--r-- 1 root bin  ... mpm.conf
-r--r--r-- 1 root bin  ... manual.conf
-r--r--r-- 1 root bin  ... languages.conf
-r--r--r-- 1 root bin  ... info.conf
-r--r--r-- 1 root bin  ... default.conf
-r--r--r-- 1 root bin  ... dav.conf
-r--r--r-- 1 root bin  ... autoindex.conf
-rw-r--r-- 1 root bin  ... php5.3-apc-stats.conf
-rw-r--r-- 1 root bin  ... php5.3-memcache-stats.conf


# ll -R /usr/apache2/2.2/
/usr/apache2/2.2/:
total 22
drwxr-xr-x 4 root sys  ... man
drwxr-xr-x 2 root sys  ... include
drwxr-xr-x 3 root sys  ... bin
drwxr-xr-x 3 root sys  ... build
drwxr-xr-x 3 root sys  ... manual
drwxr-xr-x 3 root sys  ... libexec

/usr/apache2/2.2/man:
total 6
drwxr-xr-x 2 root sys  ...  man8
drwxr-xr-x 2 root sys  ...  man1

/usr/apache2/2.2/man/man8:
total 101
...

/usr/apache2/2.2/man/man1:
total 61
...

/usr/apache2/2.2/include:
total 1059
...

/usr/apache2/2.2/bin:
total 3168
-r-x------ 1 root bin  ... suexec.disabled
-r-xr-xr-x 1 root bin  ... rotatelogs
-r-xr-xr-x 1 root bin  ... logresolve
-r-xr-xr-x 1 root bin  ... httxt2dbm
-r-xr-xr-x 1 root bin  ... httpd.worker
-r-xr-xr-x 1 root bin  ... httpd
-r-xr-xr-x 1 root bin  ... htpasswd
-r-xr-xr-x 1 root bin  ... htdigest
-r-xr-xr-x 1 root bin  ... htdbm
-r-xr-xr-x 1 root bin  ... htcacheclean
-r-xr-xr-x 1 root bin  ... envvars-std
-r-xr-xr-x 1 root bin  ... envvars
-r-xr-xr-x 1 root bin  ... dbmmanage
-r-xr-xr-x 1 root bin  ... checkgid
-r-xr-xr-x 1 root bin  ... apxs
-r-xr-xr-x 1 root bin  ... apachectl
-r-xr-xr-x 1 root bin  ... ab
drwxr-xr-x 2 root sys  ... amd64
lrwxrwxrwx 1 root root ... 64 -> amd64

/usr/apache2/2.2/bin/amd64:
total 4013
...

/usr/apache2/2.2/build:
total 57
-r--r--r-- 1 root bin  ... special.mk
-r--r--r-- 1 root bin  ... rules.mk
-r--r--r-- 1 root bin  ... program.mk
-r-xr-xr-x 1 root bin  ... mkdir.sh
-r--r--r-- 1 root bin  ... tlib.mk
-r--r--r-- 1 root bin  ... ibrary.mk
-r-xr-xr-x 1 root bin  ... instdso.sh
-r-xr-xr-x 1 root bin  ... config.nice
-r--r--r-- 1 root bin  ... config_vars.mk
drwxr-xr-x 2 root sys  ... amd64
lrwxrwxrwx 1 root root ... 64 -> amd64

/usr/apache2/2.2/build/amd64:
total 53
...

/usr/apache2/2.2/manual:
total 3
drwxr-xr-x 2 root sys  ... mod

/usr/apache2/2.2/manual/mod:
total 162
-r--r--r-- 1 root bin  ... mod_fcgid.html
-r--r--r-- 1 root bin  ... mod_fcgid.html.en

/usr/apache2/2.2/libexec:
total 72283
-r--r--r-- 1 root bin  ... mod_wsgi-2.7.so
-r--r--r-- 1 root bin  ... mod_wsgi-2.6.so
-r--r--r-- 1 root bin  ... mod_version.so
-r--r--r-- 1 root bin  ... mod_usertrack.so
-r--r--r-- 1 root bin  ... mod_userdir.so
-r--r--r-- 1 root bin  ... mod_unique_id.so
-r--r--r-- 1 root bin  ... mod_suexec.so
-r--r--r-- 1 root bin  ... mod_substitute.so
-r--r--r-- 1 root bin  ... mod_status.so
-r--r--r-- 1 root bin  ... mod_ssl.so
-r--r--r-- 1 root bin  ... mod_speling.so
-r--r--r-- 1 root bin  ... mod_setenvif.so
-r--r--r-- 1 root bin  ... mod_rewrite.so
-r--r--r-- 1 root bin  ... mod_reqtimeout.so
-r--r--r-- 1 root bin  ... mod_proxy.so
-r--r--r-- 1 root bin  ... mod_proxy_scgi.so
-r--r--r-- 1 root bin  ... mod_proxy_http.so
-r--r--r-- 1 root bin  ... mod_proxy_ftp.so
-r--r--r-- 1 root bin  ... mod_proxy_connect.so
-r--r--r-- 1 root bin  ... mod_proxy_balancer.so
-r--r--r-- 1 root bin  ... mod_proxy_ajp.so
-r--r--r-- 1 root bin  ... mod_negotiation.so
-r--r--r-- 1 root bin  ... mod_mime.so
-r--r--r-- 1 root bin  ... mod_mime_magic.so
-r--r--r-- 1 root bin  ... mod_mem_cache.so
-r--r--r-- 1 root bin  ... mod_logio.so
-r--r--r-- 1 root bin  ... mod_log_forensic.so
-r--r--r-- 1 root bin  ... mod_log_config.so
-r--r--r-- 1 root bin  ... mod_ldap.so
-r--r--r-- 1 root bin  ... mod_info.so
-r--r--r-- 1 root bin  ... mod_include.so
-r--r--r-- 1 root bin  ... mod_imagemap.so
-r--r--r-- 1 root bin  ... mod_ident.so
-r--r--r-- 1 root bin  ... mod_headers.so
-r--r--r-- 1 root bin  ... mod_filter.so
-r--r--r-- 1 root bin  ... mod_file_cache.so
-r--r--r-- 1 root bin  ... mod_ext_filter.so
-r--r--r-- 1 root bin  ... mod_expires.so
-r--r--r-- 1 root bin  ... mod_env.so
-r--r--r-- 1 root bin  ... mod_dumpio.so
-r--r--r-- 1 root bin  ... mod_disk_cache.so
-r--r--r-- 1 root bin  ... mod_dir.so
-r--r--r-- 1 root bin  ... mod_deflate.so
-r--r--r-- 1 root bin  ... mod_dbd.so
-r--r--r-- 1 root bin  ... mod_dav.so
-r--r--r-- 1 root bin  ... mod_dav_fs.so
-r--r--r-- 1 root bin  ... mod_cgid.so
-r--r--r-- 1 root bin  ... mod_cgi.so
-r--r--r-- 1 root bin  ... mod_cern_meta.so
-r--r--r-- 1 root bin  ... mod_cache.so
-r--r--r-- 1 root bin  ... mod_autoindex.so
-r--r--r-- 1 root bin  ... mod_authz_user.so
-r--r--r-- 1 root bin  ... mod_authz_owner.so
-r--r--r-- 1 root bin  ... mod_authz_host.so
-r--r--r-- 1 root bin  ... mod_authz_groupfile.so
-r--r--r-- 1 root bin  ... mod_authz_default.so
-r--r--r-- 1 root bin  ... mod_authz_dbm.so
-r--r--r-- 1 root bin  ... mod_authnz_ldap.so
-r--r--r-- 1 root bin  ... mod_authn_file.so
-r--r--r-- 1 root bin  ... mod_authn_dbm.so
-r--r--r-- 1 root bin  ... mod_authn_dbd.so
-r--r--r-- 1 root bin  ... mod_authn_anon.so
-r--r--r-- 1 root bin  ... mod_auth_gss.so
-r--r--r-- 1 root bin  ... mod_auth_digest.so
-r--r--r-- 1 root bin  ... mod_auth_basic.so
-r--r--r-- 1 root bin  ... mod_asis.so
-r--r--r-- 1 root bin  ... mod_alias.so
-r--r--r-- 1 root bin  ... mod_actions.so
-r--r--r-- 1 root bin  ... httpd.exp
-r--r--r-- 1 root bin  ... mod_vhost_alias.so
-r--r--r-- 1 root bin  ... mod_authn_default.so
lrwxrwxrwx 1 root root ... mod_wsgi.so -> mod_wsgi-2.7.so
lrwxrwxrwx 1 root root ... m64 -> amd64
-r--r--r-- 1 root bin  ... mod_php5.3.so
-r--r--r-- 1 root bin  ... mod_fcgid.so
drwxr-xr-x 2 root sys  ... amd64
-r--r--r-- 1 root bin  ... mod_dtrace.so

/usr/apache2/2.2/libexec/amd64:
total 42809
...


# ll -R /var/apache2/2.2/
/var/apache2/2.2/:
total 25
drwxr-xr-x 2 webservd webservd ... proxy
drwx------ 2 root bin  ... logs
drwxr-xr-x 2 root sys  ... htdocs
drwxr-xr-x 2 root sys  ... cgi-bin
drwxr-xr-x 3 root sys  ... icons
drwxr-xr-x 3 root sys  ... error
drwxr-xr-x 3 root sys  ... libexec


/var/apache2/2.2/proxy:
total 0

/var/apache2/2.2/logs:
total 0

/var/apache2/2.2/htdocs:
total 2
-r--r--r-- 1 root bin  ... index.html


/var/apache2/2.2/cgi-bin:
total 5
-r--r--r-- 1 root bin  ... test-cgi
-r--r--r-- 1 root bin  ... printenv


/var/apache2/2.2/icons:
total 459
...


/var/apache2/2.2/icons/small:
total 139
...


/var/apache2/2.2/error:
total 366
-r--r--r-- 1 root bin  ... HTTP_UNSUPPORTED_MEDIA_TYPE.html.var
-r--r--r-- 1 root bin  ... HTTP_UNAUTHORIZED.html.var
-r--r--r-- 1 root bin  ... HTTP_SERVICE_UNAVAILABLE.html.var
-r--r--r-- 1 root bin  ... HTTP_REQUEST_URI_TOO_LARGE.html.var
-r--r--r-- 1 root bin  ... HTTP_REQUEST_TIME_OUT.html.var
-r--r--r-- 1 root bin  ... HTTP_REQUEST_ENTITY_TOO_LARGE.html.var
-r--r--r-- 1 root bin  ... HTTP_PRECONDITION_FAILED.html.var
-r--r--r-- 1 root bin  ... HTTP_NOT_IMPLEMENTED.html.var
-r--r--r-- 1 root bin  ... HTTP_NOT_FOUND.html.var
-r--r--r-- 1 root bin  ... HTTP_METHOD_NOT_ALLOWED.html.var
-r--r--r-- 1 root bin  ... HTTP_LENGTH_REQUIRED.html.var
-r--r--r-- 1 root bin  ... HTTP_INTERNAL_SERVER_ERROR.html.var
-r--r--r-- 1 root bin  ... HTTP_GONE.html.var
-r--r--r-- 1 root bin  ... HTTP_FORBIDDEN.html.var
-r--r--r-- 1 root bin  ... HTTP_BAD_REQUEST.html.var
-r--r--r-- 1 root bin  ... HTTP_BAD_GATEWAY.html.var
-r--r--r-- 1 root bin  ... README
-r--r--r-- 1 root bin  ... HTTP_VARIANT_ALSO_VARIES.html.var
-r--r--r-- 1 root bin  ... contact.html.var
drwxr-xr-x 2 root sys  ... include


/var/apache2/2.2/error/include:

total 7
-r--r--r-- 1 root bin  ... top.html
-r--r--r-- 1 root bin  ... spacer.html
-r--r--r-- 1 root bin  ... bottom.html


/var/apache2/2.2/libexec:

total 4
drwxr-xr-x 2 root bin  ... amd64
lrwxrwxrwx 1 root root ... 64 -> amd64


/var/apache2/2.2/libexec/amd64:
total 0


Just for a quick-start (but be warned: do not keep using those configurations unless you really know what you're doing and intend so) we can accept the defaults in /etc/apache2/2.2/httpd.conf which among other things set the IP address of the server (ServerName) to 127.0.0.1 (localhost) which is reasonable at first.
 
Now it should be possible to start the HTTP web server:
  
# svcadm -v enable apache22
svc:/network/http:apache22 enabled.

# svcs apache22
STATE          STIME    FMRI
online         22:33:30 svc:/network/http:apache22


# svcs -l apache22
fmri         svc:/network/http:apache22
name         Apache 2.2 HTTP server
enabled      true
state        online
next_state   none
state_time   April 12, 2017 10:33:30 PM BRT
logfile      /var/svc/log/network-http:apache22.log
...


# svcs -vL apache22
[ Apr 12 22:33:28 Enabled. ]
[ Apr 12 22:33:28 Executing start method ... ]
Apache version is 2.2
[ Apr 12 22:33:30 Method "start" exited with status 0. ]


On a headless host, a quick verification could be as follows:

# wget -nv -P /tmp http://localhost
... URL:http://localhost/ [44/44] -> "/tmp/index.html" [1]


Otherwise, if GNOME is installed on the web server host itself, then pointing a web browser to http://localhost should display the following (contents of the original bare bones index.html for the main/default site):

It works!





# cat /var/apache2/2.2/logs/access_log
... - - [...22:34:33...] "GET / HTTP/1.1" 200 44
... - - [...
22:34:33...] "GET /favicon.ico HTTP/1.1" 404 209

# cat /var/apache2/2.2/logs/error_log
[...
22:33:29...] [warn] Init: Session Cache is not configured 
                              [hint: SSLSessionCache]
[...]            [notice] Digest: generating secret ...
[...
22:33:31...] [notice] Digest: done
[...
22:33:32...] [notice] Apache/2.2.31 (Unix) 
                          mod_ssl/2.2.31 OpenSSL/1.0.1p 
                          DAV/2 PHP/5.3.29 mod_fcgid/2.3.9 
                          configured -- 
                          resuming normal operations
[...] [error] [client...] File does not exist: .../favicon.ico


Beyond the basic installation, for better resource control management, I strongly recommend adjusting the project (for instance, www) under which the server will be running, that is, achieve something like the following:

# ps -o user,pid,ppid,project -p "`pgrep -f httpd`"
    USER   PID  PPID  PROJECT
    root   559     1  www
webservd   577   559  www
webservd   591   559  www
webservd   593   559  www
webservd   604   559  www
webservd   607   559  www
webservd   616   559  www

 
And that's all folks!