Install apache2 is totally easy if you are using Ubuntu, simply just
apt-get install .. and the rest is just configuration.
By default Apache2 is working with "
pre-fork mpm" module in most cases.
prefork module is working by single control process is responsible for launching child processes which listen for connections and serve them when they arrive. Apache always tries to maintain several spare or idle server processes, which stand ready to serve incoming requests. In this way, clients do not need to wait for a new child processes to be forked before their requests can be served.
Quote:
The worker MPM uses multiple child processes. It's multi-threaded within each child, and each thread handles a single connection. Worker is fast and highly scalable and the memory footprint is comparatively low. It's well suited for multiple processors. On the other hand, worker is less tolerant of faulty modules, and a faulty thread can affect all the threads in a child process.
The prefork MPM uses multiple child processes, each child handles one connection at a time. Prefork is well suited for single or double CPU systems, speed is comparable to that of worker, and it's highly tolerant of faulty modules and crashing children - but the memory usage is high, and more traffic leads to greater memory usage.
So the different between these 2 are "
pre-fork" module is using existing child process to save time and "
worker" module is using separate child process instead of "borrowing" other child process.
My server has 2GB memory, with around 200 connections simultaneously after a couple of days i have to restart Apache since the server has to deal with so many process, it "forks" the existing child process and maintain it so that it can serve faster in MP (Multi-Processing) operation.
This built up is server memory and my server could not deal with it.
I found that "
worker module" is suit for my low memory server, also processing better in a busy server.
Below is installation and configuration that i use in my server and it's working great:
Code:
apt-get install apache2-mpm-worker libapache2-mod-fcgid
Code:
apt-get install php5-cgi php5-cli php5-curl php5-gd php5-ldap php5-mysql php5-sqlite php5-xsl
now restart apache for the server to take affect:
/etc/init.d/apache2 restartThe installation will remove
pre-fork module and totally harmless, if your virtual hosting is already running, i would recommend you to do the configuration below for all of the virtual host file before starting to install worker module.
below is configuration for virtual host:
Code:
<VirtualHost 1.2.3.4:80>
DocumentRoot /home/user/website/public_html/
ServerName yourwebsite.com
ServerAlias www.yourwebsite.com
<Directory /home/user/website/public_html/>
AddHandler fcgid-script .php
FCGIWrapper /usr/lib/cgi-bin/php5 .php
Options ExecCGI Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
LogLevel warn
ServerSignature On
</VirtualHost>
finally add this to your
/etc/apache2/httpd.confCode:
<Directory /var/www>
AddHandler fcgid-script .php
FCGIWrapper /usr/lib/cgi-bin/php5 .php
Options +ExecCGI
</Directory>
Alias /aptitude /usr/share/doc/aptitude/html/en
Alias /apt /usr/share/doc/apt-doc
<Directory /usr/share>
AddHandler fcgid-script .php
FCGIWrapper /usr/lib/cgi-bin/php5 .php
Options ExecCGI FollowSymlinks Indexes
</Directory>
change the IP and website, directory to suit your need, if your virtual host is different from what i do and what you see, and you only have to add the following code to virtual host file:
Code:
AddHandler fcgid-script .php
FCGIWrapper /usr/lib/cgi-bin/php5 .php
Options ExecCGI Indexes FollowSymLinks MultiViews
I would do the configuration first and run the "
apt-get install" after, so that your server will stay "alive" all the time.
because if you do the "
apt-get install" first you may have to take time to config.
For more info of each module visit:
http://httpd.apache.org/docs/2.1/mod/prefork.html
http://httpd.apache.org/docs/2.0/mod/worker.html
tada
----------------------------
Nguyen