<?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>Technical Diary &#187; debian</title>
	<atom:link href="http://andriigrytsenko.net/tag/debian/feed/" rel="self" type="application/rss+xml" />
	<link>http://andriigrytsenko.net</link>
	<description>With Andrii Grytsenko</description>
	<lastBuildDate>Sun, 01 Apr 2012 11:10:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Nginx + php-fpm for Debian</title>
		<link>http://andriigrytsenko.net/2011/05/nginx-php-fpm-for-debian/</link>
		<comments>http://andriigrytsenko.net/2011/05/nginx-php-fpm-for-debian/#comments</comments>
		<pubDate>Sat, 28 May 2011 23:35:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[web]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php-fpm]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=944</guid>
		<description><![CDATA[Since I didn&#8217;t found php-fpm package for debian I decided to compile it by myself PHP-FPM If you are going to use PHP 5.3.3 or higher you don&#8217;t need to patch your php sources by PHP-FPM patch anymore. Install all required debian packages: Then download and unzip your php sources and go inside the dir [...]]]></description>
			<content:encoded><![CDATA[<p>Since I didn&#8217;t found php-fpm package for debian I decided to compile it by myself<br />
<span id="more-944"></span></p>
<h2 style="text-align: center;">PHP-FPM</h2>
<p>If you are going to use PHP 5.3.3 or higher you don&#8217;t need to patch your php sources by PHP-FPM patch anymore.<br />
Install all required debian packages:</p>
<pre class="brush: bash; collapse: false; title: ; notranslate"> apt-get install libxml2-dev \
libxml2 libssl-dev libevent-dev libbz2-dev libcurl4-openssl-dev \
libjpeg62-dev libpng12-dev libxpm-dev libfreetype6-dev libt1-dev \
libmcrypt-dev libmysql++-dev libmysqld-dev libmysqlclient-dev \
libxslt1-dev autoconf </pre>
<p>Then download and unzip your php sources and go inside the dir and run <em>buildconf</em>:</p>
<pre class="brush: bash; title: ; notranslate">
./buildconf --force
</pre>
<p>if no errors occur run configure:</p>
<pre class="brush: bash; title: ; notranslate">
./configure \
--prefix=/opt/php5 \
--with-config-file-path=/opt/php5/etc \
--with-curl \
--with-pear \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-xpm-dir \
--with-freetype-dir \
--with-t1lib \
--with-mcrypt \
--with-mhash \
--with-mysql \
--with-mysqli \
--with-pdo-mysql \
--with-openssl \
--with-xmlrpc \
--with-xsl \
--with-bz2 \
--with-gettext \
--with-fpm-user=www-data \
--with-fpm-group=www-data \
--enable-fpm \
--enable-exif \
--enable-wddx \
--enable-zip \
--enable-bcmath \
--enable-calendar \
--enable-ftp \
--enable-mbstring \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--with-libevent-dir=/usr/lib/
</pre>
<p>After finish without errors proceed and compile and install it:</p>
<pre class="brush: bash; title: ; notranslate">
make &amp;&amp; make install
</pre>
<p>The place where you can find all php-fpm related files and default prefix is <strong>/opt/php5</strong>. Now customize your configuration at <strong>/opt/php5/etc/php-fpm.conf</strong></p>
<pre class="brush: bash; title: ; notranslate">
[global]
pid = /opt/php5/var/run/php-fpm.pid
error_log = /opt/php5/var/log/php-fpm.log
log_level = warning
daemonize = yes # set yes to make php work as a daemon

[www]
listen = 127.0.0.1:9000 # the ip and port for php to listen; the port which nginx are going to work with
user = www-data # set user of new php instances(children)
group = www-data
pm = dynamic
pm.max_children = 50 # the maximum concurrent user's request which can be served by php
pm.min_spare_servers = 5 # the minimum idle processes
pm.max_spare_servers = 35
</pre>
<p>More details about how to children and servers work you can get here <a href="http://httpd.apache.org/docs/2.0/mod/mpm_common.html#maxclients">pm.max_children</a>, <a href="http://httpd.apache.org/docs/2.0/mod/mpm_common.html#maxsparethreads">pm.max_spare_servers</a>, <a href="http://httpd.apache.org/docs/2.0/mod/mpm_common.html#minsparethreads">pm.min_spare_servers</a>. Its works for apache just in the same way as for php-fpm.</p>
<p>The next step is making init scripts&#8230; Okay I&#8217;ve done it for you. Just enjoy:</p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/bash

### BEGIN INIT INFO
# Provides:          php-fpm
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php-fpm daemon
# Description:       starts php-fpm daemon
### END INIT INFO

function start {
    $DAEMON -c $CONFIG &amp;&gt; /dev/null
}

function stop {
#    killall php-fpm &amp;&gt; /dev/null
    kill `cat /opt/php5/var/run/php-fpm.pid 2&gt;/dev/null` &amp;&gt; /dev/null
}

. /lib/lsb/init-functions

CONFIG=/opt/php5/etc/php-fpm.conf
DAEMON=/opt/php5/sbin/php-fpm
DESC=&quot;php-fpm daemon&quot;
PID=/opt/php5/var/run/php-fpm.pid

test -x $DAEMON || exit 0
test -d $CONFIG_DIR || exit 0

kill -0 `cat /opt/php5/var/run/php-fpm.pid 2&gt;/dev/null` &amp;&gt; /dev/null
running=$?
case $1 in
start)
    if [ 0 -eq $running ]; then
        echo &quot;Process php-fpm is already running... Nothing to do...&quot;
        exit
    fi
    start &amp;&amp; echo &quot;Process php-fpm was successfully started ... &quot;
;;
stop)
    if [ 0 -ne $running ]; then
        echo &quot;Process php-fpm is not running...&quot;
        exit
    fi
    stop &amp;&amp; echo &quot;Process php-fpm was successfully stoped ... &quot;
;;
restart)
    stop &amp;&amp; start;
    echo &quot;Process php-fpm was successfully restarted ... &quot;
;;
status)
    if [ 0 -eq $running ]; then
        echo &quot;Process php-fpm is running...&quot;
    else
        echo &quot;Process php-fpm is not running...&quot;
    fi
