{"id":4718,"date":"2011-06-03T14:35:00","date_gmt":"2011-06-03T14:35:00","guid":{"rendered":"https:\/\/blog-staging.wowrack.co.id\/2011\/06\/03\/konfigurasi-php-fastcgi-pada-apache\/"},"modified":"2024-02-06T14:00:58","modified_gmt":"2024-02-06T07:00:58","slug":"konfigurasi-php-fastcgi-pada-apache","status":"publish","type":"post","link":"https:\/\/www.wowrack.com\/id-id\/blog\/technical-blog-id\/konfigurasi-php-fastcgi-pada-apache\/","title":{"rendered":"Konfigurasi PHP FastCGI pada Apache"},"content":{"rendered":"<p>FastCGI merupakan sebuah protokol untuk menjebatani antara program interaktif dengan web server. FastCGI bertujuan untuk mengurangi overhead yang berkaitan dengan interface web server dan program CGI, yang memungkinkan sebuah server untuk menangani beberapa request halaman web dalam suatu waktu.<\/p>\n<p>nginx dan lighttpd memiliki dukungan built-in untuk FastCGI. Untuk web server Apache perlu menggunakan mod_fastcgi atau mod_fcgid<\/p>\n<p>Dalam catatan kali ini, diasumsikan apache dan php sudah terinstall dan berjalan dengan baik. Jika belum, bisa di lihat pada catatan sebelumnya tentang installasi apache dan php.<\/p>\n<div>.:: install mod_fastcgi<\/div>\n<p><\/p>\n<div>pastikan program-program yangdibutuhkan sudah terinstall (httpd-devel and apr-devel required to compile mod_fastcgi)<\/div>\n<p><\/p>\n<pre><br\/>[root@server01 ~] # wget http:\/\/www.fastcgi.com\/dist\/mod_fastcgi-current.tar.gz<br\/>[root@server01 ~] # tar -zxvf mod_fastcgi-current.tar.gz<br\/>[root@server01 ~] # cd mod_fastcgi-2.4.6\/<br\/>[root@server01 mod_fastcgi-2.4.6] # cp Makefile.AP2 Makefile<br\/><\/pre>\n<p>.:: Compile and install mod_fastcgi for 32 bit system, enter:<\/p>\n<pre><br\/>[root@server01 ~] # make top_dir=\/usr\/lib\/httpd<br\/>[root@server01 ~] # make install top_dir=\/usr\/lib\/httpd<br\/><\/pre>\n<p>.:: Compile and install mod_fastcgi for 64 bit system, enter:<\/p>\n<pre><br\/>[root@server01 ~] # make top_dir=\/usr\/lib64\/httpd<br\/>[root@server01 ~] # make install top_dir=\/usr\/lib64\/httpd<br\/><\/pre>\n<p>.:: konfigurasi mod_fastcgi<\/p>\n<pre><br\/>[root@server01 ~] # nano \/etc\/httpd\/conf\/httpd.conf<br\/>###tambahkan baris berikut<br\/>LoadModule fastcgi_module modules\/mod_fastcgi.so<br\/><\/pre>\n<p>.:: simpan dan restart httpd.<br \/>.:: konfigurasi agar php berjalan sebagai fastcgi<br \/>pertama disable mod_php5<\/p>\n<pre><br\/>[root@server01 ~] # mv \/etc\/httpd\/conf.d\/php.conf \/etc\/httpd\/conf.d\/php.conf.disable<br\/><\/pre>\n<p>buat shell script pada direktory \/var\/www\/cgi-bin<\/p>\n<pre><br\/>[root@server01 ~] # nano \/var\/www\/cgi-bin\/php.fcgi<br\/>###isi file sebagai berikut :<br\/>#!\/bin\/bash<br\/># Shell Script To Run PHP5 using mod_fastcgi under Apache 2.x<br\/># Tested under Red Hat Enterprise Linux \/ CentOS 5.x<br\/>### Set PATH ###<br\/>PHP_CGI=\/usr\/bin\/php-cgi<br\/>PHP_FCGI_CHILDREN=4<br\/>PHP_FCGI_MAX_REQUESTS=1000<br\/>### no editing below ###<br\/>export PHP_FCGI_CHILDREN<br\/>export PHP_FCGI_MAX_REQUESTS<br\/>exec $PHP_CGI<br\/><\/pre>\n<p>atur permission file tersebut<\/p>\n<pre><br\/>[root@server01 ~] # chmod +x \/var\/www\/cgi-bin\/php.fcgi<br\/><\/pre>\n<p>.:: modifikasi document root directory. (you need to use AddHandler and Action directives for mod_fastcgi)<\/p>\n<pre><br\/>&lt;Directory \"\/var\/www\/html\"&gt;<br\/>   Options -Indexes FollowSymLinks +ExecCGI<br\/>    AllowOverride AuthConfig FileInfo<br\/>    AddHandler php5-fastcgi .php<br\/>    Action php5-fastcgi \/cgi-bin\/php.fcgi<br\/>    DirectoryIndex index.php index.html<br\/>    Order allow,deny<br\/>    Allow from all<br\/>&lt;\/Directory&gt;<br\/><\/pre>\n<p>keterangan :<br \/><em>AddHandler php5-fastcgi .php<\/em> : mengkonfigurasi Apache agar menangani file php (dalam lingkup direktif) dengan ekstensi tertentu sebagai aplikasi FastCGI.<\/p>\n<p><em>Action php5-fastcgi \/cgi-bin\/php.fcgi<\/em> : Direktif ini akan menambahkan action, dimana akan meng-aktifkan cgi-script ketika triggered by the request. cgi-script merupakan URL-path yang telah dikonfigurasi sebagai CGI script menggunakan ScriptAlias. Dalam contoh kasus di atas, permintaan file dengan ekstensi .php akan ditangani oleh script cgi yaitu \/cgi-bin\/php.fcgi<\/p>\n<p>.:: simpan dan restart httpd.<\/p>\n<p>.:: Berikut contoh untuk konfigurasi pada VirtualHost<\/p>\n<pre><br\/>NameVirtualHost 115.69.218.165:8080<br\/><br\/>&lt;VirtualHost 115.69.218.165:8080&gt;<br\/>        ServerName open.stylekita.com<br\/>        ServerAlias open.stylekita.com<br\/>        DocumentRoot \"\/home\/prayoga\/www\/open.stylekita.com\/htdocs\"<br\/>        CustomLog \"|\/usr\/sbin\/cronolog \/var\/apachelogs\/prayoga\/%Y\/%m\/%d\/open.stylekita.com.access_log\" combined<br\/>        ErrorLog \"|\/usr\/sbin\/cronolog \/var\/apachelogs\/prayoga\/%Y\/%m\/%d\/open.stylekita.com.error_log\"<br\/>        ScriptAlias \/cgi-bin \"\/home\/prayoga\/www\/open.stylekita.com\/cgi-bin\"<br\/><br\/>        &lt;Directory \"\/home\/prayoga\/www\/open.stylekita.com\/htdocs\"&gt;<br\/>               \tOptions -Indexes FollowSymLinks +ExecCGI<br\/>                AllowOverride AuthConfig FileInfo<br\/>                AddHandler php5-fastcgi .php<br\/>                Action php5-fastcgi \/cgi-bin\/php.fcgi<br\/>                DirectoryIndex index.php index.html<br\/>                Order allow,deny<br\/>                Allow from all<br\/>       \t&lt;\/Directory&gt;<br\/>&lt;\/VirtualHost&gt;<br\/><\/pre>\n<p>.:: buat file php.fcgi pada \/home\/prayoga\/www\/namadomain.com\/cgi-bin<\/p>\n<pre><br\/>[root@server01 ~] # nano \/home\/prayoga\/www\/namadomain.com\/cgi-bin\/php.fcgi<br\/><pre><br\/>#!\/bin\/bash<br\/>PHP_CGI=\/usr\/bin\/php-cgi<br\/>PHP_FCGI_CHILDREN=4<br\/>PHP_FCGI_MAX_REQUESTS=1000<br\/>export PHP_FCGI_CHILDREN<br\/>export PHP_FCGI_MAX_REQUESTS<br\/>exec $PHP_CGI<br\/><\/pre>\n<p>.:: set permission<\/p>\n<pre><br\/>[root@server01 ~] # chmod +x \/home\/prayoga\/www\/namadomain.com\/cgi-bin\/php.fcgi<br\/><\/pre>\n<p>.:: restart httpd<\/p>\n<div>Blog Wowrack Indonesia<\/div>\n","protected":false},"excerpt":{"rendered":"<p>FastCGI merupakan sebuah protokol untuk menjebatani antara program interaktif dengan web server. FastCGI bertujuan untuk mengurangi overhead yang berkaitan dengan interface web server dan program CGI, yang memungkinkan sebuah server untuk menangani beberapa request halaman web dalam suatu waktu. nginx dan lighttpd memiliki dukungan built-in untuk FastCGI. Untuk web server Apache perlu menggunakan mod_fastcgi atau [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2252,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"categories":[725,948],"tags":[],"class_list":["post-4718","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technical-blog-id","category-cloud-id","post-wrapper"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.wowrack.com\/id-id\/wp-json\/wp\/v2\/posts\/4718","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wowrack.com\/id-id\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wowrack.com\/id-id\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wowrack.com\/id-id\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wowrack.com\/id-id\/wp-json\/wp\/v2\/comments?post=4718"}],"version-history":[{"count":0,"href":"https:\/\/www.wowrack.com\/id-id\/wp-json\/wp\/v2\/posts\/4718\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wowrack.com\/id-id\/wp-json\/wp\/v2\/media\/2252"}],"wp:attachment":[{"href":"https:\/\/www.wowrack.com\/id-id\/wp-json\/wp\/v2\/media?parent=4718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wowrack.com\/id-id\/wp-json\/wp\/v2\/categories?post=4718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wowrack.com\/id-id\/wp-json\/wp\/v2\/tags?post=4718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}