Installing Apache under RHEL 6.1, September 2012.

See also Installing Apache under Solaris below.

Backup and update

Back up the system, see http://ptolemy.eecs.berkeley.edu/~cxh/sa/dumps .html

Update the system: yum update.

Reboot.

Install Apache, MySQL and PhP for RHEL

webuser UID

Note that we run as webuser instead of as user apache. See FAQ/ Web/ Creating An EECS Homepage.

See What do I change after changing the uid or gid?

This means that httpd.conf should have

User webuser
Group webuser
Resources:
yum install httpd httpd-devel
/etc/init.d/httpd start

Install MySQL

See Install MySQL

Install PhP

yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
/etc/init.d/httpd restart
Some of these packages (php-mycrypt, php-devel, php-xml) were not available for me.

See Upgrading PhPMySQL.


Probably obsolete below here

Installing Apache under Solaris

These are cxh's notes about upgrading in 5/07 and 10/07, based on allenh's notes about upgrading apache to 1.3.26, and PHP to 4.2.1 in June, 2002,
revised for the upgrade to Apache 2.0.54 and PHP 4.3.11 in June, 2005
revised for the upgrade to Apache 2.2.6 and PHP 5.2.4 in September, 2007
John Reekie's original installation notes from 1999 are below.

Apache, openssl, PHP on carson

Do the following on carson, since it involves having the website down for a while. Instructions for copying the results to andrews, with a minimum of website downtime, are below.

Note that Solaris 10 usually has OpenSSL installed in /usr/sfw. We install our own version so that we can better manage it. This might be a mistake.

We use shared so that we can create shared libraries for use by other packages. Download the most recent version from http://www.openssl.org.

Note: do not run openssl's config as root. If you do, then /dev/null will be removed.

% cd /home/tools/openssl-1.0.0e
% ./config \
    --prefix=/usr/local/openssl-1.0.0e  \
    --openssldir=/usr/local/openssl-1.0.0e \
    -fPIC shared
% gmake >& make.out &
% tail -f make.out
^C
% make test
(As root):
$ gmake install >& install.out &
$ tail -f install.out
^C

$ cd /usr/local
$ rm ssl
$ ln -s openssl-1.0.0e ssl

Note: make sure that the Amanda backup system still works

ldd /usr/local/amanda/libexec/amanda/amandad
should find libssl.so. If it does not work, then make links.
root@andrews:/usr/local# ldd /usr/local/amanda/libexec/amanda/amandad
...
        libssl.so.0.9.8 =>       (file not found)
        libcrypto.so.0.9.8 =>    (file not found)
...
root@andrews:/usr/local# cd /usr/local/lib
root@andrews:/usr/local/lib# ls -l libssl*
-rwxr-xr-x   1 root      1330380 Aug 16  2007 libssl.so.0.9.7
lrwxrwxrwx   1 root           26 Jun 22  2009 libssl.so.0.9.8 -> ../ssl/lib/libssl.so.0.9.8
root@andrews:/usr/local/lib# rm libssl.so.0.9.8
root@andrews:/usr/local/lib# ln -s ../openssl-0.9.8i/lib/libssl.so.0.9.8 .
root@andrews:/usr/local/lib# ls -l libcrypto*
-rwxr-xr-x   1 root      1441912 Aug 16  2007 libcrypto.so.0.9.7
lrwxrwxrwx   1 root           29 Jun 22  2009 libcrypto.so.0.9.8 -> ../ssl/lib/libcrypto.so.0.9.8
root@andrews:/usr/local/lib# rm libcrypto.so.0.9.8 
root@andrews:/usr/local/lib# ln -s ../openssl-0.9.8i/lib/libcrypto.so.0.9.8 .
root@andrews:/usr/local/lib# ldd /usr/local/amanda/libexec/amanda/amandad

Install cronolog

Cronolog is used to rotate the logs
cd /home/tools/cronolog-1.6.2
./configure
make
make install

Install apache

% cd /home/tools/httpd-2.2.20
% ./configure \
  --prefix=/usr/local/apache-2.2.20 \
  --datadir=/home/www \
  --enable-so \
  --enable-ssl \
  --enable-rewrite \
  --with-ssl=/usr/local/ssl \
  --disable-ipv6 \
  --with-included-apr
We use --disable-ipv6 to avoid Network is unreachable: connect to listener in the error_log file.
We use --with-included-apr to avoid
checking for APR-util... yes
configure: error: Cannot use an exte
al APR-util with the bundled APR
See http://issues.apache.org/bugzilla/show_bug.cgi?id=42089
% gmake >& make.out &
% tail -f make.out
^C

Problem: BIO_set_callback

