Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed Aug 25, 2010 1:00 am 
Offline
Junior Member

Joined: Sun Apr 11, 2010 7:06 am
Posts: 22
Due to high load on the CPU and I.O maxing, I decided to change my apache2 config to worker+php-cgi+mod-cgi

These are the set of commands I issued:
1. apt-get -u install php5-cgi libapache2-mod-fcgid apache2-mpm-worker
2. a2dismod php5 (disable php5)
3. Enable the ‘actions‘ and ‘fcgid‘ Apache mods (e.g. a2enmod fcgid and a2enmod actions)
4. Edited /etc/apache2/mods-enabled/fcgid.conf and bumped the “IPCCommTimeout” up to 60 from the default of 20
5. Created a /etc/apache2/conf.d/php-fcgid.conf file with the contents

<IfModule !mod_php4.c>
<IfModule !mod_php4_filter.c>
<IfModule !mod_php5.c>
<IfModule !mod_php5_filter.c>
<IfModule !mod_php5_hooks.c>
<IfModule mod_actions.c>
<IfModule mod_alias.c>
<IfModule mod_mime.c>
<IfModule mod_fcgid.c>
# Path to php.ini – defaults to /etc/phpX/cgi
DefaultInitEnv PHPRC=/etc/php5/cgi

# Number of PHP childs that will be launched. Leave undefined to let PHP decide.
#DefaultInitEnv PHP_FCGI_CHILDREN 3

# Maximum requests before a process is stopped and a new one is launched
#DefaultInitEnv PHP_FCGI_MAX_REQUESTS 5000

# Define a new handler "php-fcgi" for ".php" files, plus the action that must follow
AddHandler php-fcgi .php
Action php-fcgi /fcgi-bin/php-fcgi-wrapper

# Define the MIME-Type for ".php" files
AddType application/x-httpd-php .php

# Define alias "/fcgi-bin/". The action above is using this value, which means that
# you could run another "php5-cgi" command by just changing this alias
Alias /fcgi-bin/ /var/www/fcgi-bin.d/php5-default/

# Turn on the fcgid-script handler for all files within the alias "/fcgi-bin/"
<Location /fcgi-bin/>
SetHandler fcgid-script
Options +ExecCGI
</Location>
</IfModule>
</IfModule>
</IfModule>
</IfModule>
</IfModule>
</IfModule>
</IfModule>
</IfModule>
</IfModule>


6. create the directory which is chosen by the alias, and put in a symlink to the php5-cgi binary

# mkdir /var/www/fcgi-bin.d/php5-default
# ln -s /usr/bin/php5-cgi /var/www/fcgi-bin.d/php5-default/php-fcgi-wrapper

7. Restart Apache —

-------------------------------------------------------------

The wordpress site now is not opening and gives an internal failure:

The error log returns

"Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration"


What am I doing wrong?

Any help will be appreciated.

many thanks


Top
   
 Post subject:
PostPosted: Wed Aug 25, 2010 1:45 am 
Offline
Junior Member

Joined: Sun Apr 11, 2010 7:06 am
Posts: 22
Resolved it. There was a variable called php_value which was dynamically trying to set the php timeout in .htaccess.

Now the error is:
You don't have permission to access /fcgi-bin/php-fcgi-wrapper/index.php on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
---------------------------------------

Checking the error log:
Symbolic link not allowed or link target not accessible: /var/www/fcgi-bin.d/php5-default/php-fcgi-wrapper
---------------------------------------------

I went back and reissued the symbolic linkl creation:
mkdir /var/www/fcgi-bin.d/php5-default
# ln -s /usr/bin/php5-cgi /var/www/fcgi-bin.d/php5-default/php-fcgi-wrapper
-----------------------------------------------


Let me know if you can see anything wrong....

thanks again.


Top
   
 Post subject:
PostPosted: Sat Oct 30, 2010 12:56 pm 
Offline
Senior Newbie
User avatar

Joined: Sat Oct 30, 2010 12:53 pm
Posts: 19
Website: http://www.whyaskwhy.org/
Location: USA
Hey fresbee,

Did you ever figure out what the issue was?

I too am getting the 403 Forbidden error client-side and the Symbolic link not allowed or link target not accessible error in the Apache log.

I call myself checking permissions, etc.


Top
   
 Post subject: Sorta figured it out
PostPosted: Sat Oct 30, 2010 7:13 pm 
Offline
Senior Newbie
User avatar

Joined: Sat Oct 30, 2010 12:53 pm
Posts: 19
Website: http://www.whyaskwhy.org/
Location: USA
I got it working, but I pulled some info from a few other sites and mashed them up. Yep, not always a great idea, but it's something.

Here is what I have:

php-fcgid.conf

Code:
# Enable PHP in vhosts instead
#AddHandler fcgid-script .fcgi .php
AddHandler fcgid-script .fcgi

# Where to look for the php.ini file?
DefaultInitEnv PHPRC        "/etc/php5/cgi"

# Maximum requests a process handles before it is terminated
MaxRequestsPerProcess       1000

# Maximum number of PHP processes
MaxProcessCount             10

# Number of seconds of idle time before a process is terminated
IPCCommTimeout              240
IdleTimeout                 240

FCGIWrapper /usr/bin/php-cgi .php


My vhost file:
Code:
    <Directory /var/www/domain/www>
        <FilesMatch "\.ph(p3?|tml|ps)$">
            AddHandler fcgid-script .php
            Options +ExecCGI
        </FilesMatch>
    </Directory>


The FilesMatch part could be stripped out to leave:

Code:
    <Directory /var/www/domain/www>
            AddHandler fcgid-script .php
            Options +ExecCGI
    </Directory>


I removed .fcgi from the AddHandler directive, as I don't plan on using files with that extension on this particular vhost, but added back you have:

Code:
    <Directory /var/www/domain/www>
            AddHandler fcgid-script .fcgi .php
            Options +ExecCGI
    </Directory>


References:


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group