Home · News · Articles · Forum · Downloads · Search Your IP: 38.103.63.58 · Today: Tuesday, January 06, 2009
Main Menu
Home
News
Articles
- General
- Common Software
- Tips & Tricks
- Networking
- Multimedia
- Operation Systems
- Hardware
- Programming
- Security
- Configs
- CMS
Forum
Downloads
Gallery
Search
FAQ
Links
Ping us
Top 10 Article Posters
empty 37
nemo 3
linuxGuru 1
scary 1
tashak 1
siluni 1
Poll
What OS are you using?

Linux

*BSD

Solaris

Mac OS

Windows

Other

You must login to vote.
Installing Apache and mod_fastcgi and php 4.x
Installing apache + mod_fastcgi + php 4.x on Nix system
This will show you how to install apache + mod_fastcgi + php 4.x on Nix system.

#to unify the process and to make first a test that all will work fine we will install these first in /opt directory

mkdir /opt/apache

# we will create a source directory where we will download the apache source files

mkdir /opt/apache/source

cd /opt/apache/source

# at the moment i write this article the version of apache is 2.2.8

wget http://www.apache.org/dist/httpd/httpd-2.2.8.tar.gz
tar xvf httpd-2.2.8.tar.gz
cd httpd-2.2.8


# now we will configure apache.

./configure --prefix=/opt/apache --disable-asis --disable-userdir --enable-logio --enable-rewrite --enable-ssl --with-port=81 --enable-suexec --with-suexec-caller='apache' --with-suexec-docroot='/opt/apache/vhosts/'

# I will explain why i used this configure options. The first one is because i do not want this new apache to mess up with
# my production webserver. So is the --with-port setting. userdir and asis are modules which are enabled by default but i have never
# used so I do not really need them. For full configure options you can check http://httpd.apache.org/docs/2.2/programs/configure.html
# Because i used a server which has Plesk installed i gave and system user called apache already.
# The default apache user however is www. so you can drop that option if you want.
# The main reason why i put this is because suexec usually has a a setting for what could be the minimum user and group id (uid and gid respectfully) who can call it.
# Usually that is set to 100 and when user www is added it has uid=gid=80 so we will either have to change the UID and GID to something higher or set apache to use some other user.
# apache user added by plesk has uid=gid=2524 so it is perfect for our case.
# --with-suexec-docroot is again optional. I used it cause I like my virtual hosts to be in directory called vhosts. The default docroot is $PREFIX/docs .
# If you plan to run 1 website (which probably is not the case) or just have your websites in $PREFIX/docs/domain1.com , $PREFIX/docs/domain2.com and so on, probably you can drop that option too.
# If you put the virtual hosts on vhosts $PREFIX/vhosts and do not change --with-suexec-docroot suexec will throw errors that the script is not in its docroot.

# next is to install apache. If you have received any errors along the way of the configuration your best shot is to ask google about it.

make
make install


# now apache should be ready to be used. So lets move on to get mod_fastcgi installed.

cd /opt/apache/source
wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz
tar xvf mod_fastcgi-2.4.6.tar.gz
cd mod_fastcgi

# next instructions ave been taken from here : http://www.fastcgi.com/mod_fastcgi/INSTALL.AP2

cp Makefile.AP2 Makefile
make top_dir=/opt/apache
make top_dir=/opt/apache install


# Now apache and mod_fast are almost ready. You have to enable the module in httpd.conf. I prefer to take this out of the main configuration file.
# I have created a file /opt/apacheconf/extra/httpd-fastcgi.conf with this content

#---------------------httpd-fastcgi.conf-----------------

LoadModule fastcgi_module modules/mod_fastcgi.so

FastCgiIpcDir /opt/apache/docs/fcgi_ipc/tmp
AddHandler fastcgi-script .fcgi
FastCgiSuexec /opt/apache/bin/suexec
FastCgiConfig -singleThreshold 100 -killInterval 300 -autoUpdate -idle-timeout 30 -pass-header HTTP_AUTHORIZATION


#---------------------------END--------------------------

