آموزش نصب FastCgi در دایرکت ادمین
گروه آموزشی مجموعه تدبیر
fcgid is apache fastcgi implementation module that is really a fast apache handler.It is an alternative to apache mod_cgi and mod_cgid apache handler module but so much faster and with high performance .What it really does as I know it caches the php functions and classes and remain them active untill the time they are requested from clients and so that it wont load them again and consume cpu processes also it caches mysql queries and all of those will lower the amount of cpu usage and also that automaticly will reduse HArd i/o wait time so that this will make the load of the server so low and every thing will be served to clients from ram that is so faster than hard drives.
it is an alternative to mod_php with much more faster with a similar performance.
In this tutorial you will gongi to find out how to compile and make it enabled on directadmin control panel customized compiled apache .
So lets get started
run the following command into your secure shell(ssh);
wget http://archive.eu.apache.org/dist/httpd/mod_fcgid/mod_fcgid-2.3.5.tar.bz2
tar jxf mod_fcgid-2.3.5.tar.bz2
cd mod_fcgid-2.3.5
APXS=/usr/sbin/apxs ./configure.apxs && make && make install
mkdir /fcgi
Go to the custombuild directory which is provided by directadmin and open it using the nano editor
nano -w options.conf
in the case that you recieved error that nano is not understood by your linux you must have it installed
for installing nano just use yum
you will recieve a confirmation yes/no, surly type yes and enter to continue installing nano editor.
You must make this option to yes in options.conf
php5_cgi=yes
on the very first lines there should be something like this after you modify this options.conf
php5_ver=5.2
php4_cli=no
php4_cgi=no
php5_cli=no
php5_cgi=yes
after that build php by runngi the following command
then you should add mod_fcgid to apache
for doing so you should intruct apache to load mod_fcgid on its config file which is httpd.conf
by the following command you will open htpd.conf by nano editor
add the following codes that are fcgid config lines to httpd.conf
SharememPath /var/run/fcgid_shm
SocketPath /var/lib/httpd/fcgid/sock
FcgidIdleTimeout 3600
FcgidProcessLifeTime 7200
FcgidMaxProcesses 128
FcgidMaxProcessesPerClass 4
FcgidConnectTimeout 60
FcgidIOTimeout 90
FcgidInitialEnv RAILS_ENV production
# FcgidInitialEnv PHP_FCGI_CHILDREN 4
# MaxRequestsPerProcess 500
AllowOverride All
Options SymLinksIfOwnerMatch
Order allow,deny
Allow from all
php_admin_flag engine off
php_admin_flag engine off
Then after that we should go to the virtualhost template to modify virtual hosts that is located at
/usr/local/directadmin/data/templates
we will create a folder named custom
we wil copy thise files into this folder from templates
virtual_host2_secure.conf
virtual_host2_secure_sub.conf
virtual_host2_sub.conf
for creating the folder named custom and to copying these 4 files we will use the following command:
mkdir custom
cp virtual_host2*.conf custom
cd custom
comment out the lines that are commented as commented here on each of these 4 virtual_hosts2
# php_admin_flag engine |PHP|
#
# php_admin_flag safe_mode |SAFE_MODE|
#
# php_admin_value sendmail_path ‘/usr/sbin/sendmail -t -i -f |USER|@|DOMAIN|’
|*endif|
|*if OPEN_BASEDIR=”ON”|
# php_admin_value open_basedir |OPEN_BASEDIR_PATH|
|*endif|
|*if SUPHP=”1″|
# suPHP_Engine |PHP|
# suPHP_UserGroup |USER| |GROUP|
|*endif|
and then insert the following lines of codes just before the start of codes written above
SetHandler fcgid-script
Options +FollowSymLinks +ExecCGI
SetHandler fcgid-script
FCGIWrapper “/fcgi/|USER|/public_html/fcgid.sh” .php
Options +ExecCGI
allow from all
crate fcgid.sh shell script;
nano -w fcgid.sh
and then pase these codes into fcgid.sh
export PHP_FCGI_MAX_REQUESTS=0
exec /usr/local/php5/bin/php-cgi
create domain_create_post.sh in the smae fodler you already created fcgid.sh shell script and paste the following code into that shell script that you already created
mkdir -p /fcgi/${username}/public_html
cp /usr/local/directadmin/scripts/custom/fcgid.sh /fcgi/${username}/public_html/fcgid.sh && chmod 0700 /fcgi/${username}/public_html/fcgid.sh
cp /usr/local/directadmin/scripts/custom/php.ini /fcgi/${username}/public_html/php.ini
perl -pi -w -e “s/PHPCFG_BASEDIR//home/${username}//g;” /fcgi/${username}/public_html/php.ini
chown -R ${username}:${username} /fcgi/${username}
echo “`date` ${domain} created ” >> /var/log/directadmin/domain_create.log
copy php.ini to /usr/local/directadmin/scripts/custom/ directory
edit the php.ini that you have just copied with nano text editor
and then search for open_basedir that is normally commented out by default by a semicolon
for searching use CTRL + W and hen type the text to search that in this case it should be open_basedir
remove the semicolon and assign it PHPCFG_BASEDIR:/tmp:/var/tmp
after that run the bellow command:
THanks