blog.notmyidea.org/how-to-install-nginx-php-53-on-freebsd.html

88 lines
No EOL
5.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>How to install <span class="caps">NGINX</span> + <span class="caps">PHP</span> 5.3 on&nbsp;FreeBSD. - Alexis Métaireau</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://blog.notmyidea.org/theme/css/main.css" type="text/css" />
<link href="https://blog.notmyidea.org/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="Alexis Métaireau ATOM Feed" />
</head>
<body>
<section id="links">
<li>
<a class="" href="https://blog.notmyidea.org/" id="site-title">Blog</a>
</li>
<li><a class="" href="https://blog.notmyidea.org/pages/projets.html">Projets</a></li>
</section>
<header>
<h1 class="post-title">How to install <span class="caps">NGINX</span> + <span class="caps">PHP</span> 5.3 on&nbsp;FreeBSD.</h1>
<time datetime="2010-10-10T00:00:00+02:00">10 octobre 2010</time>
</header>
<article>
<ul>
<li>
<p>date<br>&nbsp;2010-10-10</p>
</li>
<li>
<p>category<br>&nbsp;tech</p>
</li>
</ul>
<p>I&#8217;ve not managed so far to get completely rid of php, so here&#8217;s a simple
reminder about how to install php on <span class="caps">NGINX</span>, for FreeBSD. Nothing hard,
but that&#8217;s worse to have the piece of configuration somewhere&nbsp;!</p>
<div class="highlight"><pre><span></span><code># update the ports
$ portsnap fetch update
# install php5 port
$ make config-recursive -C /usr/ports/lang/php5-extensions
$ make package-recursive -C /usr/ports/lang/php5-extensions
# install nginx
$ make config-recursive -C /usr/ports/www/nginx-devel
$ make package-recursive -C /usr/ports/www/nginx-devel
</code></pre></div>
<p>Now we have all the dependencies installed, we need to configure a bit
the&nbsp;server.</p>
<p>That&#8217;s a simple thing in fact, but it could be good to have something
that will work without effort over&nbsp;time.</p>
<p>Here&#8217;s a sample of my&nbsp;configuration:</p>
<div class="highlight"><pre><span></span><code><span class="nt">server</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="err">server_name</span><span class="w"> </span><span class="err">ndd</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span><span class="err">set</span><span class="w"> </span><span class="err">$path</span><span class="w"> </span><span class="err">/path/to/your/files</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span><span class="err">root</span><span class="w"> </span><span class="err">$path</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span><span class="err">location</span><span class="w"> </span><span class="err">/</span><span class="w"> </span><span class="err">{</span><span class="w"></span>
<span class="w"> </span><span class="err">index</span><span class="w"> </span><span class="err">index.php</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w"> </span><span class="nt">location</span><span class="w"> </span><span class="o">~*</span><span class="w"> </span><span class="o">^.+.(</span><span class="nt">jpg</span><span class="o">|</span><span class="nt">jpeg</span><span class="o">|</span><span class="nt">gif</span><span class="o">|</span><span class="nt">css</span><span class="o">|</span><span class="nt">png</span><span class="o">|</span><span class="nt">js</span><span class="o">|</span><span class="nt">ico</span><span class="o">|</span><span class="nt">xml</span><span class="o">)$</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="err">access_log</span><span class="w"> </span><span class="err">off</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span><span class="err">expires</span><span class="w"> </span><span class="err">30d</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w"> </span><span class="nt">location</span><span class="w"> </span><span class="o">~</span><span class="w"> </span><span class="p">.</span><span class="nc">php</span><span class="o">$</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="err">fastcgi_param</span><span class="w"> </span><span class="err">SCRIPT_FILENAME</span><span class="w"> </span><span class="err">$path$fastcgi_script_name</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span><span class="err">fastcgi_pass</span><span class="w"> </span><span class="err">backend</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span><span class="err">include</span><span class="w"> </span><span class="err">fastcgi_params</span><span class="p">;</span><span class="w"></span>
<span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="err">}</span><span class="w"></span>
<span class="nt">upstream</span><span class="w"> </span><span class="nt">backend</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w"> </span><span class="err">server</span><span class="w"> </span><span class="err">127.0.0.1:9000</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>And that&#8217;s it&nbsp;!</p>
</article>
</body>
</html>