;;
*)
    echo &quot;$0 [start|stop|restart|status]&quot;
;;
esac
</pre>
<p>Then make the stuff work after reboot add it to runlevels:</p>
<pre class="brush: bash; title: ; notranslate">
update-rc.d php-fpm defaults
</pre>
<h2 style="text-align: center;">NGINX</h2>
<p>With nginx installation there is easier way. Simply install it with <strong>apt-get</strong> package manager:</p>
<pre class="brush: bash; title: ; notranslate">apt-get install nginx </pre>
<p>I&#8217;m not going to describe all configuration just mention about php part. To make nginx work with php let it know about. Go to <strong>server</strong> section and add:</p>
<pre class="brush: bash; title: ; notranslate">
location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /var/www/nginx$fastcgi_script_name;
    include        fastcgi_params;
    }
</pre>
<p>The <strong>fastcgi_pass</strong> should be the similar to section <strong>listen</strong> in <strong>php-fpm.conf</strong>.<br />
Directive <strong>fastcgi_param</strong> you need to specify path to your dir where php files are located(i.e. for me its <em>/var/www/nginx</em>)</p>
<h2 style="text-align: center;">VERIFICATION</h2>
<p>To verify that everything work well. Use an old method with <strong>phpinfo</strong> function. Create php file in you htroot direcory with next content:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
phpinfo();
?&gt;
</pre>
<p>Then give the name like <strong>info.php</strong> or whatever(but should with <strong>.php</strong> extension anyway). And try to open in your browser. If works it would be looks like <a href="http://andriigrytsenko.net/info.php">that</a>.</p>
<h2 style="text-align: center;">PROFIT&#8230;</h2>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2011/05/nginx-php-fpm-for-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache as reverse proxy for https server</title>
		<link>http://andriigrytsenko.net/2011/02/apache-as-reverse-proxy-for-https-server/</link>
		<comments>http://andriigrytsenko.net/2011/02/apache-as-reverse-proxy-for-https-server/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 18:56:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[web]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=878</guid>
		<description><![CDATA[Configuration of https server located inside local network. To make local https server visible to outside world. You can make PAT(Port Address Translation) but what if 443 port is already binded? Than you probably want to make a reverse proxy like I did. So to configure apache&#8217;s virtual domain to work with ssl http do [...]]]></description>
			<content:encoded><![CDATA[<p>Configuration of https server located inside local network.<br />
<span id="more-878"></span></p>
<p>To make local https server visible to outside world. You can make PAT(<a href="http://en.wikipedia.org/wiki/Port_address_translation" target="_blank">Port Address Translation</a>) but what if 443 port is already binded? Than you probably want to make a reverse proxy like I did. So to configure apache&#8217;s virtual domain to work with ssl http do several easy steps.</p>
<p>First, you need to load mod_proxy&#8217;s modules into apache and make them available after the restart(for debian there is kind of exotic way to do that):</p>
<pre class="brush: bash; title: ; notranslate">
cd /etc/apache2/mods-enabled
ln -s ../mods-available/proxy.conf proxy.conf
ln -s ../mods-available/proxy.load proxy.load
ln -s ../mods-available/proxy_connect.load proxy_connect.load
ln -s ../mods-available/proxy_http.load proxy_http.load
</pre>
<p>The idea that contents of each file put in <em>mods-enabled</em> becomes a part of main configuration after restart or configuration re-read.</p>
<p>For example, if file contains line like that </p>
<pre class="brush: bash; title: ; notranslate">
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
</pre>
<p>It is the same if we put this line directly in <em>apache2.conf</em> or <em>httpd.conf</em> of whatever you have.</p>
<p>Hope it is pretty clear. Than let&#8217;s move on and create new virtual host configuration file:</p>
<pre class="brush: bash; title: ; notranslate">cd /etc/apache2/sites-available
touch ssl-proxy
</pre>
<p>Here the example how it&#8217;s should be looks like:</p>
<pre class="brush: bash; highlight: [10,11,12]; title: ; notranslate">
&lt;VirtualHost *:443&gt;

  ServerName mail.center.ua
  ProxyRequests Off
  &lt;Proxy *&gt;
    Order deny,allow
    Allow from all
  &lt;/Proxy&gt;

  SSLProxyEngine On
  ProxyPass / https://192.168.1.3/
  ProxyPassReverse / https://192.168.1.3/

  # logging section
  LogLevel info
  ErrorLog /var/log/apache2/ssl-proxy.log
  CustomLog /var/log/apache2/ssl-proxy.log combined

  SSLEngine on
  SSLProtocol all
  SSLCertificateFile /etc/ssl/apache/server.crt
  SSLCertificateKeyFile /etc/ssl/apache/server.key
&lt;/VirtualHost&gt;
</pre>
<p>About <em>SSLCertificateFile</em> and <em>SSLCertificateKeyFile</em> you need to generate keys. Use google to figure how to <a href="http://www.google.com.ua/search?hl=uk&#038;source=hp&#038;q=apache+generate+ssl+certificate&#038;aq=0&#038;aqi=g1&#038;aql=&#038;oq=apache+genera" target="_blank">do it</a>. </p>
<p>The mechanism of virtual host is similar to mods mechanism. So create new link in sites-enabled:</p>
<pre class="brush: bash; title: ; notranslate">ln -s ../sites-available/ssl-proxy ssl-proxy</pre>
<p>And restart apache:</p>
<pre class="brush: bash; title: ; notranslate">/etc/init.d/apache2 restart</pre>
<p>Good look!</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2011/02/apache-as-reverse-proxy-for-https-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Kernel from sources for Debian</title>
		<link>http://andriigrytsenko.net/2009/07/linux-kernel-from-sources-for-debian/</link>
		<comments>http://andriigrytsenko.net/2009/07/linux-kernel-from-sources-for-debian/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 10:41:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[kernel]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=275</guid>
		<description><![CDATA[It&#8217;s useful manual if you want to compile kernel from sources in Debian environment. Get all required software over apt-get: # apt-get install kernel-package ncurses-dev fakeroot wget bzip2 module-init-tools initrd-tools procps Next, get latest linux kernel from kernel.org : # cd /usr/src # wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.tar.bz2 you can also done it over apt-get as well: # [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s useful manual if you want to compile kernel from sources in Debian environment. </p>
<p><span id="more-275"></span></p>
<p>Get all required software over apt-get:</p>
<pre># apt-get install kernel-package ncurses-dev fakeroot wget bzip2 module-init-tools initrd-tools procps</pre>
<p>Next, get latest linux kernel from kernel.org : </p>
<pre># cd /usr/src
# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.tar.bz2</pre>
<p>you can also done it over apt-get as well:</p>
<pre># apt-get install linux-source</pre>
<p>Extract it: </p>
<pre># tar -xjvf linux-2.6.30.tar.bz2</pre>
<p>and make symbolic link pointed out your sources and go there:</p>
<pre># ln -s linux-2.6.30.tar.bz2 linux
# cd linux</pre>
<p>Configure your new kernel with
<pre>make menuconfig</pre>
<p> or
<pre>make oldconfig</pre>
<p> or
<pre># make xconfig</pre>
<p> and so on. </p>
<p>After you will finished. Run :</p>
<pre># make-kpkg clean
# fakeroot make-kpkg --revision=<em>kernel_name-version</em> kernel_image</pre>
<p>Where is <em>kernel_name-version</em> &#8211; kernel name and version(e.g.: custom-1.0).</p>
<p>If compilation done without errors. Go to the /usr/src and install new kernel over
<pre>dpkg</pre>
<p> tool:</p>
<pre># cd /usr/src
# dpkg -i kernel-image-2.6.30.2_custom-1.0_i386.deb</pre>
<p>Create ramdisk  from new kernel : </p>
<pre># cd /boot/
# mkinitramfs -o /boot/initrd.img-2.6.30 2.6.30</pre>
<p>Last one step is loader configuration. I will describe how to do this for two most popular(grub and lilo) loaders. If you have lilo loader just add new section into the /etc/lilo.conf and edit directive <em>default</em>. Like this: </p>
<pre>default=MYKERN
image=/vmlinuz
        label=MYKERN
        read-only
        initrd=/boot/initrd.img-2.6.30</pre>
<p>Now, install new loader at boot sector: </p>
<pre># lilo -c /etc/lilo.conf</pre>
<p>In case of GRUB loader. Put next section into the <em>/boot/grub/menu.lst</em> file: </p>
<pre>title           My Debian GNU/Linux, kernel 2.6.30
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.30 root=/dev/sda1 ro
initrd          /boot/initrd.img-2.6.30</pre>
<p>For GRUB loader no installs is require. </p>
<p>After loader section done well you have to restart you machine:</p>
<pre># reboot</pre>
<p>Check you current kernel version with <em>uname</em> if during your booting time no problems were occurred:
<pre>
# uname -r
2.6.30</pre>
<p>If it&#8217;s matched with you installed kernel version then you done everything right.   </p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/07/linux-kernel-from-sources-for-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to compile VirtualBox module</title>
		<link>http://andriigrytsenko.net/2009/07/how-to-make-virtualbox-module/</link>
		<comments>http://andriigrytsenko.net/2009/07/how-to-make-virtualbox-module/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 08:59:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[virtualbox]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=271</guid>
		<description><![CDATA[In the event of you repository doesn&#8217;t consist VirtualBox&#8217;s kernel module for your current kernel version. In this post I will describe how to make it manually. NOTICE: In my case distro is Debian. My current kernel version is : # uname -r 2.6.30-1-686 Let&#8217;s have a look about virtualbox module : # apt-cache search [...]]]></description>
			<content:encoded><![CDATA[<p>In the event of you repository doesn&#8217;t consist VirtualBox&#8217;s kernel module for your current kernel version. In this post I will describe how to make it manually.<br />
<span id="more-271"></span></p>
<p>NOTICE: In my case distro is Debian.</p>
<p>My current kernel version is :</p>
<pre># uname -r
2.6.30-1-686</pre>
<p>Let&#8217;s  have a look about virtualbox module :</p>
<pre># apt-cache search virtualbox | grep [you_kernel_version]
# </pre>
<p>Nothing was found. </p>
<p>First of all we have to get kernel sources: </p>
<pre># apt-get install linux-source-[you_kernel_version]</pre>
<p>Go to /usr/src and delete symbolic link <em>linux</em> if it exist: </p>
<pre># cd /usr/src
# rm linux </pre>
<p>extract files from archive and make new one linx:</p>
<pre># tar -xjvf linux-source-2.6.30.tar.bz2
# ln -s linux-source-2.6.30 linux</pre>
<p>Now go to sources and set current configuration:</p>
<pre># cd linux
# make oldconfig &#038;&#038; make prepare</pre>
<p>After finished, run : </p>
<pre># /etc/init.d/vboxdrv setup
Stopping VirtualBox kernel module:done..
Recompiling VirtualBox kernel module:done..
Starting VirtualBox kernel module:done..</pre>
<p>Check is everything done right: </p>
<pre># lsmod | grep -i vbox</pre>
<p>It&#8217;s okay if you get something like this: </p>
<pre>vboxdrv                63936  0</pre>
<p>Now you are ready to run VirtualBox. </p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/07/how-to-make-virtualbox-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