# note that the directory /opt/apache/docs/fcgi_ipc/tmp have to be created and and apache should be able to read and write to it
# the permission on my system are 660

# now apache and mod-fastcgi are ready. so we will proceed in installing php


mkdir /opt/php
mkdir /opt/php/source
cd /opt/php/source

# I have installed 4.4.7 because my websites are not updated to work on php 5.x series. A very useful resource for that case is http://museum.php.net/

wget http://museum.php.net/php4/php-4.4.7.tar.gz
tar xvf php-4.4.7.tar.gz
cd php-4.4.7
./configure --prefix=/opt/php --enable-versioning --with-layout=GNU --disable-all --enable-ftp --enable-libxml --with-libxml-dir=/usr/local --enable-reflection --with-regex=php --with-zend-vm=CALL --with-mysql=/usr/local/psa/mysql --with-gd=/usr/local --with-pcre-regex=/usr/local --enable-fastcgi

# This configuration again is just for what my websites require. The most important thing is that you should have --enable-fastcgi
# the rest is just what you find best for your needs. We proceed with the install

make
make install

# now we are set to get php added to the mix.

# lets say we have one domain that will work here /opt/apache/vhosts/domain1.com
# for the needs of the php-wrapper I create a directory create /opt/apache/vhosts/domain1.com/php-fastcgi
# In that directory i create a shell script called php-wrapper with the following entries

#!/bin/sh
PHP_FCGI_MAX_REQUESTS=2000
export PHP_FCGI_MAX_REQUESTS
exec /opt/php/bin/php

# Just i will note one of the cool things about this file. Here you can specify PHPRC environmental variable for where the php.ini file for the virtual host is
# Here is a second example foe php-wrapper file


--------------php-wrapper---------------------
#!/bin/sh
PHPRC=”/opt/apache/vhosts/domain1.com/php-fastcgi”
export PHPRC
PHP_FCGI_CHILDREN=3
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=2000
export PHP_FCGI_MAX_REQUESTS
exec /opt/php/bin/php
-------------php-wrapper END----------------------

# now lets say your virtual host looks like this



ServerAdmin webmaster@domain1.com
DocumentRoot "/opt/apache/vhosts/domain1.com"
ServerName domain1.com
ErrorLog "logs/domain1.com-error_log"
CustomLog "logs/domain1.com-access_log" common



# What it has to be added is

SuexecUserGroup user1 apache

Options ExecCGI
SetHandler fastcgi-script


AddType application/x-httpd-fastphp .php
AddHandler application/x-httpd-fastphp .php
Action application/x-httpd-fastphp /php-fastcgi/php-wrapper

allow from all


# The final version will look like this



ServerAdmin webmaster@domain1.com
DocumentRoot "/opt/apache/vhosts/domain1.com"
ServerName domain1.com
SuexecUserGroup user1 apache

Options ExecCGI
SetHandler fastcgi-script


AddType application/x-httpd-fastphp .php
AddHandler application/x-httpd-fastphp .php
Action application/x-httpd-fastphp /php-fastcgi/php-wrapper

allow from all

ErrorLog "logs/domain1.com-error_log"
CustomLog "logs/domain1.com-access_log" common



# Restart apache (/opt/apache/bin/apachectl restart) and all should be working fine

Author: Stefan Batanov
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.
Ratings
Rating is available to Members only.

Please login or register to vote.

Awesome! Awesome! 100% [1 Vote]
Very Good Very Good 0% [No Votes]
Good Good 0% [No Votes]
Average Average 0% [No Votes]
Poor Poor 0% [No Votes]
Search

Enter words:


Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Users Online
Guests Online: 1
No Members Online
Registered: 56
Newest: Grantt721
Random Gallery Image
My Desktop
My Desktop
Screenshots
Friends
DJs Place
Fresh Flash Games
Free Wallpapers
PHP Scripts
Levski
Flash Games
HouseFreaks.Net
Improvements
Bookmark and Share
News Feeds
Article Feeds
Forum Feeds
Spam Poison
Valid CSS!
OSGuides.net 2007 - 2008 Creative Commons License.