- Log into Plesk and enable CGI/FastCGI support. Go to Tools and Settings>Apache Modules> Check fcgid
- Enable fcgid for your domain :
/usr/local/psa/bin/domain -u example.com -php_handler_type fastcgi -fastcgi true
- Log into your server as root or sudoer account via SSH.
- Make a local copy of the PHP CGI binary program for your domain:
cp /usr/bin/php5-cgi /var/www/vhosts/example.com/bin/
- Change the ownership of the bin directory and your new local copy of PHP:
chown -R domainuser:psacln /var/www/vhosts/example.com/bin/
- Modify or create your local Apache configuration file, vhost.conf:
vim /var/www/vhosts/example.com/conf/vhost.conf
Add the following lines to the file: (may need to be created first)
vhost.confAddHandler fcgid-script .php
SuexecUserGroup domainuser psacln
<Directory /var/www/vhosts/example.com/httpdocs> FcgidWrapper /var/www/vhosts/example.com/bin/php5-cgi .php Options +ExecCGI +FollowSymLinks allow from all </Directory> - Enable shared memory for FCGID:
echo "SharememPath /var/run/fcgid_shm" >> /etc/apache2/apache2.conf
- Reload your Apache configuration settings:
/usr/local/psa/admin/bin/httpdmng --reconfigure-domain example.com
- Restart Apache:
/etc/init.d/apache2 graceful
Adjust your sessions directory:
Since PHP will now be running as the script's user rather than apache, the permissions for the session folder need adjusted to account for this.
chmod 777 /var/lib/php5
Adjust permissions:
If you have already modified permissions, or your site has been running for a while on your server, you may need to correct file ownership and permissions. You can use the following commands to reset permissions and ownership to a "standard" state. You probably don't need to run these commands if you're configuring a new domain or have just installed your CMS.
cd /var/www/vhosts/example.com/httpdocs && \
chown -R domainuser:psacln * &&\
find . -type f -exec chmod 644 {} \; &&\
find . -type d -exec chmod 755 {} \;
You should consider adjusting the number of simultaneous FastCGI processes allowed for each domain and for the server overall, based on the number of domains that you have running FastCGI. The default configuration allows 64 total processes and 8 per domain. Edit your configuration file:
vim /etc/httpd/conf.d/fcgid.conf
Update the following variables, if desired:
fcgid.conf
MaxProcessCount 64
DefaultMaxClassProcessCount 8
You should set the DefaultMaxClassProcessCount to the number of processes you want a single domain to be able to run simultaneously. Multiply that number by the number of domains that are running FastCGI, and use that number for the MaxProcessCount. For example, if you have 4 domains using FastCGI, and you want them to run a maximum of 10 simultaneous processes each, you can set the following values:
fcgid.conf
MaxProcessCount 40
DefaultMaxClassProcessCount 10
Do not set these values arbitrarily high, as this may interfere with your server's memory usage. Alternately, you can pick a server maximum first for the MaxProcessCount, and then divide by the number of your domains to set the DefaultMaxClassProcessCount value.