Undefined                       first referenced
 symbol                             in file
BIO_set_callback                    .libs/ab.o
BIO_set_callback_arg                .libs/ab.o
BIO_get_callback_arg                .libs/ab.o
SSL_CTX_set_info_callback           .libs/ab.o
Fix: Make sure that /usr/local/openssl points to the recently installed version of OpenSSL.

Problem: find_if_index

Undefined                       first referenced
 symbol                             in file
find_if_index                       /export/home/tools/httpd-2.2.4/srclib/apr/.libs/libapr-1.so
http://issues.apache.org/bugzilla/show_bug.cgi?id=39199 Patch srclib/apr/network_io/unix/multicast.c according to http://svn.apache.org/viewvc/apr/apr/trunk/network_io/unix/multicast.c?r1=493802&r2=493801&pathrev=493802 and rerun make

ap_bucket_type_error missing

Undefined                       first referenced
 symbol                             in file
ap_bucket_type_error                modules/http/.libs/libmod_http.a(http_filters.o)
ap_register_provider                modules/aaa/.libs/libmod_authn_file.a(mod_authn_file.o)
ap_bucket_error_create              modules/http/.libs/libmod_http.a(http_filters.o)
ap_lookup_provider                  modules/aaa/.libs/libmod_auth_basic.a(mod_auth_basic.o)
I'm not sure about this one. I ended up copying the command that failed into a separate file and adding -Lserver/.libs -lmain. Or, edit build/config_vars.mk and add -Lserver/.libs -lmain to the AP_LIBS line that has -lsocket.

problems with ln

While building or installing, I got this:
  (cd /usr/local/apache-2.2.6/lib && { ln -s -f libaprutil-1.so.0.2.
  11 libaprutil-1.so || { rm -f libaprutil-1.so && ln -s libaprutil-
  1.so.0.2.11 libaprutil-1.so; }; })
  Usage: ln [-f] [-s] f1
       ln [-f] [-s] f1 f2
       ln [-f] [-s] f1 ... fn d1
so, under bash as root, I did
export PATH=/usr/bin:${PATH}
so that I get the write version of ln

libpopt.so.0: open failed

Also, I got this:

  Installing man pages and online manual                                    
  ld.so.1: rsync: fatal: libpopt.so.0: open failed: No such file or         
  directory                                                                 
so I did this
export LD_LIBRARY_PATH=/usr/local/lib
$ make install >& install.out &
$ tail -f install.out
^C


If this is not an upgrade installation, as root, make a new certificate See How do I self-sign a certficate? or copy the old certificates (and configuration files).

If apache is being upgraded, run:

$ cd /usr/local/apache-2.2.20/conf
$ (cd ../../apache/conf; tar -cf - *.crt *.key) | tar -xpf -
$ cp ../../apache/conf/tomcat-mod_jk.conf .
$ cp ../../apache/conf/rewrite.conf .
$ cp /usr/local/apache/modules/mod_jk.so ../modules/
$ cd /usr/local
Note: We do not change the /usr/local/apache link until we are ready to build MySQL or PhP. The MySQL and PhP configuration should be done with the version of apache in place that will be used at run time.

Now configure httpd.conf, according to http://www.php.net/manual/en/install.apache.php, and the existing httpd.conf settings.

One way is to use diff between the old and the new:

diff ../../apache-2.2.17/conf/httpd.conf .

Another way is to make changes.

