{"id":388,"date":"2009-11-06T14:22:40","date_gmt":"2009-11-06T11:22:40","guid":{"rendered":"http:\/\/seriyps.ru\/blog\/?p=388"},"modified":"2011-05-11T22:29:11","modified_gmt":"2011-05-11T19:29:11","slug":"nginx-php-fcgi-na-ubuntu","status":"publish","type":"post","link":"https:\/\/seriyps.com\/blog\/2009\/11\/06\/nginx-php-fcgi-na-ubuntu\/","title":{"rendered":"Nginx + PHP-fcgi \u043d\u0430 Ubuntu"},"content":{"rendered":"<p>\u0415\u0441\u043b\u0438 \u0431\u044b\u0442\u044c \u0442\u043e\u0447\u043d\u044b\u043c, \u043e\u043f\u0438\u0448\u0443 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441 \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b <em>Nginx &lt;-&gt; Apache backend<\/em> \u043d\u0430 <em>Nginx &lt;-&gt; php-fcgi backend<\/em>.<\/p>\n<p>\u0422.\u0435. \u043e\u0431 \u043e\u0442\u043a\u0430\u0437\u0435 \u043e\u0442 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0433\u043e, \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u044f \u0432 \u0432\u0438\u0434\u0435 \u0430\u043f\u0430\u0447\u0430 \u043c\u0435\u0436\u0434\u0443 <strong>Nginx<\/strong> (http \u0441\u0435\u0440\u0432\u0435\u0440) \u0438 <strong>PHP <\/strong>(application \u0441\u0435\u0440\u0432\u0435\u0440)<\/p>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0447\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043c\u044b \u043e\u0431\u043e\u0439\u0434\u0435\u043c\u0441\u044f <span style=\"text-decoration: underline;\">\u0431\u0435\u0437 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/span> \u0447\u0435\u0433\u043e-\u0431\u044b \u0442\u043e \u043d\u0438 \u0431\u044b\u043b\u043e<\/p>\n<p><!--more--><strong>\u0427\u0442\u043e \u0438\u043c\u0435\u0435\u043c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442:<\/strong><\/p>\n<p>\u0418\u043c\u0435\u0435\u0442\u0441\u044f \u0434\u043e\u043c\u0435\u043d \u0441 \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u0430\u043c\u0438, \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 Ubuntu 9.10 \u0441 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c Nginx, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043b\u0443\u0448\u0430\u0435\u0442 80 \u043f\u043e\u0440\u0442, \u0438 \u0410\u043f\u0430\u0447 \u0441 mod-php, \u0432\u0438\u0441\u044f\u0449\u0438\u0439 \u043d\u0430 localhost:8080 (\u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u043a\u0441\u0438-\u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u043d\u0433\u0438\u043d\u043a\u0441\u0430). \u0414\u043b\u044f \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u0430 \u043a \u0430\u043f\u0430\u0447\u0443 \u0432 <em>\/etc\/nginx\/sites-enabled<\/em> \u043b\u0435\u0436\u0438\u0442 \u0441\u0438\u043c\u043b\u0438\u043d\u043a \u043d\u0430 \u0444\u0430\u0439\u043b\u0438\u043a <em>100apache_proxy<\/em> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f:<\/p>\n<pre style=\"overflow: auto;\">server {\r\nlisten       80;\r\nserver_name  <strong>seriyps.ru *.seriyps.ru localhost<\/strong>;\r\naccess_log  \/var\/log\/nginx\/apache_proxy.access.log;\r\nlocation \/ {\r\n\tproxy_pass      http:\/\/localhost:8080;#\u043f\u0440\u043e\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0430\u043f\u0430\u0447\r\n\tproxy_connect_timeout 15;#\u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043e\u0442 \u0430\u043f\u0430\u0447\u0430 - 15 \u0441\u0435\u043a\u0443\u043d\u0434, \u043c\u043e\u0436\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435\r\n\tproxy_redirect  off;\r\n\tproxy_set_header\tHost    $host;#\u0421\u0442\u0430\u0432\u0438\u043c HTTP \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a Host\r\n\tproxy_set_header\tX-Real-IP $remote_addr;#\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a X_Real-Ip \u0442.\u043a. \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 NGINX \u0430 \u0430\u043f\u0430\u0447\u0443 \u0434\u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 IP \u0442\u043e\u043b\u044c\u043a\u043e 172.0.0.1\r\n\tproxy_set_header\tX-Forwarded-For $proxy_add_x_forwarded_for;#\u0442\u043e-\u0436\u0435 \u0441\u0430\u043c\u043e\u0435\r\n}<\/pre>\n<p><strong>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0445\u043e\u0442\u0438\u043c<\/strong>:<\/p>\n<p>\u041f\u041b\u0410\u0412\u041d\u041e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f apache \u043f\u0440\u043e\u0441\u043b\u043e\u0439\u043a\u0438 \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 nginx&lt;-&gt;php-fcgi \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u044f\u043c\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c!<\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 PHP \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 fast-CGI<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0430\u043a\u0435\u0442 php5-cgi (\u043e\u043d \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f PHP \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442 apache)<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo apt-get install php5-cgi<\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0441\u0442\u0430\u0432\u0438\u043c <a href=\"http:\/\/redmine.lighttpd.net\/projects\/spawn-fcgi\" target=\"_blank\">\u043f\u0430\u043a\u0435\u0442\u0438\u043a spawn-fcgi<\/a> \u042d\u0442\u0430 \u0443\u0442\u0438\u043b\u0438\u0442\u043a\u0430 \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f fast-cgi \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo apt-get install spawn-fcgi<\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 <em>php5-fcgi<\/em> \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0447\u0435\u0440\u0435\u0437 <em>spawn-fcgi<\/em><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#!\/bin\/sh\r\n### BEGIN INIT INFO\r\n# Provides:          php5-fcgi\r\n# Required-Start:    $all\r\n# Required-Stop:     $all\r\n# Default-Start:     2 3 4 5\r\n# Default-Stop:      0 1 6\r\n# Short-Description: starts the php5-cgi in fast-cgi mode\r\n# Description:       configure and starts php5-cgi processes in fast-cgi mode using spawn-fcgi\r\n### END INIT INFO\r\n\r\nPATH=\/sbin:\/bin:\/usr\/sbin:\/usr\/bin\r\nSCRIPTNAME=&quot;\/etc\/init.d\/php5-fcgi&quot;\r\n\r\nFCGI_PIDFILE=&quot;\/var\/run\/spawn-php5-fcgi.pid&quot;\r\n## \u0410\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0434\u043e spawn-fcgi\r\nFCGI_DAEMON=&quot;\/usr\/bin\/spawn-fcgi&quot;\r\n\r\n## php \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u0433\u043e \u044e\u0437\u0435\u0440\u0430 \u0438 \u0433\u0440\u0443\u043f\u043f\u0443 (\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u043c\u0438-\u0436\u0435, \u043a\u0430\u043a \u0443 \u0430\u043f\u0430\u0447\u0430)\r\nUSER=www-data\r\nGROUP=www-data\r\n## \u0410\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0434\u043e  php\r\nFCGI_PROGRAM=&quot;\/usr\/bin\/php5-cgi&quot;\r\n## \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 PHP-fcgi, \u0441\u043c http:\/\/redmine.lighttpd.net\/projects\/lighttpd\/wiki\/Docs:PerformanceFastCGI#How-many-PHP-processes-do-I-need\r\nPHP_FCGI_CHILDREN=10\r\n## \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 PHP - fcgi \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\r\nPHP_FCGI_MAX_REQUESTS=1000\r\n## TCP \u043f\u043e\u0440\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u044c php-fcgi\r\nFCGI_PORT=&quot;9000&quot;\r\n## IP \u0430\u0434\u0440\u0435\u0441\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d PHP-fcgi (\u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e)\r\nFCGI_IP=&quot;127.0.0.1&quot;\r\n\r\ntest -x $FCGI_PROGRAM || exit 0\r\ntest -x $FCGI_DAEMON || exit 0\r\n\r\nset -e\r\n\r\nexport PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS\r\n\r\n. \/lib\/lsb\/init-functions\r\n\r\ncase &quot;$1&quot; in\r\n  start)\r\n        log_daemon_msg &quot;Starting spawn-fcgi&quot;\r\n        if ! $FCGI_DAEMON -a $FCGI_IP -p $FCGI_PORT -f $FCGI_PROGRAM -u $USER -g $GROUP -C $PHP_FCGI_CHILDREN -P $FCGI_PIDFILE; then\r\n            log_end_msg 1\r\n        else\r\n            log_end_msg 0\r\n        fi\r\n        RETVAL=$?\r\n  ;;\r\n  stop)\r\n        log_daemon_msg &quot;Killing all spawn-fcgi processes&quot;\r\n\tstart-stop-daemon --stop --pidfile $FCGI_PIDFILE --signal 2 &amp; log_end_msg 0 || log_end_msg 1\r\n        #if killall --signal 2 php5-cgi &gt; \/dev\/null 2 &gt; \/dev\/null; then\r\n        #    log_end_msg 0\r\n        #else\r\n        #    log_end_msg 1\r\n        #fi\r\n        RETVAL=$?\r\n  ;;\r\n  restart|force-reload)\r\n        $0 stop\r\n        #sleep 1\r\n        $0 start\r\n  ;;\r\n  *)\r\n        echo &quot;Usage: $SCRIPTNAME {start|stop|restart|force-reload}&quot; &gt;&amp;2\r\n        exit 1\r\n  ;;\r\nesac\r\n\r\nexit $RETVAL\r\n<\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 &#8211; \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 lighttpd <a href=\"http:\/\/redmine.lighttpd.net\/projects\/lighttpd\/wiki\/ScriptsUbuntu\" target=\"_blank\">http:\/\/redmine.lighttpd.net\/projects\/lighttpd\/wiki\/ScriptsUbuntu<\/a> \u043f\u0440\u0438\u0441\u043f\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 rc.d \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 Ubuntu\/Debian. \u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u043f\u0440\u043e\u0449\u0435 &#8211; \u0441\u043c <a href=\"http:\/\/redmine.lighttpd.net\/projects\/spawn-fcgi\/wiki\/Basic_Ideas\" target=\"_blank\">http:\/\/redmine.lighttpd.net\/projects\/spawn-fcgi\/wiki\/Basic_Ideas<\/a> \u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c PHP \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e<\/p>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u044d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u043a\u0430\u043a <em>\/etc\/init.d\/php5-fcgi<\/em> \u0438 \u0434\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo chmod +x \/etc\/init.d\/php5-fcgi<\/pre>\n<p>\u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 <em>rc.d<\/em> \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 <em>php5-fcgi<\/em> \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo update-rc.d php5-fcgi defaults<\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo service php5-fcgi start<\/pre>\n<p>spawn-fcgi: child spawned successfully: PID: 23620<\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ps xa | grep php5-cgi<\/pre>\n<p>\u0414\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0434\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435<\/p>\n<pre>23620 ?\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ss\u00a0\u00a0\u00a0\u00a0 0:00 \/usr\/bin\/php5-cgi\r\n23622 ?\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 S\u00a0\u00a0\u00a0\u00a0\u00a0 0:00 \/usr\/bin\/php5-cgi\r\n23623 ?\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 S\u00a0\u00a0\u00a0\u00a0\u00a0 0:00 \/usr\/bin\/php5-cgi\r\n23624 ?\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 S\u00a0\u00a0\u00a0\u00a0\u00a0 0:00 \/usr\/bin\/php5-cgi\r\n23625 ?\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 S\u00a0\u00a0\u00a0\u00a0\u00a0 0:00 \/usr\/bin\/php5-cgi\r\n23626 ?\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 S\u00a0\u00a0\u00a0\u00a0\u00a0 0:00 \/usr\/bin\/php5-cgi\r\n23627 ?\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 S\u00a0\u00a0\u00a0\u00a0\u00a0 0:00 \/usr\/bin\/php5-cgi\r\n23628 ?\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 S\u00a0\u00a0\u00a0\u00a0\u00a0 0:00 \/usr\/bin\/php5-cgi\r\n23629 ?\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 S\u00a0\u00a0\u00a0\u00a0\u00a0 0:00 \/usr\/bin\/php5-cgi\r\n23630 ?\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 S\u00a0\u00a0\u00a0\u00a0\u00a0 0:00 \/usr\/bin\/php5-cgi\r\n23631 ?\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 S\u00a0\u00a0\u00a0\u00a0\u00a0 0:00 \/usr\/bin\/php5-cgi<\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0442\u043e-\u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0437\u043d\u0430\u0447\u0438\u0442, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0432\u0441\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e! \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 <em>23620 ?\u00a0Ss 0:00 \/usr\/bin\/php5-cgi<\/em> &#8211; \u044d\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u043c\u0430\u0441\u0442\u0435\u0440-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u043c \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 <em>php5-cgi<\/em>. \u0423\u0431\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e &#8211; \u0443\u0431\u0438\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b <em>php5-cgi<\/em>.<br \/>\n\u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430!<\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Nginx \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 php-fcgi<\/h2>\n<p>\u0422\u0443\u0442 \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e (\u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c url-rewrite \u043f\u0440\u0430\u0432\u0438\u043b\u0430).<br \/>\n\u0412 \u043f\u0430\u043f\u043e\u0447\u043a\u0435 <em>\/etc\/nginx\/sites-available<\/em> \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b\u0438\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <em><strong>20yourdomain.com<\/strong><\/em> \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f:<\/p>\n<pre>#\/etc\/nginx\/sites-available\/<strong>20yourdomain.com<\/strong>\r\nserver {\r\n\tlisten   80;\r\n\tserver_name  <strong>yourdomain.com<\/strong>;\r\n\r\n\taccess_log  \/var\/log\/nginx\/<strong>yourdomain_com<\/strong>.log;\r\n\troot   \/var\/www\/<strong>yourdomain.com<\/strong>;\r\n\tindex  index.php index.html index.htm;\r\n\r\n\t# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9090\r\n\t#\r\n\tlocation ~ \\.php$ {\r\n\t\tfastcgi_pass   127.0.0.1:9000;\r\n\t\tfastcgi_index  index.php;\r\n\t\tfastcgi_param  SCRIPT_FILENAME  \/var\/www\/<strong>yourdomain.com<\/strong>$fastcgi_script_name;\r\n\t\tinclude fastcgi_params;\r\n\t}\r\n\t# deny access to .htaccess files, if Apache's document root\r\n\t# concurs with nginx's one\r\n\tlocation ~ \/\\.ht {\r\n\t\tdeny  all;\r\n\t}\r\n\r\n}<\/pre>\n<p>(\u043c\u0435\u0441\u0442\u0430, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 <strong>\u0436\u0438\u0440\u043d\u044b\u043c \u0448\u0440\u0438\u0444\u0442\u043e\u043c<\/strong> \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0432\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435)<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430 \u043d\u0435\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u0432 <em>\/etc\/nginx\/sites-enabled<\/em><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo ln -s \/etc\/nginx\/sites-available\/&lt;strong&gt;20yourdomain.com &lt;\/strong&gt;\/etc\/nginx\/sites-enabled\/&lt;strong&gt;20yourdomain.com&lt;\/strong&gt;<\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0430<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo service nginx configtest<\/pre>\n<p>Testing nginx configuration: the configuration file \/etc\/nginx\/nginx.conf syntax is ok<br \/>\nconfiguration file \/etc\/nginx\/nginx.conf test is successful<br \/>\nnginx.<\/p>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e! \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c Nginx<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo service nginx restart<\/pre>\n<p>\u0438 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0435\u043c\u0441\u044f! \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0434\u0435\u043b\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u0443 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u0430, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 URL-rewrite \u0438 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0435\u043c\u0441\u044f \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0415\u0441\u043b\u0438 \u0431\u044b\u0442\u044c \u0442\u043e\u0447\u043d\u044b\u043c, \u043e\u043f\u0438\u0448\u0443 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441 \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b Nginx &lt;-&gt; Apache backend \u043d\u0430 Nginx &lt;-&gt; php-fcgi backend. \u0422.\u0435. \u043e\u0431 \u043e\u0442\u043a\u0430\u0437\u0435 \u043e\u0442 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0433\u043e, \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u044f \u0432 \u0432\u0438\u0434\u0435 \u0430\u043f\u0430\u0447\u0430 \u043c\u0435\u0436\u0434\u0443 Nginx (http \u0441\u0435\u0440\u0432\u0435\u0440) \u0438 PHP (application \u0441\u0435\u0440\u0432\u0435\u0440) \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0447\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043c\u044b \u043e\u0431\u043e\u0439\u0434\u0435\u043c\u0441\u044f \u0431\u0435\u0437 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0447\u0435\u0433\u043e-\u0431\u044b \u0442\u043e \u043d\u0438 \u0431\u044b\u043b\u043e<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[52,134,248,135,136,122],"class_list":["post-388","post","type-post","status-publish","format-standard","hentry","category-linux","tag-apache","tag-nginx","tag-php","tag-php-cgi","tag-php5-fcgi","tag-server"],"_links":{"self":[{"href":"https:\/\/seriyps.com\/blog\/wp-json\/wp\/v2\/posts\/388","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seriyps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seriyps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seriyps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seriyps.com\/blog\/wp-json\/wp\/v2\/comments?post=388"}],"version-history":[{"count":20,"href":"https:\/\/seriyps.com\/blog\/wp-json\/wp\/v2\/posts\/388\/revisions"}],"predecessor-version":[{"id":402,"href":"https:\/\/seriyps.com\/blog\/wp-json\/wp\/v2\/posts\/388\/revisions\/402"}],"wp:attachment":[{"href":"https:\/\/seriyps.com\/blog\/wp-json\/wp\/v2\/media?parent=388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seriyps.com\/blog\/wp-json\/wp\/v2\/categories?post=388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seriyps.com\/blog\/wp-json\/wp\/v2\/tags?post=388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}