http://httpd.apache.org/docs/current/howto/htaccess.html - continue reading from the "How directives are applied" section

http://furbo.org/2015/01/22/fear-china/ - done reading
http://speckyboy.com/2012/06/18/using-the-power-of-the-htaccess-file-to-improve-wordpress-seo/ - done reading
http://www.sitepoint.com/htaccess-for-all/ - done reading
http://net.tutsplus.com/tutorials/apache-aliasing-and-redirection/ - done reading
http://code.tutsplus.com/tutorials/apache-aliasing-and-redirection--net-28606 - done reading

Sending Apache Logs to Syslog
Security and Performance


Various non-HTTP-related projects from ASF

How can we check if the configuration files are valid?

httpd -S

How can we start or stop apache using a different configuration file?

/usr/sbin/httpd -k start -f /etc/httpd/conf/httpd.conf
/usr/sbin/httpd -k stop -f /etc/httpd/conf/httpd.conf

How can we start apache in single process mode?

/usr/sbin/httpd -k start -X -f /etc/httpd/conf/httpd.conf

Problem with single process mode and share memory

If you frequently restart your sandbox in single process mode, occassionally you may get an error "…". Here is how I clean up share memory segments:

ipcs -s | gawk '{ print $2 }' | grep -P '\d' | xargs -n 1 ipcrm -s

What is an MPM?

MPM stand for Multi-Processing Modules. It is a modular design / API that allow apache to be easily ported to a wide variety of platforms in a range of different environments. Different platforms and different environments often require different features, or may have different ways of implementing the same feature most efficiently. This design allows the webmaster to choose which features to be included in the server by selecting which modules to load either at compile-time or at run-time.

At the user level, MPMs appear much like other modules. The main difference is that one and only one MPM can be loaded into the server at any time. MPMs must be chosen during configuration, and compiled into the server. Compilers are capable of optimizing a lot of functions if threads are used, but only if they know that threads are being used. Different distribution (operating system) may provide different binaries for different mpm. For example, RedHat ES4 or Fedora Core 4 provide /usr/sbin/httpd.worker for the worker (threaded) mpm, and /usr/sbin/httpd for the prefork mpm.

How do I know which mpm is currently used?

From command line, you can specify -l option to either /usr/sbin/httpd or apachectl. From inside your code, you can call ap_mpm_query()

How can we build the debuginfo rpm

In order to build the debuginfo rpm for a particular rpm package, the src rpm of the respective package needs to be obtained. In this example, we will build the debuginfo rpm for httpd package.

up2date -d httpd --src --get (see the up2date man page) 
cd /var/spool/up2date 
rpm -i  *.src.rpm (and install any dependent packages if necessary) 
rpmbuild -bb /usr/src/redhat/SPECS/httpd.spec (This re-build the packages) 
cd /usr/src/redhatRPMS/i386 (the debuginfo rpm should be here)

What are other web servers?

What are some load balancing software?

  • mod_proxy
  • perlbal

What are some tools for load testing?

What is the purpose of the MM library?

The MM library is optional. It is used for shared memory support in Apache/EAPI. This allows mod_ssl to use high performance RAM-based session instead of disk-base one.

How can we install Apache from source?

mkdir /usr/src/apache
cp apache_1.3.x.tar.gz /usr/src/apache
cp mod_ssl_2.6.x-1.3.x.tar.gz /usr/src/apache
cp openssl_0.9.x.tar.gz /usr/src/apache
cp mm_1.1.x.tar.gz /usr/src/apache

cd /usr/src/apache
tar -xvzf apache_1.3.x.tar.gz
tar -xvzf openssl_0.9.x.tar.gz

cd openssl-0.9.x
make test
make install

cd ..
cd mm-1.1.x
./configure --disable-shared

cd ..
tar -xvzf mod_sql-2.6.x_1.3.x.tar.gz
cd mod_ssl-2.6.x-1.3.x
./configure --with-apache=../apache_1.3.x

cd ..
[ ... Add more modules to Apache source tree ...]

tar -xvzf mod_perl-1.xx.tar.gz
cd mod_perl-1.xx
perl Makefile.PL \
    APACHE_SRC=../apache_1.3.x/src \
    USE_APACI=1 \
    PREP_HTTPD=1 \
make install // This will install only the Perl portion

cd ..
cd apache_1.3.x
./configure \
    --with-mm=../mm-1.1.x \
    --prefix=/usr/local/apache \
    --enable-module=ssl \
    --activate-module=src/modules/perl/libperl.a \
    --enable-module=perl \
    --enable-shared=ssl \ # build mod_ssl as a DSO
    --enable-shared=perl \
    --enable-module=rewrite \

make certificate
make install

cd ..
/usr/local/apache/bin/apachectl start
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl startssl

How can we install mod_auth_mysql as a DSO?

tar -xvzf mod_auth_mysql...
cd mod_auth_mysql...
cp config.h auth_mysql_config.h
/usr/local/apache/bin/apxs -i -a -I/usr/local/mysql/include -L/usr/local/mysql/lib -lmysqlclient -c mod_auth_mysql.c

How can we install mod_fastcgi as a DSO?

unpack the source
change to the mod_fastcgi source directory
/usr/local/apache/bin/apxs -o mod_fastcgi.so -c *.c
/usr/local/apache/bin/apxs -i -a -n fastcgi mod_fastcgi.so

How can we install mod_php as a DSO from source?

unpack the source tar file for PHP
change to PHP source directory
./configure \
    --with-apxs=/usr/local/apache/bin/apxs \
    --with-gd \
    --with-imap \
    --with-mysql=/usr/local/mysql \
    --with-ldap=/usr/local \
    --with-zlib \
make install

How can we install mod_perl as a DSO from source?

change to source directory
perl Makefile.PL \
    USE_APXS=1 \
    WITH_APXS=/usr/local/apache/bin/apxs \
make install

How can we password protect a directory?

1. Create .htaccess file that look like this:

AuthUserFile    /usr/www/dirname/.htpasswd
AuthGroupFile    /dev/null
AuthName    "The Secret Page"
AuthType Basic

<Limit GET POST>
    require valid_user

2. Create the .htpasswd file:

htpasswd -c .htpasswd user_name

3. Continue to add new users without the -c option:

htpasswd .htpasswd new_user_name

Look into using htdigest.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License