Home > Debian, docs, error, fedora, GNU/Linux, install, nginx, Opensuse, php-fpm, server, Web server > Install PHP-FPM pada Nginx 0.7.6 dari source

Install PHP-FPM pada Nginx 0.7.6 dari source


php-fastcgi

php-fastcgi

Setelah pada postingan sebelum nya, menginstall nginx dari source. Pada kali ini kita akan mencoba install PHP-FPM. Mengapa PHP-FPM ??? atau PHP-FPM itu apa sih ?? . tau ach…. gelap nich .. :mrgreen: .. baca di sini untuk penjelasan lengkapnya.

oke lah. langkah pertama.

Compile PHP:

Donlot paket dan ekstrak

# wget http://id.php.net/get/php-5.3.0.tar.gz/from/this/mirror
# tar -xzvf php-5.3.0.tar.gz
# wget http://php-fpm.org/downloads/php-5.3.0-fpm-0.5.12.diff.gz

Install patch untuk patching php.

# zypper install patch

Patching lalu configure

# gzip -cd php-5.3.0-fpm-0.5.12.diff.gz | patch -d php-5.3.0 -p1
# cd php-5.3.0/
# ./configure --enable-fastcgi --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --disable-pdo --with-curl --disable-debug --enable-pic --disable-rpath --enable-inline-optimization --with-bz2=/usr/local/sbin --with-xml --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-xslt --enable-memcache --enable-zip --with-pcre-regex

make, make test lalu make install

# make
# make test
# make all install

Setelah sukses make install jalankan perintah berikut:

# /usr/local/src/php-5.3.0/build/shtool install -c ext/phar/phar.phar /usr/local/bin
# ln -s -f /usr/local/bin/phar.phar /usr/local/bin/phar

Install module extention via PECL

# pecl install memcache
# pecl install apc
# pecl install syck-beta

Configuration PHP:

Kopi konfigurasi php.ini-production ke /usr/local/lib/php.ini

# cd ../php-5.3.0/
# cp php.ini-production /usr/local/lib/php.ini

Buat direktori untuk linking konfigurasi php

# mkdir /etc/php/

linking php.ini dan php-fpm.conf

# ln -s /usr/local/lib/php.ini /etc/php/php.ini
# ln -s /usr/local/etc/php-fpm.conf /etc/php/php-fpm.conf

Configurasi php-fpm.conf

# vi /etc/php/php-fpm.conf
<value name="owner">nobody</value>
<value name="group">nobody</value>
<value name="user">nobody</value>
<value name="group">nobody</value>

Config Nginx

linking direktori conf nginx ke /etc

# ln -s /usr/local/nginx/conf /etc/nginx

konfigurasi file nginx.conf

# vi /etc/nginx/nginx.conf

Ketik seperti ini

user  nobody;
worker_processes  6;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx_access.log  main;
    error_log	/var/log/nginx_error.log   debug;
    sendfile        on;
    keepalive_timeout  10 10;
    gzip  on;
    gzip_comp_level 1;
    gzip_proxied any;
    gzip_types text/plain text/css application/x-javascript text/xml
application/xml application/xml+rss text/javascript;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.php index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
 	location ~ ^/index.php
        {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME
//usr/local/nginx/html$fastcgi_script_name;
                fastcgi_param PATH_INFO $fastcgi_script_name;
                include /usr/local/nginx/conf/fastcgi_params;
        }
    }
}

Konfigurasi file fastcgi_params

# vi /etc/nginx/fastcgi_params
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;

Bikin Script di init.d (RH based)

# vi /etc/init.d/nginx

ketik seperti ini

