<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Carlos André Ferrari &#187; linux</title>
	<atom:link href="http://ferrari.eti.br/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://ferrari.eti.br</link>
	<description>php, python, xhtml, html5, css, javascript, jquery, webstandards, linux, nginx</description>
	<lastBuildDate>Thu, 29 Jul 2010 10:05:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP 5.3, PHP-FPM, XCache, Nginx no Debian Lenny &#8211; Performance extrema</title>
		<link>http://ferrari.eti.br/php-5-3-php-fpm-xcache-nginx-no-debian-lenny-performance-extrema/</link>
		<comments>http://ferrari.eti.br/php-5-3-php-fpm-xcache-nginx-no-debian-lenny-performance-extrema/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 14:36:08 +0000</pubDate>
		<dc:creator>caferrari</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[webserver]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php-fpm]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[xcache]]></category>

		<guid isPermaLink="false">http://ferrari.eti.br/?p=112</guid>
		<description><![CDATA[Neste post vou exemplificar os passos para configurar um Webserver que consome poucos recursos e é extremamente rápido no Debian Lenny.
PHP-FPM: é um gerenciador de processos CGI do php, similar ao Phpcgi, porém com várias vantagens como:

Gerenciador de Processos muito eficiente, com capacidade de parar e iniciar seus deamons caso necessário
Possibilidade de Iniciar processos com [...]]]></description>
			<content:encoded><![CDATA[<p>Neste post vou exemplificar os passos para configurar um Webserver que consome poucos recursos e é extremamente rápido no <a href="http://www.debian.org/">Debian Lenny</a>.</p>
<p><a href="http://php-fpm.org/">PHP-FPM</a>: é um gerenciador de processos CGI do php, similar ao Phpcgi, porém com várias vantagens como:</p>
<ul>
<li>Gerenciador de Processos muito eficiente, com capacidade de parar e iniciar seus <a href="http://en.wikipedia.org/wiki/Daemon">deamons</a> caso necessário</li>
<li>Possibilidade de Iniciar processos com usuários diferentes e com arquivos php.ini diferentes</li>
<li>Uploads otimizados</li>
<li>Capacidade de reinicializar processos caso ocorra algum problema</li>
<li>Escalabilidade de processos, ele pode criar mais processos de acordo com a demanda</li>
<li>e muito mais.</li>
</ul>
<p><a href="http://xcache.lighttpd.net/">XCache</a>: é um gerenciador de cache, que armazena os scripts php em <a href="http://en.wikipedia.org/wiki/Opcode">opcode</a> para uso futuro, é extremamente rápido e muito usado no mundo em servidores com alta demanda.</p>
<p><a href="http://nginx.org">Nginx</a>: Conheci este webserver lendo o <a href="http://www.boo-box.com/blog/br/2009/nova-infraestrutura-de-servidores-web-do-sistema-boo-box/">blog da boo-box</a>, ele é um Servidor web e proxy reverso extremamente veloz e que vem ganhando mercado nos últimos meses devido a sua facilidade de uso e capacidade de carga.</p>
<p style="text-align: center;"><a href="http://royal.pingdom.com/2010/01/22/internet-2009-in-numbers/"><img class="aligncenter" title="Market Share de navegadores no final de 2009" src="http://farm5.static.flickr.com/4022/4295546152_b8e094e8cc_o.png" alt="Market Share de navegadores no final de 2009" width="580" height="300" /></a></p>
<p>Para agilizar a configuração, vamos usar alguns pacotes (php5.3, php-fpm) pré compilados e mantidos <a href="http://www.dotdeb.org/">www.dotdeb.org.</a> os testes que eu realzei usando estes pacotes tiveram um ganho de performance enorme.</p>
<h3>Instalação:</h3>
<p>Vamos começar adicionado os repositórios do dotdeb no /etc/apt/sources.list:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">deb http:<span style="color: #000000; font-weight: bold;">//</span>php53.dotdeb.org stable all
deb-src http:<span style="color: #000000; font-weight: bold;">//</span>php53.dotdeb.org stable all</pre></div></div>

<p>Vamos instalar os pacotes e algumas dependências para o nginx:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">aptitude</span> update
<span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php5-fpm php5-xcache php5-gd php5-curl \
php5-mysql php5-pgsql libssl-dev libpcre3-dev build-essential <span style="color: #660033;">-y</span></pre></div></div>

<p>Agora temos o php instalado, vamos compilar o nginx:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> src
<span style="color: #7a0874; font-weight: bold;">cd</span> src
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>nginx.org<span style="color: #000000; font-weight: bold;">/</span>download<span style="color: #000000; font-weight: bold;">/</span>nginx-0.7.64.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-zxvf</span> nginx-0.7.64.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> nginx-0.7.64
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>nginx <span style="color: #660033;">--user</span>=www-data <span style="color: #660033;">--group</span>=www-data \
    --without-mail_pop3_module --without-mail_imap_module \
    --without-mail_smtp_module --with-http_stub_status_module \
    --with-http_ssl_module <span style="color: #660033;">--http-log-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>access.log \
    <span style="color: #660033;">--conf-path</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf  <span style="color: #660033;">--pid-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>nginx.pid
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>Se tudo ocorreu bem, você já tem o nginx instalado, vamos apenas coloca-lo para inicializar automáticamente, crie o arquivo /etc/init.d/nginx e coloque o conteúdo:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#! /bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### BEGIN INIT INFO</span>
<span style="color: #666666; font-style: italic;"># Provides:          nginx</span>
<span style="color: #666666; font-style: italic;"># Required-Start:    $all</span>
<span style="color: #666666; font-style: italic;"># Required-Stop:     $all</span>
<span style="color: #666666; font-style: italic;"># Default-Start:     2 3 4 5</span>
<span style="color: #666666; font-style: italic;"># Default-Stop:      0 1 6</span>
<span style="color: #666666; font-style: italic;"># Short-Description: starts the nginx web server</span>
<span style="color: #666666; font-style: italic;"># Description:       starts nginx using start-stop-daemon</span>
<span style="color: #666666; font-style: italic;">### END INIT INFO</span>
&nbsp;
<span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span>
<span style="color: #007800;">DAEMON</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>nginx
<span style="color: #007800;">NAME</span>=nginx
<span style="color: #007800;">DESC</span>=nginx
&nbsp;
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-x</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Include nginx defaults if available</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>default<span style="color: #000000; font-weight: bold;">/</span>nginx <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
        . <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>default<span style="color: #000000; font-weight: bold;">/</span>nginx
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-e</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
  start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Starting <span style="color: #007800;">$DESC</span>: &quot;</span>
        start-stop-daemon <span style="color: #660033;">--start</span> <span style="color: #660033;">--quiet</span> <span style="color: #660033;">--pidfile</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$NAME</span>.pid \
                <span style="color: #660033;">--exec</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #660033;">--</span> <span style="color: #007800;">$DAEMON_OPTS</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #c20cb9; font-weight: bold;">true</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$NAME</span>.&quot;</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
  stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Stopping <span style="color: #007800;">$DESC</span>: &quot;</span>
        start-stop-daemon <span style="color: #660033;">--stop</span> <span style="color: #660033;">--quiet</span> <span style="color: #660033;">--pidfile</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$NAME</span>.pid \
                <span style="color: #660033;">--exec</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #c20cb9; font-weight: bold;">true</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$NAME</span>.&quot;</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
  restart<span style="color: #000000; font-weight: bold;">|</span>force-reload<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Restarting <span style="color: #007800;">$DESC</span>: &quot;</span>
        start-stop-daemon <span style="color: #660033;">--stop</span> <span style="color: #660033;">--quiet</span> <span style="color: #660033;">--pidfile</span> \
                <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$NAME</span>.pid <span style="color: #660033;">--exec</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #c20cb9; font-weight: bold;">true</span>
        <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">1</span>
        start-stop-daemon <span style="color: #660033;">--start</span> <span style="color: #660033;">--quiet</span> <span style="color: #660033;">--pidfile</span> \
                <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$NAME</span>.pid <span style="color: #660033;">--exec</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #660033;">--</span> <span style="color: #007800;">$DAEMON_OPTS</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #c20cb9; font-weight: bold;">true</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$NAME</span>.&quot;</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
  reload<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Reloading <span style="color: #007800;">$DESC</span> configuration: &quot;</span>
        start-stop-daemon <span style="color: #660033;">--stop</span> <span style="color: #660033;">--signal</span> HUP <span style="color: #660033;">--quiet</span> <span style="color: #660033;">--pidfile</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$NAME</span>.pid \
            <span style="color: #660033;">--exec</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #c20cb9; font-weight: bold;">true</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$NAME</span>.&quot;</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
  configtest<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Testing <span style="color: #007800;">$DESC</span> configuration: &quot;</span>
        <span style="color: #000000; font-weight: bold;">if</span> nginx <span style="color: #660033;">-t</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">then</span>
          <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$NAME</span>.&quot;</span>
        <span style="color: #000000; font-weight: bold;">else</span>
          <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$?</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
  <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: <span style="color: #007800;">$NAME</span> {start|stop|restart|reload|force-reload|configtest}&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p>depois vamos torna-lo executável e atualizar o rc.d:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>nginx
update-rc.d nginx defaults</pre></div></div>

<p>Com isso o processo de instalação está concluído, vamos configurar!</p>
<h3>Configuração do XCache</h3>
<p>Coloque a seguinte configuração no arquivo /etc/php5/fpm/conf.d/xcache.ini:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">; configuration for php xcache module</span>
<span style="color: #000099;">extension</span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">xcache.so</span>
&nbsp;
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>xcache.admin<span style="">&#93;</span></span>
xcache.admin.user <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;secom&quot;</span>
<span style="color: #666666; font-style: italic;">; xcache.admin.pass = md5($your_password)</span>
xcache.admin.pass <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;&quot;</span>
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>xcache<span style="">&#93;</span></span>
<span style="color: #666666; font-style: italic;">; ini only settings, all the values here is default unless explained</span>
<span style="color: #666666; font-style: italic;">; select low level shm/allocator scheme implemenation</span>
xcache.shm_scheme <span style="color: #000066; font-weight:bold;">=</span>        <span style="color: #933;">&quot;mmap&quot;</span>
<span style="color: #666666; font-style: italic;">; to disable: xcache.size=0</span>
<span style="color: #666666; font-style: italic;">; to enable : xcache.size=64M etc (any size &gt; 0) and your system mmap allows</span>
xcache.size  <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">                64M</span>
<span style="color: #666666; font-style: italic;">; set to cpu count (cat /proc/cpuinfo |grep -c processor)</span>
xcache.count <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">                 1</span>
<span style="color: #666666; font-style: italic;">; just a hash hints, you can always store count(items) &gt; slots</span>
xcache.slots <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">                8K</span>
<span style="color: #666666; font-style: italic;">; ttl of the cache item, 0=forever</span>
xcache.ttl   <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">                 0</span>
<span style="color: #666666; font-style: italic;">; interval of gc scanning expired items, 0=no scan, other values is in seconds</span>
xcache.gc_interval <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">           0</span>
<span style="color: #666666; font-style: italic;">; same as aboves but for variable cache</span>
xcache.var_size  <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">            64M</span>
xcache.var_count <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">             1</span>
xcache.var_slots <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">            8K</span>
<span style="color: #666666; font-style: italic;">; default ttl</span>
xcache.var_ttl   <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">             0</span>
xcache.var_maxttl   <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">          0</span>
xcache.var_gc_interval <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">     300</span>
xcache.test <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">                Off</span>
<span style="color: #666666; font-style: italic;">; N/A for /dev/zero</span>
xcache.readonly_protection <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> Off</span>
<span style="color: #666666; font-style: italic;">; for *nix, xcache.mmap_path is a file path, not directory.</span>
<span style="color: #666666; font-style: italic;">; Use something like &quot;/tmp/xcache&quot; if you want to turn on ReadonlyProtection</span>
<span style="color: #666666; font-style: italic;">; 2 group of php won't share the same /tmp/xcache</span>
<span style="color: #666666; font-style: italic;">; for win32, xcache.mmap_path=anonymous map name, not file path</span>
xcache.mmap_path <span style="color: #000066; font-weight:bold;">=</span>    <span style="color: #933;">&quot;/dev/zero&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; leave it blank(disabled) or &quot;/tmp/phpcore/&quot;</span>
<span style="color: #666666; font-style: italic;">; make sure it's writable by php (without checking open_basedir)</span>
xcache.coredump_directory <span style="color: #000066; font-weight:bold;">=</span>   <span style="color: #933;">&quot;&quot;</span>
<span style="color: #666666; font-style: italic;">; per request settings</span>
xcache.cacher <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">               On</span>
xcache.stat   <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">               On</span>
xcache.optimizer <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">            On</span>
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>xcache.coverager<span style="">&#93;</span></span>
<span style="color: #666666; font-style: italic;">; per request settings</span>
<span style="color: #666666; font-style: italic;">; enable coverage data collecting for xcache.coveragedump_directory and xcache_coverager_start/stop/get/clean() functions (will hurt executing performance)</span>
xcache.coverager <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">          Off</span>
<span style="color: #666666; font-style: italic;">; ini only settings</span>
<span style="color: #666666; font-style: italic;">; make sure it's readable (care open_basedir) by coverage viewer script</span>
<span style="color: #666666; font-style: italic;">; requires xcache.coverager=On</span>
xcache.coveragedump_directory <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;&quot;</span></pre></div></div>

<h3>Configuração do Nginx</h3>
<p>Edite o arquivo em /etc/nginx/nginx.conf:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user  www-data;
&nbsp;
<span style="color: #666666; font-style: italic;">#Coloque quantos processos simultaneos, o ideal é um para cada nucleo do sistema:</span>
worker_processes  <span style="color: #000000;">4</span>;
&nbsp;
error_log  <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>error.log;
&nbsp;
events <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #666666; font-style: italic;"># numero de conexões simultaneas por worker</span>
    worker_connections  <span style="color: #000000;">1024</span>;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
http <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    include       mime.types;
    default_type  application<span style="color: #000000; font-weight: bold;">/</span>octet-stream;
&nbsp;
    access_log  <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>access.log;
    sendfile        on;
    <span style="color: #666666; font-style: italic;"># isso é interessante, dá um ganho enorme na navegação, e o nginx aguenta tranquilamente</span>
    keepalive_timeout  <span style="color: #000000;">60</span>;
    tcp_nodelay        on;
&nbsp;
    <span style="color: #666666; font-style: italic;">## Compressão</span>
    <span style="color: #c20cb9; font-weight: bold;">gzip</span> on;
    gzip_http_version <span style="color: #000000;">1.0</span>;
    gzip_comp_level <span style="color: #000000;">2</span>;
    gzip_proxied any;
    gzip_min_length  <span style="color: #000000;">1100</span>;
    gzip_buffers <span style="color: #000000;">16</span> 8k;
    <span style="color: #666666; font-style: italic;"># mime types para zipar e adicionar header de cache</span>
    gzip_types text<span style="color: #000000; font-weight: bold;">/</span>plain text<span style="color: #000000; font-weight: bold;">/</span>css application<span style="color: #000000; font-weight: bold;">/</span>x-javascript text<span style="color: #000000; font-weight: bold;">/</span>xml application<span style="color: #000000; font-weight: bold;">/</span>xml application<span style="color: #000000; font-weight: bold;">/</span>xml+rss text<span style="color: #000000; font-weight: bold;">/</span>javascript image<span style="color: #000000; font-weight: bold;">/</span>gif image<span style="color: #000000; font-weight: bold;">/</span>jpeg image<span style="color: #000000; font-weight: bold;">/</span>png;
    <span style="color: #666666; font-style: italic;"># Desabilita compressão em algumas versões do IE6</span>
    gzip_disable <span style="color: #ff0000;">&quot;MSIE [1-6].(?!.*SV1)&quot;</span>;
    <span style="color: #666666; font-style: italic;"># Impede que servidores proxy mandem versões em gzip do arquivo para os IE6</span>
    gzip_vary on;
&nbsp;
    server <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	root  <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>;
	server_name     localhost;
	listen          <span style="color: #000000;">80</span>;
	location <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
		index  index.php index.html index.htm;
	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">#error_page  404  /404.html;</span>
	<span style="color: #666666; font-style: italic;"># redirect server error pages to the static page /50x.html</span>
	error_page   <span style="color: #000000;">500</span> <span style="color: #000000;">502</span> <span style="color: #000000;">503</span> <span style="color: #000000;">504</span>  <span style="color: #000000; font-weight: bold;">/</span>50x.html;
	location = <span style="color: #000000; font-weight: bold;">/</span>50x.html <span style="color: #7a0874; font-weight: bold;">&#123;</span>
		root   <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>nginx-default;
	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># Joga requisições para arquivos .php para o php-fpm</span>
	location ~ \.php$ <span style="color: #7a0874; font-weight: bold;">&#123;</span>
		fastcgi_pass   127.0.0.1:<span style="color: #000000;">9000</span>;
		fastcgi_index  index.php;
		include fastcgi_params;
        	fastcgi_param SCRIPT_FILENAME <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$fastcgi_script_name</span>;
        	fastcgi_param SERVER_NAME <span style="color: #007800;">$http_host</span>;
        	fastcgi_ignore_client_abort on;
	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<h3>Configuração do php-fpm</h3>
<p>Edite o arquivo: /etc/php5/fpm/php5-fpm.conf e faça os ajustes que você achar interessante, aqui eu só aumento os max_childrens (Numero de clientes CGI) de 5 para 50, esta configuração depende do seu hardware.</p>
<h3>Configuração do Logrotate</h3>
<p>Vamos configurar agora o logrotate para não enchermos os discos com logs do nginx, edite o arquivo /etc/logrotate.d/nginx:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/*</span>.log <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        daily
        missingok
        rotate <span style="color: #000000;">7</span>
        compress
        delaycompress
        notifempty
        create <span style="color: #000000;">640</span> root adm
        sharedscripts
        postrotate
                <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>nginx.pid <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #660033;">-USR1</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>nginx.p$
        endscript
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<h3>Finalizando</h3>
<p>Agora que está tudo configurado, vamos reinicalizar os serviços:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>php5-fpm restart
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>nginx restart</pre></div></div>

<p>crie um arquivo /var/www/index.php e vamos testar o php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
e acesse<span style="color: #339933;">:</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//ip_do_servidor/</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://ferrari.eti.br/php-5-3-php-fpm-xcache-nginx-no-debian-lenny-performance-extrema/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Trabalhando em Grupo em um mesmo branch no git</title>
		<link>http://ferrari.eti.br/trabalhando-em-grupo-em-um-mesmo-branch-no-gi/</link>
		<comments>http://ferrari.eti.br/trabalhando-em-grupo-em-um-mesmo-branch-no-gi/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 19:58:29 +0000</pubDate>
		<dc:creator>caferrari</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://ferrari.eti.br/?p=96</guid>
		<description><![CDATA[Problema: Trabalhar em grupo em um branch que não seja o master usando git.
Solução:
Considerando que o repositório já está ok, e você já está conectado no remote:
Aqui estão os passos para criar o branch que a equipe vai trabalhar

# criar o branch
git checkout -b meu_branch
# enviar o branch para a origem
git push origin meu_branch
# vamos [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problema:</strong> Trabalhar em grupo em um branch que não seja o master usando git.</p>
<p><strong>Solução:</strong><br />
Considerando que o repositório já está ok, e você já está conectado no remote:</p>
<p>Aqui estão os passos para criar o branch que a equipe vai trabalhar</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># criar o branch</span>
git checkout <span style="color: #660033;">-b</span> meu_branch
<span style="color: #666666; font-style: italic;"># enviar o branch para a origem</span>
git push origin meu_branch
<span style="color: #666666; font-style: italic;"># vamos apagar esse branch local agora</span>
git checkout master
git branch <span style="color: #660033;">-D</span> meu_branch</pre></div></div>

<p>Agora cada um que vai trabalhar com este branch pode adicioná-lo assim:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git checkout <span style="color: #660033;">--track</span> <span style="color: #660033;">-b</span> meu_branch origin<span style="color: #000000; font-weight: bold;">/</span>meu_branch</pre></div></div>

<p>Agora todo mundo da equipe pode trabalhar no &#8220;meu_branch&#8221; como se estivesse no master.</p>
<p>e para excluir o branch da origem faça:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git push origin :meu_branch</pre></div></div>

<p>Até a proxima</p>
]]></content:encoded>
			<wfw:commentRss>http://ferrari.eti.br/trabalhando-em-grupo-em-um-mesmo-branch-no-gi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Backup automático do postgres + rsync para outra máquina</title>
		<link>http://ferrari.eti.br/backup-automatico-do-postgres-usando-rsync/</link>
		<comments>http://ferrari.eti.br/backup-automatico-do-postgres-usando-rsync/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 19:16:33 +0000</pubDate>
		<dc:creator>caferrari</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://ferrari.eti.br/?p=91</guid>
		<description><![CDATA[Aqui vou exemplificar a solução que usamos para fazer backup diário dos nossos bancos de dados, este backup é armazenado em um servidor fora do país. para fazer a sincronia, usamos o rsync.
1) Configurando login automático via chaves digitais no nosso servidor de armazenamento
Primeiro você tem que gerar as chaves no seu servidor de banco, [...]]]></description>
			<content:encoded><![CDATA[<p>Aqui vou exemplificar a solução que usamos para fazer backup diário dos nossos bancos de dados, este backup é armazenado em um servidor fora do país. para fazer a sincronia, usamos o <a href="http://samba.anu.edu.au/rsync/">rsync</a>.</p>
<h2>1) Configurando login automático via chaves digitais no nosso servidor de armazenamento</h2>
<p>Primeiro você tem que gerar as chaves no seu servidor de banco, com o usuário do banco de dados, no meu caso é o usuário &#8220;postgres&#8221;.</p>
<p>Você será perguntado por uma senha, deixe em branco e confirme:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">su</span> postgres
$ <span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-t</span> dsa</pre></div></div>

<p>Agora você terá sua chave, copie-a para seu servidor que irá armazenar o backup</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">scp</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_dsa.pub user<span style="color: #000000; font-weight: bold;">@</span>server_bkp:~<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Agora acesse seu servidor via ssh e adicione a chave pública na lista de chaves autorizadas do ssh</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ssh</span> user<span style="color: #000000; font-weight: bold;">@</span>server_bkp
$ <span style="color: #c20cb9; font-weight: bold;">cat</span> ~<span style="color: #000000; font-weight: bold;">/</span>id_dsa.pub <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys</pre></div></div>

<p>Volte para o seu servidor de banco no usuario do postgres e teste:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ssh</span> user<span style="color: #000000; font-weight: bold;">@</span>server_bkp</pre></div></div>

<p>Se você conseguiu acessar o server de backup sem digitar senha, continue no passo 2, senão, de uma revisada. qualquer dúvida comente!.</p>
<h2>2) Instalando o rsync e script de backup</h2>
<p>Para instalar o rsync no debian é bem simples:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> rsync</pre></div></div>

<p>No nosso banco de dados os backups são feitos diariamente as 19 horas, e usamos a pasta /backup para armazena-los:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>backup
$ <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span>backup.sh
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span>backup.sh
$ <span style="color: #c20cb9; font-weight: bold;">chown</span> postgres:postgres <span style="color: #000000; font-weight: bold;">/</span>backup <span style="color: #660033;">-R</span></pre></div></div>

<p>Agora, edite o arquivo backup.sh e coloque o conteúdo:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">PASTA</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>Y<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">DATA</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>Y<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>d<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">DIA</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>d<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$PASTA</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$PASTA</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$DIA</span>
&nbsp;
<span style="color: #007800;">LIST</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>psql <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ print $1}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-vE</span> <span style="color: #ff0000;">'^-|^\(|^List|^N[o|a]me|template[0|1]'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">for</span> d <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$LIST</span>
<span style="color: #000000; font-weight: bold;">do</span>
        pg_dump <span style="color: #660033;">-i</span> <span style="color: #660033;">-h</span> 127.0.0.1 <span style="color: #660033;">-p</span> <span style="color: #000000;">5432</span> <span style="color: #660033;">-U</span> postgres <span style="color: #660033;">-F</span> t <span style="color: #660033;">-b</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;/backup/<span style="color: #007800;">$DATA</span>-<span style="color: #007800;">$d</span>.backup&quot;</span> <span style="color: #007800;">$d</span>
        <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-zcf</span> <span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$PASTA</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$DIA</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$DATA</span>-<span style="color: #007800;">$d</span>.tar.gz <span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$DATA</span>-<span style="color: #007800;">$d</span>.backup
        <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$DATA</span>-<span style="color: #007800;">$d</span>.backup
        <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>rsync <span style="color: #660033;">-avzh</span> <span style="color: #660033;">--delete</span> <span style="color: #660033;">--progress</span> <span style="color: #660033;">--update</span> <span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span> user<span style="color: #000000; font-weight: bold;">@</span>server_bkp:~<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>faça um teste e rode o script com o user do postgres:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">su</span> postgres
$ <span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span>backup.sh</pre></div></div>

<p>Se tudo ocorrer bem, é só adicionar no crontab para executar quando você quiser:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">su</span>
$ pico <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>crontab</pre></div></div>

<p>e adicionar:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">0</span> <span style="color: #000000;">19</span>    <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span>   postgres    <span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span>backup.sh</pre></div></div>

<p>Reinicie o cron e o backup será feito todos os dias as 19 horas.</p>
]]></content:encoded>
			<wfw:commentRss>http://ferrari.eti.br/backup-automatico-do-postgres-usando-rsync/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>nginx &#8211; webserver, proxy reverso e perfeito!</title>
		<link>http://ferrari.eti.br/nginx-webserver-proxy-reverso-e-perfeito/</link>
		<comments>http://ferrari.eti.br/nginx-webserver-proxy-reverso-e-perfeito/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 13:00:25 +0000</pubDate>
		<dc:creator>caferrari</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://ferrari.eti.br/?p=85</guid>
		<description><![CDATA[Nosso departamento é responsável por manter a identidade visual dos sites do Governo do Estado e ainda fazemos os sites dos orgãos que não possuem um.
No trabalho sempre tivemos um constante problema para hospedar nossos sites: hardware!. Contamos hoje com dois incríveis servidores IBM Pentium4 3Ghz com 2gb de memória e HDs scsi, um para [...]]]></description>
			<content:encoded><![CDATA[<p>Nosso <a href="http://web.secom.to.gov.br">departamento</a> é responsável por manter a identidade visual dos sites do <a href="http://to.gov.br">Governo do Estado</a> e ainda fazemos os sites dos orgãos que não possuem um.</p>
<p>No trabalho sempre tivemos um constante problema para hospedar nossos sites: hardware!. Contamos hoje com dois incríveis servidores IBM Pentium4 3Ghz com 2gb de memória e HDs scsi, um para hospedar mais de 40 sites e o outro onde fica postgres com os bancos de dados desses sites.</p>
<p>Ultimamente nosso problema tem crescido bastante, pois, a demanda por sites aumentou e ao mesmo tempo o número de visitas veio aumentando e, como não conseguimos de forma alguma (até agora) investimento em equipamento novo estavamos chegando em uma situação crítica, nosso servidor começava a <del datetime="2009-10-15T12:28:06+00:00">sentar</del> morrer com 200 conexões simultaneas!</p>
<p>Lembrei-me de um <a href="http://www.boo-box.com/blog/br/2009/a-infraestrutura-de-servidores-web-do-sistema-boo-box/">post do boo-box</a> onde vi um servidor web chamado <a href="http://nginx.net">nginx</a> (lê-se engineX) e decidi pesquisar mais e fazer testes em casa onde rodando um servidor e servindo uma página php com um usleep de meio segundo consegui mais de 2000 conexões simultaneas! uau!..</p>
<p style="text-align: center;"><img class="aligncenter" title="nginx_performance" src="../wp-content/uploads/2009/10/nginx_performance.jpg" alt="nginx_performance" width="500" height="331" /></p>
<p>Na segunda feira seguinte, sem pensar muito, fui para o nosso servidor de produção e apliquei a seguinte política de funcionamento:</p>
<ul>
<li>nginx recebe todas as conexões pela porta 80</li>
<li>nginx faz proxy para o apache (que roda em outra porta) se a solicitação for para uma página php</li>
<li>nginx resolve sozinho usando php-cgi caso a requisição seja para:
<ul>
<li>uma fotografia</li>
<li>um arquivo</li>
<li>uma requisição para o webservice</li>
<li>um download do diário oficial</li>
<li>um banner do Governo</li>
<li>a barra padrão do Estado</li>
<li>ou um arquivo na nossa lib</li>
</ul>
</li>
</ul>
<p><del datetime="2009-11-15T10:54:02+00:00">Como resultado da experiência, nossos sites continuam morrendo, porém, aguentando 700 conexões simultaneas e esse valor só é alcançado quando tem muita pesquisa no banco de dados (Dias que sai algo sobre algum concurso público ou muita demissão no Diário Oficial) logo, fica claro, que o problema não é mais do webserver e sim do nosso servidor de Banco. Bom, o nosso webserver atualmente mal chega a 5% de uso, mesmo com as 700 conexões. Só espero conseguir uma maquina nova e mais eficiente para os nossos Bancos de Dados logo!.</del></p>
<p>Update:<br />
Fomos atendidos, estamos com um Xeon Quad Core com 4Gb de memória para o Banco de dados, e, associado com uma otimização do cache do webservice alcançamos mais de 1000 conexões simultâneas sem nenhuma degradação na performance. Detalhe que o webserver ainda é um P4 3ghz com 1gb de memória em que a utilização de processamento não passa de 5%.</p>
]]></content:encoded>
			<wfw:commentRss>http://ferrari.eti.br/nginx-webserver-proxy-reverso-e-perfeito/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Navegando onde não é possível navegar, usando SSH</title>
		<link>http://ferrari.eti.br/navegando-onde-nao-e-possivel-navegar-usando-ssh/</link>
		<comments>http://ferrari.eti.br/navegando-onde-nao-e-possivel-navegar-usando-ssh/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 17:34:09 +0000</pubDate>
		<dc:creator>caferrari</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://ferrari.eti.br/?p=43</guid>
		<description><![CDATA[No trabalho o acesso a qualquer site é bloqueado durante o horario de almoço e após o expediente, hoje pesquisando uma solução com um amigo, descobrimos os Tuneis SSH.
Para criar um túnel desses você precisa ter acesso a alguma maquina em algum lugar (fora do firewall ou proxy de sua rede que bloqueia a navegação) [...]]]></description>
			<content:encoded><![CDATA[<p>No trabalho o acesso a qualquer site é bloqueado durante o horario de almoço e após o expediente, hoje pesquisando uma solução com um amigo, descobrimos os Tuneis SSH.</p>
<p>Para criar um túnel desses você precisa ter acesso a alguma maquina em algum lugar (fora do firewall ou proxy de sua rede que bloqueia a navegação) via SSH, eu possuo contas no dreamhost.com e crio o túnel passando por lá.</p>
<p>o comando para criação do tunel no linux é: ssh -D [usuario]@[servidor], exemplo:</p>
<p><code>ssh -D 9999 eu@meuservidor.com</code></p>
<p>Após digitar a sua senha, o tunel estará criado e funcionando perfeitamente, só que para navegar é necessário configurar os programas (Firefox, IM) para usarem este proxy.</p>
<p>No firefox a opção fica em Editar-&gt;Preferências-&gt;Avançado-&gt;Rede->Conexão-&gt;Configurar, chegando na tela, marque a opção de &#8220;Configuração Manual do Proxy&#8221;, no campo SOCKS, coloque o seu IP (127.0.0.1) e a porta 9999 (definida no exemplo acima) e tudo estará funcionando.</p>
<p>Como eu uso isso sempre, eu configurei meu pc para se autenticar sem pedir senha e coloquei o comando no rc.local:</p>
<p><code>/usr/bin/screen -DmUS proxy /usr/bin/ssh -D 9999 [usuario]@[servidor] &#038;</code></p>
<p>Para finalizar, pelo Putty no Windows é possivel criar tuneis quase que da mesma maneira, é só ir na opção de Tuneis dele e preencher os dados do seu servidor e da porta que você deseja usar</p>
<p>Espero que tenha sido útil.</p>
]]></content:encoded>
			<wfw:commentRss>http://ferrari.eti.br/navegando-onde-nao-e-possivel-navegar-usando-ssh/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
