{"id":573,"date":"2009-08-17T03:12:52","date_gmt":"2009-08-16T20:12:52","guid":{"rendered":"http:\/\/adityo.blog.binusian.org\/?p=573"},"modified":"2009-08-17T03:21:13","modified_gmt":"2009-08-16T20:21:13","slug":"how-to-install-php-fpm-nginx-on-opensuse-110","status":"publish","type":"post","link":"https:\/\/adityo.blog.binusian.org\/?p=573","title":{"rendered":"How to install PHP-fpm + Nginx on openSUSE 11.0"},"content":{"rendered":"<h4><span style=\"font-size: larger;\">What is Nginx ?<\/span><\/h4>\n<p><span style=\"font-size: larger;\">nginx (pronounced as &#8220;engine X&#8221;) is a lightweight, high performance web server\/reverse proxy and e-mail (IMAP\/POP3) proxy, licensed under a BSD-like license.<\/span><\/p>\n<h4><span style=\"font-size: larger;\">What is PHP-FPM ?<\/span><\/h4>\n<p><span style=\"font-size: larger;\">PHP-FPM is a patch for PHP4\/5 to greatly improve PHP\u2019s FastCGI SAPI capabilities and administration. This means that you don\u2019t install php through your distribution\u2019s package manager, but rather download the package from the PHP-website, and the patch from another site. You patch up the sourcecode, compile things, and get it started. <\/span><\/p>\n<p><span style=\"font-size: larger;\">The following is a comparison chart of problems and how php-fpm handles them, when enabled with the FastCGI SAPI:<\/span><\/p>\n<table style=\"height: 1106px;\" border=\"1\" cellspacing=\"0\" cellpadding=\"20\" width=\"448\">\n<tbody>\n<tr>\n<th><span style=\"font-size: small;\">Description<\/span><\/th>\n<th><span style=\"font-size: xx-small;\">php \u201cout of the box\u201d<\/span><\/th>\n<th><span style=\"font-size: xx-small;\">spawn-fcgi + spawn-php.sh + daemontools<\/span><\/th>\n<th><span style=\"font-size: xx-small;\">php-fpm<\/span><\/th>\n<\/tr>\n<tr>\n<td><span style=\"font-size: xx-small;\">php daemonization: pid file, log file, setsid(), setuid(), setgid(), chroot()<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(-)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(+)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(+)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-size: xx-small;\">Process Management. Ability to \u201cgraceful\u201d stop and start php workers without losing any queries. The possibility of gradually update the configuration and binary without losing any queries.<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">php4 (-), php5 (only graceful completion)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(-)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(+)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-size: xx-small;\">Restricting ip addresses from which requests can come from a web server<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">php4 (-), php5 (+) (from 5.2.2)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(-)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(+)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-size: xx-small;\">Dynamic number of processes, depending on the load<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(-)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(-)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">TODO<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-size: xx-small;\">Starting the workers with different uid\/gid\/chroot\/environment and different php.ini option. You do not need a safe mode!<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(-)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(-)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(+)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-size: xx-small;\">Logging stdout &amp; stderr business processes<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(-)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(-)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(+)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-size: xx-small;\">Emergency restart all the processes in the event of accidental destruction of shared memory opcode cache, if used accelerator<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(-)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(-)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(+)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-size: xx-small;\">Forcing the completion of process if set_time_limit() fails<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(-)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(-)<\/span><\/td>\n<td><span style=\"font-size: xx-small;\">(+)<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4><span style=\"font-size: larger;\">Installation <\/span><\/h4>\n<p><span style=\"font-size: larger;\">1. Install some dependecies first<br \/>\n# yast2 &#8211;install gcc libjpeg-devel libpng-devel libmcrypt libmcrypt-devel pcre pcre-devel libcurl-devel\u00a0 libmysqlclient-devel mysql make wget vim<\/span><\/p>\n<p>2. We need to get PHP-sourcecode and php-fpm patch, in this tutorial i use php-5.2.10 and php-5.2.10-fpm-0.5.13<br \/>\n# wget <a title=\"http:\/\/id.php.net\/get\/php-5.2.10.tar.bz2\/from\/us.php.net\/mirror\" href=\"http:\/\/id.php.net\/get\/php-5.2.10.tar.bz2\/from\/us.php.net\/mirror\">http:\/\/id.php.net\/get\/php-5.2.10.tar.bz2\/from\/us.php.net\/mirror<\/a><br \/>\n# wget <a title=\"http:\/\/php-fpm.org\/downloads\/php-5.2.10-fpm-0.5.13.diff.gz\" href=\"http:\/\/php-fpm.org\/downloads\/php-5.2.10-fpm-0.5.13.diff.gz\">http:\/\/php-fpm.org\/downloads\/php-5.2.10-fpm-0.5.13.diff.gz<\/a><\/p>\n<p>3. Extract and run the patch<br \/>\n# tar xvf php-5.2.10.tar.bz2<br \/>\n# gzip -cd php-5.2.10-fpm-0.5.13.diff.gz | patch -d php-5.2.10 -p1<\/p>\n<p>4. Configure and compile\u00a0 php-5.2.10 and php-5.2.10-fpm-0.5.13 patch<\/p>\n<p># cd php-5.2.10<br \/>\n#\u00a0 .\/configure &#8211;enable-fastcgi &#8211;enable-fpm &#8211;with-mcrypt &#8211;enable-mbstring &#8211;enable-mysql &#8211;with-mysql=\/usr\/include\/mysql &#8211;with-mysql-sock=\/var\/lib\/mysql\/mysql.sock &#8211;with-curl &#8211;with-sockets &#8211;with-gd &#8211;with-zlib &#8211;with-iconv &#8211;with-dom &#8211;with-jpeg-dir=\/usr\/lib<br \/>\n#\u00a0 make<br \/>\n#\u00a0 make install<\/p>\n<p>5. Installing Init Script for PHP-FPM<br \/>\n# cd \/etc\/init.d\/<br \/>\n# ln -s \/usr\/local\/sbin\/php-fpm php-fpm<\/p>\n<p>now make the nginx start on boot<\/p>\n<p># chkconfig &#8211;add php-fpm<br \/>\n# chkconfig &#8211;level 345 php-fpm on<\/p>\n<p>6. Installing and configure nginx, when i write this tutorial the latest stable versions are nginx-0.7.61 you can go to <a title=\"http:\/\/nginx.net\/\" href=\"http:\/\/nginx.net\/\">http:\/\/nginx.net\/<\/a> for latest nginx sourcode<br \/>\n#\u00a0 wget <a title=\"http:\/\/sysoev.ru\/nginx\/nginx-0.7.61.tar.gz\" href=\"http:\/\/sysoev.ru\/nginx\/nginx-0.7.61.tar.gz\">http:\/\/sysoev.ru\/nginx\/nginx-0.7.61.tar.gz<\/a><br \/>\n#\u00a0 tar xvf <a title=\"http:\/\/sysoev.ru\/nginx\/nginx-0.7.61.tar.gz\" href=\"http:\/\/sysoev.ru\/nginx\/nginx-0.7.61.tar.gz\">http:\/\/sysoev.ru\/nginx\/nginx-0.7.61.tar.gz<\/a><br \/>\n#\u00a0 cd nginx-0.7.61<br \/>\n#\u00a0 .\/configure &#8211;pid-path=\/usr\/local\/nginx\/logs\/nginx.pid &#8211;sbin-path=\/usr\/local\/sbin\/nginx &#8211;with-md5=\/usr\/lib &#8211;with-sha1=\/usr\/lib &#8211;with-http_ssl_module &#8211;with-http_dav_module &#8211;without-mail_pop3_module &#8211;without-mail_imap_module &#8211;without-mail_smtp_module<\/p>\n<p>you should see this on the end of configuration<\/p>\n<p>nginx path prefix: &#8220;\/usr\/local\/nginx&#8221;<br \/>\nnginx binary file: &#8220;\/usr\/local\/sbin\/nginx&#8221;<br \/>\nnginx configuration prefix: &#8220;\/usr\/local\/nginx\/conf&#8221;<br \/>\nnginx configuration file: &#8220;\/usr\/local\/nginx\/conf\/nginx.conf&#8221;<br \/>\nnginx pid file: &#8220;\/usr\/local\/nginx\/logs\/nginx.pid&#8221;<br \/>\nnginx error log file: &#8220;\/usr\/local\/nginx\/logs\/error.log&#8221;<br \/>\nnginx http access log file: &#8220;\/usr\/local\/nginx\/logs\/access.log&#8221;<br \/>\nnginx http client request body temporary files: &#8220;client_body_temp&#8221;<br \/>\nnginx http proxy temporary files: &#8220;proxy_temp&#8221;<br \/>\nnginx http fastcgi temporary files: &#8220;fastcgi_temp&#8221;<\/p>\n<p># make<br \/>\n# make install<\/p>\n<p>now make the nginx start on boot<\/p>\n<p># chkconfig &#8211;add nginx<br \/>\n# chkconfig &#8211;level 345 nginx on<\/p>\n<p>7. Installing Nginx Daemon for openSUSE 11.0, you can copy paste this script to your \/etc\/init.d\/nginx<\/p>\n<p># vim \/etc\/init.d\/nginx<\/p>\n<p>#! \/bin\/sh<\/p>\n<p>PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/sbin:\/bin:\/usr\/sbin:\/usr\/bin<br \/>\nDAEMON=\/usr\/local\/sbin\/nginx<br \/>\nNAME=nginx<br \/>\nDESC=nginx<br \/>\nPIDFILE=\/usr\/local\/nginx\/logs\/$NAME.pid<br \/>\nDAEMON_CONFIG=\/usr\/local\/nginx\/conf\/nginx.conf<\/p>\n<p>test -x $DAEMON || exit 0<\/p>\n<p>set -e<\/p>\n<p>case &#8220;$1&#8221; in<br \/>\nstart)<br \/>\necho -n &#8220;Starting $DESC: &#8221;<br \/>\nstart-stop-daemon &#8211;start &#8211;quiet &#8211;pidfile $PIDFILE \\<br \/>\n&#8211;exec $DAEMON<br \/>\necho &#8221; started&#8221;<br \/>\n;;<br \/>\nstop)<br \/>\necho -n &#8220;Stopping $DESC: &#8221;<br \/>\nif [ -f $PIDFILE ]; then<br \/>\nkill -15 `cat $PIDFILE 2&gt;\/dev\/null`<br \/>\nfi<br \/>\necho &#8221; stopped&#8221;<br \/>\n;;<br \/>\nrestart|force-reload)<br \/>\necho -n &#8220;Restarting $DESC: &#8221;<br \/>\nif [ -f $PIDFILE ]; then<br \/>\nkill -15 `cat $PIDFILE 2&gt;\/dev\/null`<br \/>\nfi<br \/>\nsleep 1<br \/>\nstart-stop-daemon &#8211;start &#8211;quiet &#8211;pidfile $PIDFILE \\<br \/>\n&#8211;exec $DAEMON<br \/>\necho &#8221; restarted&#8221;<br \/>\n;;<br \/>\nstatus)<br \/>\necho &#8220;Status $DESC: &#8221;<br \/>\nps aux | grep -v grep | grep -v \/bin\/sh | grep $NAME<br \/>\n;;<br \/>\n*)<br \/>\nN=\/etc\/init.d\/$NAME<br \/>\necho &#8220;Usage: $N {start|stop|status|restart}&#8221; &gt;&amp;2<br \/>\nexit 1<br \/>\n;;<br \/>\nesac<\/p>\n<p>exit 0<\/p>\n<p>8.\u00a0 Nginx\u00a0 configuration<\/p>\n<p>&#8211; Go to nginx.conf on \/usr\/local\/nginx\/conf\/nginx.conf and\u00a0 remove the #<\/p>\n<p>user\u00a0 nobody;<\/p>\n<p>&#8211; Go to\/usr\/local\/etc\/php-fpm.conf<\/p>\n<p># vi \/usr\/local\/etc\/php-fpm.conf<\/p>\n<p>Find these two lines. Remove the Comments (arrows)<\/p>\n<p>&lt;!&#8211;\u00a0 &lt;value name=&#8221;user&#8221;&gt;nobody&lt;\/value&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt;<br \/>\n&lt;!&#8211;\u00a0 &lt;value name=&#8221;group&#8221;&gt;nobody&lt;\/value&gt;\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt;<\/p>\n<p>If you don\u2019t do this, starting php-fpm will show this error.<\/p>\n<p>fpm_unix_conf_wp(), line 124: please specify user and group othe<\/p>\n<p>&#8211; Go to nginx configuration file: \u201c\/usr\/local\/nginx\/conf\/nginx.conf\u201d , and add the php configuration<\/p>\n<p>location ~ \\.php$ {<br \/>\nroot \/usr\/share\/nginx\/html; # itmena the root of the coument are located on \/usr\/share\/nginx\/html<br \/>\nfastcgi_pass 127.0.0.1:9000;<br \/>\nfastcgi_index index.php;<br \/>\nfastcgi_param SCRIPT_FILENAME \/usr\/share\/nginx\/html$fastcgi_script_name;<br \/>\ninclude fastcgi_params;<br \/>\n}<\/p>\n<p>to make index.php to be your web default page add index.php on<\/p>\n<p>location \/ {<br \/>\nroot \/usr\/share\/nginx\/html;<br \/>\nindex index.php index.html index.htm;<br \/>\n}<\/p>\n<p>&#8211; Go to \/usr\/share\/nginx\/html and create php files<\/p>\n<p># mkdir -p \/usr\/share\/nginx\/html<br \/>\n# vi index.php<br \/>\n&lt;?php\u00a0 phpinfo();\u00a0 ?&gt;<\/p>\n<p>9. Start the nginx and php-fpm<br \/>\n# \/etc\/init.d\/php-fpm start<\/p>\n<p># \/etc\/init.d\/nginx start<\/p>\n<p>10. You should go to your domain <a title=\"http:\/\/localhost\/index.php\" href=\"http:\/\/localhost\/index.php\">http:\/\/localhost\/index.php<\/a> or server address and see the phpinfo<\/p>\n<p><a href=\"http:\/\/adityo.blog.binusian.org\/files\/2009\/08\/nginx.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-574\" title=\"nginx\" src=\"http:\/\/adityo.blog.binusian.org\/files\/2009\/08\/nginx.png\" alt=\"nginx\" width=\"544\" height=\"220\" srcset=\"https:\/\/adityo.blog.binusian.org\/files\/2009\/08\/nginx.png 604w, https:\/\/adityo.blog.binusian.org\/files\/2009\/08\/nginx-300x121.png 300w\" sizes=\"auto, (max-width: 544px) 100vw, 544px\" \/><\/a><a href=\"http:\/\/adityo.blog.binusian.org\/files\/2009\/08\/nginx1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-575\" title=\"nginx1\" src=\"http:\/\/adityo.blog.binusian.org\/files\/2009\/08\/nginx1.png\" alt=\"nginx1\" width=\"543\" height=\"238\" srcset=\"https:\/\/adityo.blog.binusian.org\/files\/2009\/08\/nginx1.png 603w, https:\/\/adityo.blog.binusian.org\/files\/2009\/08\/nginx1-300x131.png 300w\" sizes=\"auto, (max-width: 543px) 100vw, 543px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Nginx ? nginx (pronounced as &#8220;engine X&#8221;) is a lightweight, high performance web server\/reverse proxy and e-mail (IMAP\/POP3) proxy, licensed under a BSD-like license. What is PHP-FPM ? PHP-FPM is a patch for PHP4\/5 to greatly improve PHP\u2019s FastCGI SAPI capabilities and administration. This means that you don\u2019t install php through your distribution\u2019s [&hellip;]<\/p>\n","protected":false},"author":386,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1887,2640],"tags":[2859],"class_list":["post-573","post","type-post","status-publish","format-standard","hentry","category-nginx","category-opensuse","tag-php-fpm-nginx-on-opensuse-110"],"_links":{"self":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/573","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/users\/386"}],"replies":[{"embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=573"}],"version-history":[{"count":6,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/573\/revisions"}],"predecessor-version":[{"id":577,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/573\/revisions\/577"}],"wp:attachment":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}