Changes made from the default:
    - LoadModule php4_module modules/libphp4.so
    No Longer Neccessary:
         - ExtendedStatus:		uncommented, "On"
         - Port:			8080 -> 80
    - User, Group:		daemon -> apache, for both
    - ServerAdmin:		you@example.com -> root@andrews.eecs.berkeley.edu
    No Longer Necessary:
         - Change "Listen" args from 8080 and 8443 to 80 and 443, respectively, in
	    "<IfDefine SSL>" section.
         - UseCanonicalName:		Off -> On
         - ServerName:
		comment out, move to <VirtualHost -> contexts
    - DocumentRoot:		comment out, move to <VirtualHost> contexts
    - First <Directory> section /home/www/htdocs -> home/www/gsrcwww
    - Duplicate <Directory> section for
	- /home/www/chesswww,
	- /home/www/embeddedwww,
	- /home/www/php,
	- /home/www/bugzilla.
	Check the options against the previous-version http.conf.
    - Add "index.jsp and index.shtml arguments to "DirectoryIndex index.html" line:
          DirectoryIndex index.html index.jsp index.shtml
    - Exclude CVS directories
      >DirectoryMatch /CVS/<
          Order Deny,Allow
          Deny from All
      >/DirectoryMatch<

    - ErrorLog:			Use cronolog, see prev. file
    - No longer necessary:
           - Comment out "/manual" alias and its <Directory> section
    - Comment out "ScriptAlias /cgi-bin/", move to <VirtualHosts> contexts
    - No longer necessar, we have no kiosk:
           - Add kiosk <Directory> section after '<Directory "/home/www/cgi-bin">'
    - Add 'Include "/usr/local/apache/conf/rewrite.conf"'.
    - Add "AddType" lines for .php, .php3, .phps, JNLP, .jnlp
	(to match previous ver)
    - Un-comment "AddHandler cgi-script .cgi"
    - On markov, add NameVirtualHost lines, with SSL port numbers.
    - Add a <VirtualHost> context for each virtual host: gigascale, chess, e3s-center, embedded and trust:
	<VirtualHost <IP_address>:80>
	    ServerName: <website_name>
	    DocumentRoot /home/www/[gsrc|chess|embedded]www

	    TransferLog "|/usr/local/cronolog/sbin/cronolog -l /usr/local/apache/logs/access_log_<name> /usr/local/apache/logs/%Y/%m/%d/access_log_<name>"
	    CustomLog    "|/usr/local/cronolog/sbin/cronolog -l /usr/local/apache/logs/agent_log /usr/local/apache/logs/%Y/%m/%d/agent_log" agent

	    Alias /pipermail/ "<mailman_home>/archives/public/"
	    ScriptAlias /cgi-bin/ "/home/www/<name>www/cgi-bin/"
	    ScriptAlias /mailman/ "<mailman_home>/cgi-bin/"

	    # This can't just be included once at the top.  It must be in each
	    # <VirtualHost> context:
	    Include "/usr/local/apache/conf/rewrite.conf"
	</VirtualHost>

Make the following changes to /usr/local/apache/conf/extra/httpd-ssl.conf
One was is to use diff:

diff /usr/local/apache-2.2.17/conf/extra/httpd-ssl.conf /usr/local/apache-2.2.20/conf/extra/httpd-ssl.conf

The otherway is to just edit the file. This file used to be /usr/local/apache/ssl.conf

    - On carson, add "Listen" lines for ports 4430 and 4431 for the testbed virtual hosts.
    - Add a <VirtualHost> section for each virtual host:
	<VirtualHost <IP_address>:<port>>
	    ServerName <website_name>
	    DocumentRoot /home/www/[gsrc|chess|embedded]www

	    TransferLog "|/usr/local/cronolog/sbin/cronolog -l /usr/local/apache/logs/access_log_<name> /usr/local/apache/logs/%Y/%m/%d/access_log_<name>"
	    CustomLog    "|/usr/local/cronolog/sbin/cronolog -l /usr/local/apache/logs/agent_log /usr/local/apache/logs/%Y/%m/%d/agent_log" agent

	    SSLEngine on

	    SSLCertificateFile    /usr/local/apache-2.0.54/conf/<name>-crt/server.crt
	    SSLCertificateKeyFile /usr/local/apache-2.0.54/conf/<name>-crt/server.key

	    <Files ~ ".(cgi|shtml|phtml|php3?)$">
		SSLOptions +StdEnvVars
	    </Files>
	    <Directory "/home/www/<name>www/cgi-bin">
		SSLOptions +StdEnvVars
	    </Directory>

	    SetEnvIf User-Agent ".*MSIE.*" 
		     nokeepalive ssl-unclean-shutdown 
		     downgrade-1.0 force-response-1.0

	    CustomLog logs/ssl_request_log 
		      "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x "%r" %b"

	    Include "/usr/local/apache/conf/rewrite.conf"

	</VirtualHost>

The easiest way to see what changes are necessary is to do a diff between the old httpd.conf and the new one. Pay particular attention to includes for the vhosts and ssl files, usually extras/http-vhosts.conf and extras/httpd-ssl.conf.

The vhosts and ssl files will also need to be updated.

You will also need to update rewrite.conf and files in /usr/local/apache/modules and /usr/local/apache/libexec.

Also, edit /usr/local/extras/httpd-mpm.conf and change MaxRequestPerChild from 0 to 10000. For details, see Server Crash: Not enough space: fork: Unable to fork new process

Install MySQL

PHP requires that MySQL is installed first Install MySQL

Install PHP

See also PHP Upgrade, which duplicates the instructions below. However, you are better off using these instructions.

Download and unpack the 5.3.3 release from http://www.php.net.

% cd /home/tools/php-5.3.3
(INSTALL file here directs user to more up-to-date documentation at http://www.php.net/manual/en/install.apache.php. Proceeding according to that document.)