Sachin’s Weblog

August 17, 2007

Configure Apache

Filed under: Apache, LAMP — sachin @ 9:34 am

This section describes how to configure Apache. This section is a continued part of the my previous weblog Configuring Apache php and MySQL, and could be useful for any apache configuration. In this section i’m going to talk ’bout various configuration options that we could use with apache installation according the application needs. As i have already describes default compilation of apache doesn’t include some of the modules that could be required for most of the web 2.0 rich applications. Below are the some options and their description, which are disables by default and that we need for such applications.

  • –enable-cache
    Enable dynamic file caching provided by mod_cache. This experimental module may be interesting for servers with high load or caching proxy servers. At least one storage management module (e.g. mod_disk_cache or mod_mem_cache) is also necessary.
  • –enable-disk-cache
    Enable disk caching provided by mod_disk_cache .
  • –enable-expires
    Enable Expires header control provided by mod_expires .
  • –enable-file-cache
    Enable the file cache provided by mod_file_cache .
  • –enable-headers
    Enable control of HTTP headers provided by mod_headers .
  • –enable-mem-cache
    Enable memory caching provided by mod_mem_cache .
  • –enable-mime-magic
    Enable automatical determining of MIME types, which is provided by mod_mime_magic .
  • –enable-proxy
    Enable the proxy/gateway functionality provided by mod_proxy . The proxying capabilities for AJP13 , CONNECT , FTP , HTTP and the balancer are provided by the separate modules mod_proxy_ajp , mod_proxy_connect , mod_proxy_ftp , mod_proxy_http and mod_proxy_balancer . These five modules are also automatically enabled with –enable-proxy .
  • –enable-proxy-ajp
    Enable proxy support for AJP13 (Apache JServ Protocol 1.3) request handling, which is provided by mod_proxy_ajp . This module is an extension for the mod_proxy module, so you should also use –enable-proxy .
  • –enable-proxy-balancer
    Enable load balancing support for the AJP13 , FTP and HTTP protocols, which is provided by mod_proxy_balancer . This module is an extension for the mod_proxy module, so you should also use –enable-proxy .
  • –enable-proxy-connect
    Enable proxy support for CONNECT request handling, which is provided by mod_proxy_connect . This module is an extension for the mod_proxy module, so you should also use –enable-proxy .
  • –enable-proxy-ftp
    Enable proxy support for FTP requests, which is provided by mod_proxy_ftp . This module is an extension for the mod_proxy module, so you should also use –enable-proxy .
  • –enable-proxy-http
    Enable proxy support for HTTP requests, which is provided by mod_proxy_http . This module is an extension for the mod_proxy module, so you should also use –enable-proxy .
  • –enable-rewrite
    Enable rule based URL manipulation provided by mod_rewrite .
  • –enable-so
    Enable DSO capability provided by mod_so . This module will be automatically enabled if you use the –enable-mods-shared option.
  • –enable-ssl
    Enable support for SSL/TLS provided by mod_ssl .
  • –enable-vhost-alias
    Enable mass virtual hosting provided by mod_vhost_alias .
  • –enable-ssl
    Enable support for SSL/TLS provided by mod_ssl .
  • –enable-vhost-alias
    Enable mass virtual hosting provided by mod_vhost_alias .Then The most Important part for apache performance
  • –with-mpm=MPM
    Choose the process model for your server. You have to select exactly one Multi-Processing Module. Otherwise the default MPM for your operating system will be taken. Possible MPMs are beos , mpmt_os2 , prefork , and worker .
    Recommendations
    : According to study, worker mpm should not be used with Apache2 and php 5 on production server, it may cause problem. Prefork mpm is recommended instead. This is because of the fact that PHP is glue. It needs a working OS, a working web server and working 3rd-party libraries to glue together. When any of these stop working PHP needs ways to identify the problems and fix them quickly. When you make the underlying framework more complex by not having completely separate execution threads, completely separate memory segments and a strong sandbox for each request to play in, feet of clay are introduced into PHP’s system.

    The worker MPM
    requires that the latest and greatest version of apr and apr-util be installed, otherwise you will get an error about ap_thread_stacksize being undefined.
Exact configuration of Apache starts with understanding the need of applications that you are going to host, loading all of these module may satisfy your need but any extra loaded modules always causes overhead to apache performance which in turns will not lead you to better situation.
Apache memory leak is commonly know problem for administrators and Multi-Processing Module is to ensure that you can deal with it. It’s my Personal recommendations for all users reading and making their minds to compile Apache, briefly go through Apache performance and their application needs once again before they really compile it, obviously to avoid any future problems.
Anyways, download apache from
http://apache.mirror99.com/httpd/ or from any other mirror on apache.org

CONFIGURE APACHE :

tar -xzvf httpd-(version).tar.gz
cd httpd-(version)
./configure –prefix=/usr/local/apache2 –with-mpm=prefork –enable-ssl –enable-rewrite –enable-module-so –enable-cache –enable-diskcache –enable-expires –enable-file-cache –enable-mem-cache –enable-mime-magic –enable-vhost-alias –enable-usertrack –enable-proxy –enable-proxy-connect –enable-proxy-ftp –enable-proxy-http

make
make install

cd /usr/local/apache2/
mv /usr/local/apache2/bin/* /usr/bin/
ln -s /usr/bin /usr/local/apache2/bin

To start apache at system boot
vi /etc/init.d/apache2d
paste the following lines

=============================
case “$1″ in
’start’)
/usr/local/apache2/bin/apachectl start;;
’stop’)
/usr/bin/pkill httpd;;
*)
echo “usage : $0 { start | stop }”
exit 1;;
esac
exit
=============================

chmod 755 /etc/init.d/apache2d
ln -s /etc/init.d/apache2d /etc/rc5.d/S98apache2d

Start apache server by service apache2.d restart

Note: The startup script may already be configured to higher version then 2.0.55, in that case you don’t need to put the script at system startup.

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

You must be logged in to post a comment.

Blog at WordPress.com.