#! /bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/nginx/sbin/nginx
NAME=nginx
DESC=nginx
PIDFILE=/usr/local/nginx/logs/$NAME.pid
DAEMON_CONFIG=/usr/local/nginx/conf/nginx.conf
    test -x $DAEMON || exit 0
    set -e
    case "$1" in
      start)
            echo -n "Starting $DESC: "
            start-stop-daemon --start --quiet --pidfile $PIDFILE \
                    --exec $DAEMON
            echo " started"
            ;;
      stop)
            echo -n "Stopping $DESC: "
     if [ -f $PIDFILE ]; then
                    kill -15 `cat $PIDFILE 2>/dev/null`
            fi
            echo " stopped"
            ;;
      restart|force-reload)
            echo -n "Restarting $DESC: "
     if [ -f $PIDFILE ]; then
                    kill -15 `cat $PIDFILE 2>/dev/null`
            fi
            sleep 1
            start-stop-daemon --start --quiet --pidfile $PIDFILE \
                    --exec $DAEMON
            echo " restarted"
            ;;
      status)
            echo "Status $DESC: "
            ps aux | grep -v grep | grep -v /bin/sh | grep $NAME
            ;;
      *)
            N=/etc/init.d/$NAME
            echo "Usage: $N {start|stop|status|restart}" >&2
            exit 1
            ;;
    esac
    exit 0

Testing:

Jalankan php-fpm

# /usr/local/sbin/php-fpm start

lihat apakah sudah running atau belum

# netstat -tulpn | grep 9000

Jalankan script nginx

# chmod a+x /etc/init.d/nginx
# /etc/init.d/nginx start

lihat apakah sudah running atau belum

# netstat -tulpn | grep 80

bikin file index.php di /usr/local/nginx/html/ . isi dengan:

<?php phpinfo(); ?>

Akses ke localhost (127.0.0.1) atau sesuai alamat ip nya.

nginx-php-fpm

nginx-php-fpm

Troubleshooting:

A. ERROR PHP

1. Masalah:

configure: error: XML configuration could not be found

Solusi:

# zypper install libxml2-devel

2. Masalah:
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution

Solusi:
Install bzip2 dari source

# cd ..
# wget http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz
# tar -xzvf bzip2-1.0.5.tar.gz
# cd bzip2-1.0.5/
# make
# make install PREFIX=/usr/local/sbin/

3. Masalah:
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/

Solusi:

zypper install libcurl-devel libmcrypt-devel mhash-devel


B. MEMCACHE

1. Masalah:
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.

Solusi:

# zypper install re2c

2. Masalah:
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
ERROR: `phpize' failed

Solusi:
Install autoconf

# zypper install autoconf

lalu jalankan lagi pecl install memcache

Enable memcache session handler support? [yes] :y <== ketik y
&#91;/sourcecode&#93;

<strong>Hasil:</strong><code>
Build process completed successfully
Installing
'/usr/local/lib/php/extensions/no-debug-non-zts-20090626/memcache.so'
install ok: channel://pecl.php.net/memcache-2.2.5
configuration option "php_ini" is not set to php.ini location
You should add "extension=memcache.so" to php.ini</code>

 

<strong>C. APC</strong>

<strong>1. Masalah:</strong>
<code>Sorry, I was not able to successfully run APXS.  Possible reasons:
1.  Perl is not installed;
2.  Apache was not compiled with DSO support (--enable-module=so);
3.  'apxs' is not in your path.  Try to use --with-apxs=/path/to/apxs
The output of apxs follows
/tmp/pear/temp/APC/configure: line 4061: apxs: command not found
configure: error: Aborting
ERROR: `/tmp/pear/temp/APC/configure --with-apxs' failed
make: *** [php_apc.lo] Error 1</code>

<strong>Solusi:</strong>

# pecl install apc-beta
Enable per request file info about files used from the APC cache [no] : n <== ketik n
Enable spin locks (EXPERIMENTAL) &#91;no&#93; : n <== ketik n
&#91;/sourcecode&#93;

<strong>Hasil:</strong><code>
Build process completed successfully
Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/apc.so'
install ok: channel://pecl.php.net/APC-3.1.3p1
configuration option "php_ini" is not set to php.ini location
You should add "extension=apc.so" to php.ini</code>

 

<strong>D. SYCK</strong>

