Install Apache2 with FastCGI in Ubuntu Server 14.04

Posted on

Install Apache2 with FastCGI in Ubuntu Server 14.04
tutorial ini, kita akan Install Apache2 with FastCGI in Ubuntu Server 14.04. Menggunakan FastCGI dengan PHP, kita dapat mengatur beberapa versi PHP, dan menggunakan suexec untuk mendukung web pengguna dengan contoh sendiri dari PHP, yang berarti kita dapat memisahkan file php.ini untuk setiap pengguna web.

Install Apache2

apt-get install apache2 apache2-mpm-worker libapache2-mod-fcgid apache2-suexec-custom

Install PHP5

apt-get install php5 libapache2-mod-php5 php5-cgi php5-cli php5-gd php5-mysql php5-json

Install mysql-client

apt-get install mysql-client

Edit suexec userdir,

nano /etc/apache2/suexec/www-data

with content:


Setting up fcgi in home users. Create a user name “udon″

useradd -m udon
cd /home/udon

Create folder cgi-bin with a sub directory in home udon.

mkdir -p cgi-bin/php5-default
cd cgi-bin/php5-default

Create a file name php-fcgi-wrapper,

nano php-fcgi-wrapper

with content:

# Wrapper for PHP-fcgi
# This wrapper can be used to define settings before launching the PHP-fcgi binary.
# Define the path to php.ini. This defaults to /etc/phpX/cgi.
export PHPRC=/home/udon/conf
# Define the number of PHP child processes that will be launched.
# This is low to control memory usage on a server that might launch
# these processes for lots of domains.
# Leave undefined to let PHP decide.
# Maximum requests before a process is stopped and a new one is launched

# Launch the PHP CGI binary
# This can be any other version of PHP which is compiled with FCGI support.
exec /usr/bin/php5-cgi

and save and make file executable:

chmod +x php-fcgi-wrapper

create an other folder name conf in this home udon.

mkdir /home/udon/conf
cd /home/udon/conf

Create file php.ini,

nano php.ini

with content:

display_errors = On

Go to home udon and create folder name public_html.

cd /home/udon
mkdir public_html

Create a phpinfo file in public_html,

cd public_html
nano phpinfo.php

with content:

cd public_html
nano phpinfo.php

Change ownership to udon.

chown -R udon:udon /home/udon/

Setting up Virtualhost:

nano /etc/apache2/sites-available/

with content:

<VirtualHost *:80>
DocumentRoot /home/udon/public_html
SuexecUserGroup udon udon
ErrorLog /var/log/apache2/udon-error_log
LogLevel debug
CustomLog /var/log/apache2/udon-access_log combined
<Directory />
Options FollowSymLinks
AllowOverride All
Require all granted


AddHandler php-fcgi .php
Action php-fcgi /fcgi-bin/php-fcgi-wrapper

# FastCgiExternalServer /var/www/cgi-bin/php5-default_php538 -socket /var/run/php5-fpm.sock -pass-header Authorization
# 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/ /home/udon/cgi-bin/php5-default/

# Turn on the fcgid-script handler for all files within the alias "/fcgi-bin/"
<Location /fcgi-bin/>
SetHandler fcgid-script
Options +ExecCGI
RewriteEngine On
RewriteRule ^/fcgi-bin/[^/]*$ / [PT]

Enable site:


Disable module php5:

a2dismod php5

Enable modules:

a2enmod suexec actions rewrite

Restart service apache2.

service apache2 restart

sekian dari saya terima kasih

2 thoughts on “Install Apache2 with FastCGI in Ubuntu Server 14.04

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.