<strong>1. Masalah:</strong><code>
checking for syck files in default path... not found
configure: error: Please reinstall the syck distribution
ERROR: `/tmp/pear/temp/syck/configure' failed</code>

<strong>Solusi:</strong>
Install syck dari source.


# wget http://files.rubyforge.mmmultiworks.com/syck/syck-0.55.tar.gz
# tar -xzvf syck-0.55.tar.gz
# cd syck-0.55/
# ./configure
# make
# make install

Hasil:
Build process completed successfully
Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/syck.so'
install ok: channel://pecl.php.net/syck-0.9.3
configuration option "php_ini" is not set to php.ini location
You should add "extension=syck.so" to php.ini

Referensi:

1. Nginx init http://www.magnet-id.com/download/nginx/nginx-daemon
2. Main Tutorial http://interfacelab.com/nginx-php-fpm-apc-awesome/
3. APC Error Bug http://pecl.php.net/bugs/bug.php?id=16078
4. Syck Error Configuration reinstall http://labs.uechoco.com/blog/2008/04/phppeclsyck.html
5. Autoconf http://tunggul.staff.uns.ac.id/2009/01/09/howto-install-eaccelerator-di-freebsd/
6. XML error http://webhostingneeds.com/Configure:_error:_XML_configuration_could_not_be_found

Advertisements
  1. February 24, 2010 at 3:03 am

    thanks dianux 😉

    keep up good work.

    • February 24, 2010 at 12:37 pm

      wew.. ada om widya… :mrgreen: sami2 mas..
      keep up good work to yu.. 😉

  2. June 8, 2012 at 12:49 am

    Is it alright to put a portion of this in my blog if I submit a reference point to this website?

  3. June 21, 2012 at 8:45 pm

    Please message me with some tips on how you made this site look this awesome, Id be appreciative.

  4. June 22, 2012 at 8:18 am

    I Will have to return again when my course load lets up – nonetheless I am taking your Rss feed so i could go through your blog offline. Thanks.

  5. June 22, 2012 at 2:04 pm

    Is it fine to put a portion of this on my personal site if I submit a reference to this web site?

  6. June 24, 2012 at 8:26 am

    I believe that one of your advertisements initiated my internet browser to resize, you might well want to place that on your blacklist.

  7. June 27, 2012 at 6:24 am

    Whenever I at first left a comment I clicked the Notify me whenever new comments are added checkbox and now each time a remark is added I receive 4 messages with the identical comment.

  8. June 27, 2012 at 1:29 pm

    I was wanting to know if you ever considered replacing the design of your web site? Its very well written; I enjoy what youve got to state. But maybe you could create a a bit more in the way of written content so people can connect to it better. You have got a great deal of wording for only having one or two graphics. Maybe you can space it out better?

  9. June 28, 2012 at 8:33 am

    I tried viewing your site on my blackberry and the format does not seem to be correct. Might wanna check it out on WAP as well as it seems most smartphone layouts are not really working with your website.

  10. June 29, 2012 at 6:26 am

    Wanted to drop a remark and let you know your Rss feed isnt working today. I tried adding it to my Yahoo reader account but got absolutely nothing.

  11. July 1, 2012 at 1:39 am

    Please email me with any tips about how you made your website look this good, Id appreciate it!

  12. July 2, 2012 at 8:29 am

    Cool post . Cheers for, posting on my blog mate! I will message you again! I did not know that.

  13. July 2, 2012 at 11:23 am

    The structure for the web site is a bit off in Epiphany. Even So I like your website. I might need to install a normal browser just to enjoy it.

  14. July 3, 2012 at 10:56 pm

    Even though I really like this post, I think there was an punctuational error close to the end of your 3rd sentence.

  15. July 4, 2012 at 9:30 am

    A insightful blog post there mate . Thanks for the post !

  16. July 6, 2012 at 4:35 am

    Hello, I just hopped over to your web site using StumbleUpon. Not somthing I would typically read, but I liked your views none the less. Thank you for creating something well worth browsing.

  17. July 6, 2012 at 5:24 am

    If you could message me with any tips on how you made your blog site look this good, I would be appreciative!

  18. July 6, 2012 at 7:41 am

    Could you email me with any pointers about how you made this site look this good, Id appreciate it.

  19. July 6, 2012 at 9:22 am

    Wanted to drop a remark and let you know your Rss feed is not working today. I tried including it to my Bing reader account and got nothing.

  20. July 7, 2012 at 6:55 pm

    I was basically curious about if you ever considered modifying the page layout of your site? It is very well written; I enjoy what you have got to state. But maybe you can create a little more in the way of written content so people can connect to it better. You have got a great deal of wording for only having one or two pictures. Maybe you could space it out better?

  21. July 8, 2012 at 2:12 am

    The majority of of the remarks on this blog site dont make sense.

  22. July 8, 2012 at 8:17 am

    I was basically wondering if you ever thought of adjusting the design of your site? It is well written; I love what youve got to say. But maybe you can add a little more in the way of content so people might connect to it better. You have got a great deal of wording for only having one or two graphics. Maybe you can space it out better?

  23. July 8, 2012 at 9:04 am

    fairly valuable material, overall I imagine this is worthy of a bookmark, thank you

  24. July 8, 2012 at 8:58 pm

    If you could message me with a few tips about how you made this blog site look this good , Id appreciate it.

  25. July 9, 2012 at 1:42 am

    The look for your web site is a bit off in Epiphany. Even So I like your web site. I may need to install a normal web browser just to enjoy it.

  26. July 9, 2012 at 8:01 am

    Do you have a spam issue on this website; I also am a blogger, and I was asking yourself your scenario; we now have produced some nice approaches and were searching to swap solutions with other people, be sure to shoot me an e-mail if serious.

  27. July 10, 2012 at 1:54 am

    It looks to me that this website doesnt download on a Motorola Droid. Are other people getting the same problem? I enjoy this website and dont want to have to miss it when Im away from my computer.

  28. July 10, 2012 at 2:38 am

    I believe that one of your current advertisements caused my internet browser to resize, you might well need to get that on your blacklist.

  29. July 11, 2012 at 1:29 am

    Im getting a small issue. I cant get my reader to pick-up your rss feed, Im using yahoo reader by the way.

  30. July 11, 2012 at 10:34 pm

    I appreciate your wp format, where did you get a hold of it?

  31. July 12, 2012 at 10:49 am

    As soon as I originally commented I clicked the Notify me whenever new comments are added checkbox and now every time a comment is added I receive four emails with the identical comment.

  32. July 13, 2012 at 1:58 am

    Hello, I just hopped over to your web-site thru StumbleUpon. Not somthing I would generally read, but I liked your thoughts none the less. Thank you for making something worth browsing.

  33. July 13, 2012 at 8:37 am

    I was basically wanting to know if you ever considered switching the page layout of your site? Its very well written; I love what youve got to state. But maybe you can add a little more in the way of written content so people could connect with it better. Youve got an awful lot of wording for only having one or two images. Maybe you can space it out better?

  34. July 14, 2012 at 1:57 am

    Almost all of the commentary on this weblog dont make sense.

  35. mlm
    July 14, 2012 at 9:29 am

    Do youve got a spam problem on this web site; I also am a blogger, and I was wondering your situation; weve got developed some great techniques and we are looking to trade solutions with other folks, be certain to fire me an e-mail if serious.

  36. July 14, 2012 at 12:23 pm

    Wanted to drop a comment and let you know your Feed is not working today. I tried including it to my Google reader account but got absolutely nothing.

  37. July 16, 2012 at 8:24 am

    I tried looking at your site on my new iphone 4 and the format does not seem to be right. Might wanna check it out on WAP as well as it seems most smartphone layouts are not really working with your website.

  38. July 17, 2012 at 2:32 am

    Good Stuff, do you have a myspace profile?

  39. July 17, 2012 at 2:35 am

    Do youve a spam issue on this site; I also am a blogger, and I was asking yourself your situation; weve got developed some great strategies and were looking to swap options with other individuals, be positive to blast me an e-mail if serious.

  40. May 6, 2013 at 2:43 pm

    When someone writes an article he/she retains
    the image of a user in his/her mind that
    how a user can know it. Therefore that’s why this article is amazing. Thanks!

  41. March 8, 2014 at 9:18 pm

    Great post. Really helpful, dude! Thank you

  1. October 30, 2014 at 8:00 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s