<?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>System Network Programming Solution - Linux - windows - centos- security- cpanel - plesk -directadmin helm&#187; Debian</title>
	<atom:link href="http://thegioinguonmo.com/tag/debian/feed/" rel="self" type="application/rss+xml" />
	<link>http://thegioinguonmo.com</link>
	<description>SHARING EVERYTHING</description>
	<lastBuildDate>Sat, 19 May 2012 21:40:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Xen on Debian Etch</title>
		<link>http://thegioinguonmo.com/virtualization/xen/xen-debian-etch.html</link>
		<comments>http://thegioinguonmo.com/virtualization/xen/xen-debian-etch.html#comments</comments>
		<pubDate>Mon, 26 Mar 2012 16:19:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Xen]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[vps]]></category>
		<category><![CDATA[xen server]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2592</guid>
		<description><![CDATA[I’ve been testing out a few virtualization systems and am sofar very pleased with Xen. Installing on Debian Etch couldn’t be easier and it worked straight out the box – I had my first virtual server running in under 15 minutes flat! Use the following commands to install Xen on a Debian Etch machine: apt-get [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been testing out a few virtualization systems and am sofar very pleased with Xen. Installing on Debian Etch couldn’t be easier and it worked straight out the box – I had my first virtual server running in under 15 minutes flat!</p>
<p>Use the following commands to install Xen on a Debian Etch machine:</p>
<pre lang="shell">apt-get install xen-linux-system-2.6.18-4-xen-686 libc6-xen bridge-utils</pre>
<p>This will install the Xen kernel (2.6.18-5-xen-686 #1 SMP), the libc6-xen libraries which is optimized for the Xen hypervisor and the utilities for configuring the Linux ethernet bridge.</p>
<p>Next up is a reboot into your newly installed kernel:</p>
<pre lang="shell">reboot</pre>
<p>Once the machine is back online you need to install the xen-tools package which allows you easily create new guest Xen domains on your Debian Etch host:</p>
<pre lang="shell">apt-get install xen-tools</pre>
<p>Next, modify the Xen config file (/etc/xen/xend-config.sxp) and enable:</p>
<pre lang="shell">(network-script network-bridge)</pre>
<p>You also need to modify /etc/xen-tools/xen-tools.conf to set kernel and initrd parameters as well as the disk and sizing options for your vistual servers.</p>
<p>You can easily find out what your kernel and initrd image is named by typing:</p>
<pre lang="shell">ls /boot/vmlinuz* /boot/initrd*</pre>
<p>This will list the kernel and initrd names for your system. Remember, your after the xen kernel and initrd images!</p>
<pre lang="shell">/boot/initrd.img-2.6.18-5-xen-686

/boot/vmlinuz-2.6.18-5-xen-686</pre>
<p>Continue and edit the xen-tools configuration file</p>
<pre lang="shell">vi /etc/xen-tools/xen-tools.conf

#
# Default kernel and ramdisk to use for the virtual servers
#
kernel = /boot/vmlinuz-2.6.18-5-xen-686
initrd = /boot/initrd.img-2.6.18-5-xen-686

dir = /data/vservers
debootstrap = 1
gateway   = 172.16.0.1
netmask   = 255.255.255.0

size   = 6Gb
memory = 256Mb
swap   = 256Mb
fs     = ext3
dist   = etch
image  = sparse</pre>
<p>Next, create the directory where your virtual servers will reside:</p>
<pre lang="shell">mkdir -p /data/vservers/domains</pre>
<p>Now your ready to create your first virtual server! Use the following command to create it:</p>
<pre lang="shell">xen-create-image -hostname=dns -ip=172.16.0.25 -passwd</pre>
<p>It will take a minute or two to create the virtual server after which you can fire it up by using:</p>
<pre lang="shell">xm create dns.cfg</pre>
<p>Your virtual server should be started up and ready for you to use.. You can either ssh to the IP you created the server with or attach to it from the host using:</p>
<pre lang="shell">xm console dns</pre>
<p>Have fun with your Xen virtual machine!</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/virtualization/xen/xen-debian-etch.html" title="bridge-utils programing">bridge-utils programing</a> (1)</li><li><a href="http://thegioinguonmo.com/virtualization/xen/xen-debian-etch.html" title="debian etch xentools">debian etch xentools</a> (1)</li><li><a href="http://thegioinguonmo.com/virtualization/xen/xen-debian-etch.html" title="debian xen install">debian xen install</a> (1)</li><li><a href="http://thegioinguonmo.com/virtualization/xen/xen-debian-etch.html" title="virtualisation centos debian xen">virtualisation centos debian xen</a> (1)</li><li><a href="http://thegioinguonmo.com/virtualization/xen/xen-debian-etch.html" title="virtualisation xen noyau débian">virtualisation xen noyau débian</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/virtualization/xen/xen-debian-etch.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Icinga Configuration For Nginx On Debian Wheezy/Ubuntu 11.10</title>
		<link>http://thegioinguonmo.com/os/linux/icinga-configuration-nginx-debian-wheezyubuntu-1110.html</link>
		<comments>http://thegioinguonmo.com/os/linux/icinga-configuration-nginx-debian-wheezyubuntu-1110.html#comments</comments>
		<pubDate>Sat, 03 Mar 2012 15:39:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Icinga]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2474</guid>
		<description><![CDATA[Icinga is an enterprise grade open source monitoring system which keeps watch over networks and any conceivable network resource, notifies the user of errors and recoveries and generates performance data for reporting. It is a fork of Nagios. This tutorial explains how to serve the Icinga Web interface from an nginx server on Debian Wheezy/Ubuntu [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="nofollow" target="_blank" href="https://www.icinga.org/" target="_blank">Icinga</a> is an enterprise grade open source monitoring system which keeps watch over networks and any conceivable network resource, notifies the user of errors and recoveries and generates performance data for reporting. It is a fork of <a rel="nofollow" target="_blank" href="http://www.nagios.org/" target="_blank">Nagios</a>. This tutorial explains how to serve the Icinga Web interface from an nginx server on Debian Wheezy/Ubuntu 11.10 (the tutorial might work for Debian Squeeze as well but I didn&#8217;t test; Squeeze&#8217;s Icinga version is a lot older than the versions for Wheezy and Ubuntu 11.10, so there might be small differences).</p>
<p>I do not issue any guarantee that this will work for you!</p>
<p>&nbsp;</p>
<h3>1 Preliminary Note</h3>
<p>I want to serve the Icinga web interface from a vhost called www.example.com/example.com here with the document root /var/www/www.example.com/web.</p>
<p>You should have a working LEMP installation, as shown in this tutorial:</p>
<ul>
<li><a rel="nofollow" target="_blank" href="http://www.howtoforge.com/installing-nginx-with-php5-and-php-fpm-and-mysql-support-on-ubuntu-11.10" target="_blank">Installing Nginx With PHP5 (And PHP-FPM) And MySQL Support On Ubuntu 11.10</a></li>
</ul>
<p><strong>A note for Ubuntu users: </strong></p>
<p>Because we must run all the steps from this tutorial with root privileges, we can either prepend all commands in this tutorial with the string sudo, or we become root right now by typing</p>
<p>sudo su</p>
<p>&nbsp;</p>
<h3>2 Installing Fcgiwrap</h3>
<p>As Icinga mostly uses CGI scripts, we need to install a CGI wrapper so that nginx can serve those scripts. We install fcgiwrap for this:</p>
<p>apt-get install fcgiwrap</p>
<p>&nbsp;</p>
<h3>3 Installing Icinga</h3>
<p>Icinga can be installed as follows:</p>
<p>apt-get install icinga icinga-doc icinga-phpapi</p>
<p>You might see the following questions:</p>
<p>General type of mail configuration: &lt;&#8211; Internet Site<br />
System mail name: &lt;&#8211; server1.example.com<br />
Apache servers to configure for icinga: &lt;&#8211; none (we don&#8217;t use Apache, so we don&#8217;t need to configure it)<br />
Configure database for icinga-idoutils with dbconfig-common? &lt;&#8211; No<br />
Workgroup/Domain Name: &lt;&#8211; WORKGROUP</p>
<p>&nbsp;</p>
<h3>4 Configuring PHP</h3>
<p>Icinga has a <a rel="nofollow" target="_blank" href="http://docs.icinga.org/1.6/en/icinga-api.html" target="_blank">PHP API</a>, therefore we need PHP support if you want to use that API.</p>
<p>APC is a free and open PHP opcode cacher for caching and optimizing PHP intermediate code. It&#8217;s similar to other PHP opcode cachers, such as eAccelerator and XCache. It is strongly recommended to have one of these installed to speed up your PHP page.</p>
<p>APC can be installed as follows:</p>
<p>apt-get install php-apc</p>
<p>If you use PHP-FPM as your FastCGI daemon (like in <a rel="nofollow" target="_blank" href="http://www.howtoforge.com/installing-nginx-with-php5-and-php-fpm-and-mysql-support-on-ubuntu-11.10" target="_blank">Installing Nginx With PHP5 (And PHP-FPM) And MySQL Support On Ubuntu 11.10</a>), restart it as follows:</p>
<p>/etc/init.d/php5-fpm restart</p>
<p>If you use lighttpd&#8217;s spawn-fcgi program as your FastCGI daemon (like in <a rel="nofollow" target="_blank" href="http://www.howtoforge.com/installing-nginx-with-php5-and-mysql-support-on-debian-squeeze" target="_blank">Installing Nginx With PHP5 And MySQL Support On Debian Squeeze</a>), we must kill the current spawn-fcgi process (running on port 9000) and create a new one. Run</p>
<p>netstat -tap</p>
<p>to find out the PID of the current spawn-fcgi process:</p>
<p>root@server1:~# netstat -tap<br />
Active Internet connections (servers and established)<br />
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name<br />
tcp        0      0 *:sunrpc                *:*                     LISTEN      734/portmap<br />
tcp        0      0 *:www                   *:*                     LISTEN      2987/nginx<br />
tcp        0      0 *:ssh                   *:*                     LISTEN      1531/sshd<br />
tcp        0      0 *:57174                 *:*                     LISTEN      748/rpc.statd<br />
tcp        0      0 localhost.localdom:smtp *:*                     LISTEN      1507/exim4<br />
tcp        0      0 localhost.localdom:<strong>9000</strong> *:*                     LISTEN      1542/php5-cgi<br />
tcp        0      0 localhost.localdo:mysql *:*                     LISTEN      1168/mysqld<br />
tcp        0     52 server1.example.com:ssh 192.168.0.198:2462      ESTABLISHED 1557/0<br />
tcp6       0      0 [::]:www                [::]:*                  LISTEN      2987/nginx<br />
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      1531/sshd<br />
tcp6       0      0 ip6-localhost:smtp      [::]:*                  LISTEN      1507/exim4<br />
root@server1:~#</p>
<p>In the above output, the PID is 1542, so we can kill the current process as follows:</p>
<p>kill -9 1542</p>
<p>Afterwards we create a new spawn-fcgi process:</p>
<p>/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid</p>
<p>&nbsp;</p>
<h3>5 Configuring nginx</h3>
<p>We must password-protect the Icinga web interface, therefore I create the password file /etc/icinga/htpasswd.users with the username icingaadmin. To create the password file, we need the tool htpasswd which is part of the apache2-utils package which we install as follows:</p>
<p>apt-get install apache2-utils</p>
<p>Afterwards we create the password file:</p>
<p>htpasswd -c /etc/icinga/htpasswd.users icingaadmin</p>
<p>The document root of my www.example.com web site is /var/www/www.example.com/web &#8211; if it doesn&#8217;t exist, create it as follows:</p>
<p>mkdir -p /var/www/www.example.com/web</p>
<p>Next we create an nginx vhost configuration for our www.example.com vhost in the /etc/nginx/sites-available/ directory as follows:</p>
<p>vi /etc/nginx/sites-available/www.example.com.vhost</p>
<table width="90%" border="1" cellspacing="0" cellpadding="2" align="center" bgcolor="#CCCCCC">
<tbody>
<tr>
<td>
<pre>server {
       listen 80;
       server_name www.example.com example.com;
       root /var/www/www.example.com/web;

       if ($http_host != "www.example.com") {
                 rewrite ^ http://www.example.com$request_uri permanent;
       }

       index index.php index.html index.htm;

       location = /favicon.ico {
                log_not_found off;
                access_log off;
                expires max;
       }

       location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
       }

       # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
       location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
       }

       location / {
                root   /usr/share/icinga/htdocs;
                index  index.html;

                auth_basic              "Restricted";
                auth_basic_user_file    /etc/icinga/htpasswd.users;

       }

       location /icinga/stylesheets {
                alias /etc/icinga/stylesheets;
       }
       location /stylesheets {
                alias /etc/icinga/stylesheets;
       }
       location /icinga/images {
                alias /usr/share/icinga/htdocs/images;
       }

       location ~ \.cgi$ {
                # define root directory for CGIs
                root /usr/lib/cgi-bin/icinga;
                rewrite ^/icinga/cgi-bin/(.*)\.cgi /$1.cgi break;
                rewrite ^/cgi-bin/icinga/(.*)\.cgi /$1.cgi break;

                include /etc/nginx/fastcgi_params;
                fastcgi_pass  unix:/var/run/fcgiwrap.socket;
                fastcgi_index index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

                auth_basic              "Restricted";
                auth_basic_user_file    /etc/icinga/htpasswd.users;

                fastcgi_param  AUTH_USER          $remote_user;
                fastcgi_param  REMOTE_USER        $remote_user;
       }

       location ~ ^/icinga-api/(.+\.php)$ {
                root   /usr/share/icinga/htdocs;
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_index index.php;

                auth_basic              "Restricted";
                auth_basic_user_file    /etc/icinga/htpasswd.users;

                fastcgi_param  AUTH_USER          $remote_user;
                fastcgi_param  REMOTE_USER        $remote_user;
       }
}</pre>
</td>
</tr>
</tbody>
</table>
<p>To enable the vhost, we create a symlink to it from the /etc/nginx/sites-enabled/ directory:</p>
<p>cd /etc/nginx/sites-enabled/<br />
ln -s /etc/nginx/sites-available/www.example.com.vhost www.example.com.vhost</p>
<p>Reload nginx for the changes to take effect:</p>
<p>/etc/init.d/nginx reload</p>
<p>That&#8217;s it! Now we can go to http://www.example.com. Log in with the username icingaadmin&#8230;</p>
<p><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/icinga_nginx_debian_wheezy_ubuntu_11.10/big/1.png"><img src="http://static.howtoforge.com/images/icinga_nginx_debian_wheezy_ubuntu_11.10/1.png" alt="1 Icinga Configuration For Nginx On Debian Wheezy/Ubuntu 11.10" width="550" height="399" title="Icinga Configuration For Nginx On Debian Wheezy/Ubuntu 11.10" /></a></p>
<div><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/icinga_nginx_debian_wheezy_ubuntu_11.10/big/1.png"><img src="http://static.howtoforge.com/images/click_to_enlarge.png" alt="click to enlarge Icinga Configuration For Nginx On Debian Wheezy/Ubuntu 11.10" width="100" height="12" border="0" title="Icinga Configuration For Nginx On Debian Wheezy/Ubuntu 11.10" /> </a></div>
<p>&#8230; and afterwards you should see the Icinga web interface:</p>
<p><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/icinga_nginx_debian_wheezy_ubuntu_11.10/big/2.png"><img src="http://static.howtoforge.com/images/icinga_nginx_debian_wheezy_ubuntu_11.10/2.png" alt="2 Icinga Configuration For Nginx On Debian Wheezy/Ubuntu 11.10" width="550" height="399" title="Icinga Configuration For Nginx On Debian Wheezy/Ubuntu 11.10" /></a></p>
<div><a rel="nofollow" target="_blank" href="http://static.howtoforge.com/images/icinga_nginx_debian_wheezy_ubuntu_11.10/big/2.png"><img src="http://static.howtoforge.com/images/click_to_enlarge.png" alt="click to enlarge Icinga Configuration For Nginx On Debian Wheezy/Ubuntu 11.10" width="100" height="12" border="0" title="Icinga Configuration For Nginx On Debian Wheezy/Ubuntu 11.10" /> </a></div>
<p>If you want to learn more about Icinga configuration, please check out this tutorial: <a rel="nofollow" target="_blank" href="http://www.howtoforge.com/server-monitoring-with-icinga-on-debian-squeeze" target="_blank">Server Monitoring With Icinga On Debian Squeeze</a></p>
<p>&nbsp;</p>
<h3>6 Links</h3>
<ul>
<li>Icinga: <a rel="nofollow" target="_blank" href="https://www.icinga.org/" target="_blank">https://www.icinga.org/ </a></li>
<li>Icinga Documentation: <a rel="nofollow" target="_blank" href="http://docs.icinga.org/latest/en/" target="_blank">http://docs.icinga.org/latest/en/ </a></li>
<li>Nagios: <a rel="nofollow" target="_blank" href="http://www.nagios.org/" target="_blank">http://www.nagios.org/ </a></li>
<li>nginx: <a rel="nofollow" target="_blank" href="http://nginx.org/" target="_blank">http://nginx.org/</a></li>
<li>nginx Wiki: <a rel="nofollow" target="_blank" href="http://wiki.nginx.org/" target="_blank">http://wiki.nginx.org/</a></li>
<li>Debian: <a rel="nofollow" target="_blank" href="http://www.debian.org/" target="_blank">http://www.debian.org/</a></li>
<li>Ubuntu: <a rel="nofollow" target="_blank" href="http://www.ubuntu.com/" target="_blank">http://www.ubuntu.com/</a></li>
</ul>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/os/linux/icinga-configuration-nginx-debian-wheezyubuntu-1110.html" title="iso debian icinga">iso debian icinga</a> (2)</li><li><a href="http://thegioinguonmo.com/os/linux/icinga-configuration-nginx-debian-wheezyubuntu-1110.html" title="tutorial icinga debian">tutorial icinga debian</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/icinga-configuration-nginx-debian-wheezyubuntu-1110.html" title="plesk sur wheezy">plesk sur wheezy</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/icinga-configuration-nginx-debian-wheezyubuntu-1110.html" title="Nginx plesk 10 debian 6">Nginx plesk 10 debian 6</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/icinga-configuration-nginx-debian-wheezyubuntu-1110.html" title="nginx php5 4 installer debian">nginx php5 4 installer debian</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/icinga-configuration-nginx-debian-wheezyubuntu-1110.html" title="ngingx centos icinga">ngingx centos icinga</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/icinga-configuration-nginx-debian-wheezyubuntu-1110.html" title="Ngin On Debian Squeeze">Ngin On Debian Squeeze</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/icinga-configuration-nginx-debian-wheezyubuntu-1110.html" title="apt-get install icinga">apt-get install icinga</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/icinga-configuration-nginx-debian-wheezyubuntu-1110.html" title="Icinga Tutorial Ubuntu">Icinga Tutorial Ubuntu</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/icinga-configuration-nginx-debian-wheezyubuntu-1110.html" title="icinga iso">icinga iso</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/os/linux/icinga-configuration-nginx-debian-wheezyubuntu-1110.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create a Callback option</title>
		<link>http://thegioinguonmo.com/voip/asterisk/create-callback-option.html</link>
		<comments>http://thegioinguonmo.com/voip/asterisk/create-callback-option.html#comments</comments>
		<pubDate>Wed, 22 Feb 2012 09:08:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[Callback]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[voip]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2330</guid>
		<description><![CDATA[1. Overview This tutorial will show you how to create a queue, where your incoming calls to arrive. Noting so special, but we are also going to show you how to give a choice to the callers &#8211; they will be able to leave the queue at any time and in our example they will [...]]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;"><em>1. Overview</em></span></p>
<div>This tutorial will show you how to create a queue, where your incoming calls to arrive. Noting so special, but we are also going to show you how to give a choice to the callers &#8211; they will be able to leave the queue at any time and in our example they will have the choice to leave a number at which you could callback them later. The best part is that the number will be nicely emailed to your email box with details not only about the left number, but also the CallerID, the queue at which the caller was initially placed and the date and time at which he has left his number.</div>
<p>&nbsp;</p>
<div></div>
<p><span style="text-decoration: underline;"><em>2. Prerequisites</em></span></p>
<div>Before we start we will assume that you have <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/general_asterisk_installation_compilation.html">a working Asterisk PBX</a> with registered users in <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/iax_conf.html"><em>iax.conf</em></a>, <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/sip_conf.html"><em>sip.conf</em></a> or <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/mgcp_conf.html"><em>mgcp.conf</em></a>(It depends on which protocol you would like to use)</p>
<p>We will show you how to create your extensions in <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html">extensions.conf</a>.</p>
<div></div>
<p>To test how the setup works we recommend to use our <span style="text-decoration: underline;"><strong>IAX softphone Idefisk</strong></span>. You can download it <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tools/idefisk_beta.php" target="_blank">from our website &#8211; here</a>. If you do so, you can also take a look at our <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/idefisk_softphone.html">tutorial</a> about how to configure it to work with <strong>Asterisk PBX</strong>.</p>
<p>For the sending of the emails you will need to install the <strong>mime-construct</strong> package. <strong>apt-get install mime-construct</strong> (in Debian) should do the trick. Of course you will need a SMTP server too.</div>
<p>&nbsp;</p>
<div></div>
<p><span style="text-decoration: underline;"><em>3. Asterisk PBX configurations</em></span></p>
<div>We need to create one user in the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/iax_conf.html"><em>iax.conf</em></a> file. This is because we are going to use Idefisk and its <strong>IAX2</strong> support. Idefisk supports the <strong>SIP</strong> protocol too. So if you want to use it, you have to do the configurations below respectively in <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/sip_conf.html"><em>sip.conf</em></a>.</div>
<p>&nbsp;</p>
<div>Here is the configuration.</p>
<p><em>[general]<br />
trunkmtu = 4000<br />
bandwidth=low<br />
disallow=lpc10<br />
jitterbuffer=no<br />
forcejitterbuffer=no<br />
tos=lowdelay<br />
autokill=yes</p>
<p>[caller1]<br />
secret=caller1<br />
type=friend<br />
host=dynamic<br />
context=incoming_calls</em></div>
<p>&nbsp;</p>
<div>So, we now we have the user <em>caller1</em></p>
<p><em>Type=friend</em> means that this user can make and receive calls. <em>Host=dynamic</em> means that the IP is not statically assigned but dynamically through a DHCP server. <em>Allow=all</em> means that the line which this user will use, support all available audio codecs, supported by Asterisk. <em>Context=test</em> &#8211; this shows that the user is allowed to work with the extensions in the context with this name in the configuration file <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html">extensions.conf</a>.</p>
<p>Our <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html">extensions.conf</a> looks like:</div>
<p>&nbsp;</p>
<div>The configuration is below:</p>
<p><em>[incoming_calls]</p>
<p>exten =&gt; 100100,1,Set(CALLERID(name)=queue1)<br />
exten =&gt; 100100,n,Queue(queue1)<br />
exten =&gt; 100100,n,Hangup()</p>
<p>exten =&gt; 200200,1,Set(CALLERID(name)=queue2)<br />
exten =&gt; 200200,n,Queue(queue2)<br />
exten =&gt; 200200,n,Hangup()</p>
<p>exten =&gt; 300300,1,Set(CALLERID(name)=queue3)<br />
exten =&gt; 300300,n,Queue(queue3)<br />
exten =&gt; 300300,n,Hangup()</p>
<p>[queue1out]</p>
<p>exten =&gt; 1,1,Set(FLAG=1)<br />
exten =&gt; 1,n,Playback(CallBack)<br />
exten =&gt; 1,n,Read(NUMBER|beep|10|||5)<br />
exten =&gt; 1,n,Wait(1)<br />
exten =&gt; 1,n,Set(FLAG=2)<br />
exten =&gt; 1,n,GoToIf($[${NUMBER} = ""]?empty:full)<br />
exten =&gt; 1,n(empty),System(/usr/bin/call/mailnonumber.sh callback@test.org ${CALLERID(num)} Queue1)<br />
exten =&gt; 1,n,Hangup()<br />
exten =&gt; 1,n(full),System(/usr/bin/call/mailnumber.sh ${NUMBER} callback@test.org ${CALLERID(num)} Queue1)<br />
exten =&gt; 1,n,Hangup()</p>
<p>exten =&gt; h,1,NoOp(${FLAG})<br />
exten =&gt; h,2,GoToIf($[${FLAG} = 1]?h|3:h|4)<br />
exten =&gt; h,3,System(/usr/bin/call/mailnonumber.sh callback@test.org ${CALLERID(num)} Queue1)<br />
exten =&gt; h,4,Hangup()</p>
<p>[queue2out]</p>
<p>exten =&gt; 1,1,Set(FLAG=1)<br />
exten =&gt; 1,n,Playback(CallBack)<br />
exten =&gt; 1,n,Read(NUMBER|beep|10|||5)<br />
exten =&gt; 1,n,Wait(1)<br />
exten =&gt; 1,n,Set(FLAG=2)<br />
exten =&gt; 1,n,GoToIf($[${NUMBER} = ""]?empty:full)<br />
exten =&gt; 1,n(empty),System(/usr/bin/call/mailnonumber.sh callback@test.org ${CALLERID(num)} Queue2)<br />
exten =&gt; 1,n,Hangup()<br />
exten =&gt; 1,n(full),System(/usr/bin/call/mailnumber.sh ${NUMBER} callback@test.org ${CALLERID(num)} Queue2)<br />
exten =&gt; 1,n,Hangup()</p>
<p>exten =&gt; h,1,NoOp(${FLAG})<br />
exten =&gt; h,2,GoToIf($[${FLAG} = 1]?h|3:h|4)<br />
exten =&gt; h,3,System(/usr/bin/call/mailnonumber.sh callback@test.org ${CALLERID(num)} Queue2)<br />
exten =&gt; h,4,Hangup()</p>
<p>[queue3out]</p>
<p>exten =&gt; 1,1,Set(FLAG=1)<br />
exten =&gt; 1,n,Playback(CallBack)<br />
exten =&gt; 1,n,Read(NUMBER|beep|10|||5)<br />
exten =&gt; 1,n,Wait(1)<br />
exten =&gt; 1,n,Set(FLAG=2)<br />
exten =&gt; 1,n,GoToIf($[${NUMBER} = ""]?empty:full)<br />
exten =&gt; 1,n(empty),System(/usr/bin/call/mailnonumber.sh callback@test.org ${CALLERID(num)} Queue3)<br />
exten =&gt; 1,n,Hangup()<br />
exten =&gt; 1,n(full),System(/usr/bin/call/mailnumber.sh ${NUMBER} callback@test.org ${CALLERID(num)} Queue3)<br />
exten =&gt; 1,n,Hangup()</p>
<p>exten =&gt; h,1,NoOp(${FLAG})<br />
exten =&gt; h,2,GoToIf($[${FLAG} = 1]?h|3:h|4)<br />
exten =&gt; h,3,System(/usr/bin/call/mailnonumber.sh callback@test.org ${CALLERID(num)} Queue3)<br />
exten =&gt; h,4,Hangup()<br />
</em></div>
<p>&nbsp;</p>
<div>As we are talking about queues, we are going to create three different queues in the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html"><strong>queues.conf</strong></a> configuration file</div>
<p>&nbsp;</p>
<div>The configuration:</p>
<p><em>[general]</p>
<p>[default]</p>
<p>[queue1]</p>
<p>music = default<br />
strategy = ringall<br />
timeout=15<br />
retry = 5<br />
context = queue1out<br />
periodic-announce-frequency = 60<br />
periodic-announce = Call_Back_1</p>
<p>member =&gt; IAX2/user1<br />
member =&gt; IAX2/user2<br />
member =&gt; IAX2/user3<br />
member =&gt; IAX2/user4<br />
member =&gt; IAX2/user5<br />
member =&gt; IAX2/user6<br />
member =&gt; IAX2/user7<br />
member =&gt; IAX2/user8<br />
member =&gt; IAX2/user9</p>
<p>[queue2]</p>
<p>music = default<br />
strategy = ringall<br />
timeout=15<br />
retry = 5<br />
context = queue2out<br />
periodic-announce-frequency = 60<br />
periodic-announce = Call_Back_1</p>
<p>member =&gt; IAX2/user1<br />
member =&gt; IAX2/user2<br />
member =&gt; IAX2/user3<br />
member =&gt; IAX2/user4<br />
member =&gt; IAX2/user5<br />
member =&gt; IAX2/user6<br />
member =&gt; IAX2/user7<br />
member =&gt; IAX2/user8<br />
member =&gt; IAX2/user9</p>
<p>[queue3]</p>
<p>music = default<br />
strategy = ringall<br />
timeout=15<br />
retry = 5<br />
context = queue3out<br />
periodic-announce-frequency = 60<br />
periodic-announce = Call_Back_1</p>
<p>member =&gt; IAX2/user1<br />
member =&gt; IAX2/user2<br />
member =&gt; IAX2/user3<br />
member =&gt; IAX2/user4</em></div>
<div>Now let’s take a look at the shell script you will need if you want to send emails with the left number. The script will use the <strong>mime-construct</strong> program to create the email message and send it to the desired recipient. The second script has the same purpose and the only change is in the body of the email message.</div>
<p>&nbsp;</p>
<div>Here are the configurations:</p>
<p><strong><span style="text-decoration: underline;">Script 1:</span></strong></p>
<p><em>#!/bin/sh</p>
<p>NUMBER=$1<br />
RECIPIENT=$2<br />
CALLERID=$3<br />
QUEUE=$4</p>
<p>mime-construct &#8211;to $RECIPIENT &#8211;subject &#8220;You have just missed a call&#8221; &#8211;string &#8220;The number that have been left by the caller: $NUMBER. The CallerID we have received: $CALLERID. The call is coming from the $QUEUE queue. Call was received at `date`&#8221;</em></p>
<p><strong><span style="text-decoration: underline;">Script 2:</span></strong></p>
<p><em>#!/bin/sh</p>
<p>RECIPIENT=$1<br />
CALLERID=$2<br />
QUEUE=$3</p>
<p>mime-construct &#8211;to $RECIPIENT &#8211;subject &#8220;You have just missed a call&#8221; &#8211;string &#8220;The caller did not left a telephone number. The CallerID we have received: $CALLERID. The call is coming from the $QUEUE queue. Call was received at `date`&#8221;</em></div>
<p>&nbsp;</p>
<div></div>
<p><span style="text-decoration: underline;"><em>4. Explanation</em></span></p>
<div>Now, we are going to explain you what the configurations about actually means and how it works.</p>
<p>However, keep in mind that we are going to explain you only the configurations concerning the Callback possibility. If you want to learn more about the used configuration files and their options &#8211; take a look at one of our tutorials:</p>
<div><em><a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/iax_conf%20internall" target="_blank">iax.conf</a><br />
<a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html">extensions.conf</a><br />
<a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html">queues.conf</a></em></div>
<p><span style="text-decoration: underline;">Let&#8217;s start with <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html"><em>queues.conf</em></a></span>.</p>
<div>In the example above you could see three different queues each one with different number of agents.</p>
<p>Each queue has its own configuration. Most of the settings are common, unless one option &#8211; the <strong>context</strong>.</p>
<p>This option is giving you the possibility to define a context, where eventually, by pressing a single digit, the caller will be &#8220;transferred&#8221;. The digit could be pressed at any time while the caller is waiting in the queue. The context we are talking about has to be created in the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html">extensions.conf</a> configuration file. There is one more requirement and it is that you have to create an extension of one digit, in this context &#8211; the digit that the caller will press in order to exit the queue.</p>
<p>Despite of the fact, that for all the queues, the setup for leaving a number and then emailing it to our email address will be pretty much the same, we recommend you to create different contexts for every different queue. That is because we are going to email not only the left number but also some other information such as the queue from which the caller has quitted. Of course you could do it with one common and more complicated context for all the queues, but we think that it will be much easier to manage and change the settings for each queue independently of the other ones.</p>
<p>So here are all the options in our queue and what they are doing&#8221;</p>
<div><em>music = default</em> &#8211; the music class defined in <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/musiconhold_conf" target="_blank"><em>musiconhold.conf</em></a>, where Asterisk will be looking for mp3 files, which will be played to the caller instead of ringing tone, while he is waiting in the queue.<br />
<em>strategy = ringall</em> &#8211; one of six ringing strategies that you could choose. This one means the phone of each agent, assigned to the queue, will start ringing in case of incoming call. For details about the other strategies take a look at our tutorial about <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html">queues.conf</a><br />
<em>timeout=15</em> &#8211; a timeout in seconds. It defines after how many seconds with no answer the agent phone to stop ringing. For more information about refer to our tutorial about <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html">queues.conf</a> .<br />
<em>retry = 5</em> &#8211; after how many seconds to try to ring all the agents again. For more information about refer to our tutorial about <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html">queues.conf</a>.<br />
<em>context = queue3out</em> &#8211; we have already explained this above.<br />
<em>periodic-announce-frequency = 60</em> &#8211; define in seconds an interval of time after which the caller, waiting in the queue, will hear a prerecorded message. It could be a message with instructions or something else. It is up to you. For more information about refer to our tutorial about <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html">queues.conf</a>.<br />
<em>periodic-announce = Call_Back_1</em> &#8211; that is the name of the prerecorded message that should be played after the periodic announce timeout expires. For more information about refer to our tutorial about <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html">queues.conf</a>.</p>
<p><em>member =&gt; IAX2/user1</em> &#8211; there are two different ways to assign agents to a specific queue. We have picked up the easies one. Whenever a phone with username <strong>user1</strong> is registered successfully to the Asterisk system, the incoming calls in the queue will be send to this phone. You could have as many as you want agents assigned to the queue in this way and the incoming call will be send to all of them according to the chosen strategy. For more information about refer to our tutorial about <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queues_conf.html">queues.conf</a>.</div>
</div>
<p><span style="text-decoration: underline;">Now let&#8217;s take a look at the configurations in <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html">extensions.conf</a>.</span></p>
<div>First of all we have three extensions for the incoming calls. They are all put in the <strong>[incoming_calls]</strong> context. Their purpose is to put the incoming calls in the corresponding queue.</p>
<p>When we have an incoming call, the first thing we are doing is to change the Callerid name to the name of the queue where the caller will be put. Thus the agent who is answering the call will know from which queue exactly the call is coming. It is not absolutely necessary, but the idea is that one agent could be assigned to many different queues. In order to do the change we are using the <em><a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/set.html">Set application &#8211; More information about it in our tutorial</a></em></p>
<p>The next step is to actually send the call in the queue &#8211; pretty easy one. There is an application called <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queue.html"><em>Queue</em></a> to which you just have to pass the name of the desired queue as an argument. We are not going to use any extra options. You could <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/queue.html"><em>find more information about how to use the QUEUE application in our tutorial</em></a></p>
<p>You could notice and the usage of the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/hangup.html"><em>Hangup application</em></a>. It is always a good idea to use it as last application for all of your extensions. Thus, you will always be sure that the used channel will be released when the conversation is over. <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/hangup.html"><em>Refer to our tutorial for more information on this application</em></a></p>
<p>Next step is to create the contexts, where the callers should be &#8220;transferred&#8221; in case they have decided to exit the queue. As we have mentioned above we have different context for each of the queue.</p>
<p>Before we continue &#8211; a few words about the idea behind. We are running queues with a callback option. In other words, when we have a caller waiting in the queue, we will play him a message every 60 seconds. The message will saying: <em>&#8220;All of our lines are busy. You could leave your number by pressing one and we will call you back as soon as possible or you could stay in the queue and wait to be served.&#8221;</em>.</p>
<p>If the caller decides to exit the queue, he will be asked to leave his number after the &#8220;beep&#8221; signal. At this stage, you have to keep in mind that the caller might not leave his number for some reason. So what we will have a check and if the number is not left we will send an email message that the caller has decided not to leave his number.</p>
<p>So what do we need as extensions? The first thing we are doing is to set a flag. Why? In case the caller hangs up at some point before leaving his number, we need to send a message that we did not received the number. For the purpose we are using the so called <strong>predefined</strong> extension &#8211; <strong><em>h</em></strong>, which allows you to execute something in case of hang up. <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html"><em>Refer to our tutorial for more information</em></a></p>
<p>However, there is a slight chance that the caller might wait for the timeout to expires without leaving his number or to have a problem with the sending of DTMF tone, that we will have an email saying that the caller has left his number but the number field will be empty and because we have a hang up event even if the caller has left his number, we need the flag to determine whether the hang up is before the application that will store the number or after it and on that basis we will know whether we need to send an email message on hang up or not. In this way we omit the sending of one message twice.</p>
<p>On the next step we have the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/playback.html"><em>Playback application</em></a>. Its simple purpose is to play a sound files. We have a sound message, which instructs the caller to type his number after the beep tone and to press the pound key (#) when he is ready. For more information <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/playback.html"><em>refer to our tutorial about the Playback application</em></a></p>
<p>Next, comes the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/read.html"><em>Read application</em></a>. It’s the one used to store the number typed by the caller. It has many options.</p>
<p>There is a small limitation in the application we are going to use to save the number typed by the caller. We need to know, when he has finished with the typing. So there are two ways.</p>
<p>The first one is to ask him to press the pound key (#) once he is ready and the second one is to limit the length of the number the caller could type plus a timeout.<br />
In our example we are going to limit the length of the number to 10 digits and we are going to put a timeout of 5 seconds. We are going to store the number typed by the caller in the <strong>NUMBER</strong> variable. The <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/read.html"><em>Read application</em></a> gives you the possibility to play a sound file before the typing of the number. In our case we will are going to play a <strong>beep</strong> tone</p>
<p><a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/read.html"><em>Refer to our tutorial for more information and details about the Read application</em></a></p>
<p>Next steps &#8211; we have the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/wait.html"><em>Wait application</em></a>, which is not absolutely necessary and then we set the flag variable to <strong>2</strong>. This, as we have already described above will be used to omit the sending of one and the same email message twice. For more information about the Wait application, <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/wait.html"><em>refer to our tutorial</em></a>.</p>
<p>We now have to check whether the caller has actually left his number or not. For the purpose we can use the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/gotoif.html"><em>GoToIf application</em></a>. It has a very specific syntax, but its idea is simple to verify whether one condition is true or false. So, in our case we are just checking whether the <strong>NUMBER</strong> variable is empty or not. If it is empty then the execution of the dialplan will continue with the next step, marked as <strong>n(empty)</strong>. <strong>n</strong> makes your life easier as you do not have to write and follow the steps (priorities) &#8211; <strong>n</strong> means that you take the previous priority and increase it with 1. <strong>(empty)</strong> is a label showing to you and the system to which <strong>n</strong> you will be send.</p>
<p>If the <strong>NUMBER</strong> variable contains even one digit then we assume that we have the number of the caller so the execution of the dialplan will be send to the step with label <strong>(full)</strong>. Refer to our <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/gotoif.html"><em>Tutorial for more information, details and option about the GoToIf application</em></a>.</p>
<p>Both steps <strong>(empty)</strong> and <strong>(full)</strong> have one and the same task &#8211; to execute the shell script, which will form the email message and send it. The only difference would be in the body of the email message. The application, which we have to use is called <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/system.html"><em>System</em></a>. It just executes system commands as you will do it in your Linux CLI. Refer to our <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/system.html"><em>Tutorial for more information about the System application</em></a>.</p>
<p>In our case we are executing our own scripts called <strong>mailnumber</strong> and <strong>mailnonumber</strong>. They are written in such way that we have to pass them a few parameters. You could see them above as screenshots and in pure text</p>
<p>If we do not have the caller&#8217;s number, we will execute the script called <strong>mailnonumber</strong>. We need to add, as first parameter, the email address of the recipient. The second parameter is the CallerId number as we have received it in our system. The last parameter is the name of the queue from which the caller has exited.</p>
<p>If we have the caller&#8217;s number we will have executed another shell script called <strong>mailnumber</strong> which has a different body, but the same parameters plus one more, which of course is the number left by the caller.</p>
<p>The sending of the email is the last step we need to do and that is why after it we have to hang up the channel. For the purpose we will use once again the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/hangup.html"><em>Hangup application</em></a>.</p>
<p>In the <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/extensions_conf.html"><em>predefined extensions</em></a> starting with <strong>h</strong> we have a simple check of the <strong>FLAG</strong> variable to help use determine whether we have to send an email with saying that we do not have the caller&#8217;s number. (this step is only needed in case the caller hangs up before the prompt to leave his number)</div>
<p><span style="text-decoration: underline;">A few words about the shell scripts.</span></p>
<div>They are not very complicated. All you need is a basic knowledge of shell scripts and the <strong><em>mime-construct package</em></strong>. <strong>apt-get install mime-construct</strong> (in Debian) and you will have it. Then its just up to the <strong>mime-construct&#8217;s</strong> syntax</div>
<p>Now all you have to do is to register your <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tools/idefisk_beta.php" target="_blank">IAX2 base softphone Idefisk</a> to your Asterisk system with the settings, shown above, in <a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/iax_conf.html"><em>iax.conf</em></a> and dial one of the extensions created in the <strong>[incoming_calls]</strong> context.</p>
<p>What will happen (if you have followed our setup) is that you will be put in a queue and on every 60 seconds you will hear a message saying that you could exit the queue and leave your number by pressing 1. If you press one you will hear a prompt to leave you number after the signal. Then you will hear beep and if you leave your number followed by the pound key (#), the number will be emailed to the desired email address and you will probably receive a callback.</p></div>
<p>&nbsp;</p>
<div></div>
<p><strong><span style="text-decoration: underline;">4. Uploaded files</span></strong></p>
<div><a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/274673/extensions.conf">extensions.conf</a><br />
<a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/274674/iax.conf">iax.conf</a><br />
<a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/274675/queues.conf">queues.conf</a><br />
<a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/274676/mailnumber.sh">mailnumber.sh</a><br />
<a rel="nofollow" target="_blank" href="http://www.asteriskguru.com/tutorials/274677/mailnonumber.sh">mailnonumber.sh</a></div>
<p>&nbsp;</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/voip/asterisk/create-callback-option.html" title="linux network callback">linux network callback</a> (2)</li><li><a href="http://thegioinguonmo.com/voip/asterisk/create-callback-option.html" title="asterisk 10 callback">asterisk 10 callback</a> (1)</li><li><a href="http://thegioinguonmo.com/voip/asterisk/create-callback-option.html" title="type=friend means that this user can make and receive calls">type=friend means that this user can make and receive calls</a> (1)</li><li><a href="http://thegioinguonmo.com/voip/asterisk/create-callback-option.html" title="plesk micro updates 9 5 0 linux">plesk micro updates 9 5 0 linux</a> (1)</li><li><a href="http://thegioinguonmo.com/voip/asterisk/create-callback-option.html" title="network callback programming">network callback programming</a> (1)</li><li><a href="http://thegioinguonmo.com/voip/asterisk/create-callback-option.html" title="linux CALLBACK windows">linux CALLBACK windows</a> (1)</li><li><a href="http://thegioinguonmo.com/voip/asterisk/create-callback-option.html" title="linux Callback Solution">linux Callback Solution</a> (1)</li><li><a href="http://thegioinguonmo.com/voip/asterisk/create-callback-option.html" title="linux callback example">linux callback example</a> (1)</li><li><a href="http://thegioinguonmo.com/voip/asterisk/create-callback-option.html" title="Idefisk Examples">Idefisk Examples</a> (1)</li><li><a href="http://thegioinguonmo.com/voip/asterisk/create-callback-option.html" title="asterisk pbx callback for windows">asterisk pbx callback for windows</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/voip/asterisk/create-callback-option.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Manage Apache Resources Limits With mod_slotlimit (Debian Etch)</title>
		<link>http://thegioinguonmo.com/web-server/apache/how-to-manage-apache-resources-limits-with-mod_slotlimit-debian-etch-2.html</link>
		<comments>http://thegioinguonmo.com/web-server/apache/how-to-manage-apache-resources-limits-with-mod_slotlimit-debian-etch-2.html#comments</comments>
		<pubDate>Mon, 09 Jan 2012 09:39:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[mod]]></category>
		<category><![CDATA[order]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=254</guid>
		<description><![CDATA[mod_slotlimit is an Apache module that using dynamic slot allocation algorithm and static rules, can manage resources used for each running site. &#160; 1. Installation In order to compile mod_slotlimit, you will need to have apxs2 (APache eXtension tool) installed and configured with Apache. The follow command will install it: apt-get install apache2-prefork-dev Now we [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="nofollow" target="_blank" href="http://sourceforge.net/projects/mod-slotlimit/" target="_blank">mod_slotlimit</a> is an Apache module that using dynamic slot allocation algorithm and static rules, can manage resources used for each running site.</p>
<p>&nbsp;</p>
<h3>1. Installation</h3>
<p>In order to compile mod_slotlimit, you will need to have apxs2 (APache eXtension tool) installed and configured with Apache.</p>
<p>The follow command will install it:</p>
<p>apt-get install apache2-prefork-dev</p>
<p>Now we download the source package present at http://sourceforge.net/projects/mod-slotlimit/ or download it using wget application and this direct link to the repository:</p>
<p>wget http://kent.dl.sourceforge.net/sourceforge/mod-slotlimit/mod_slotlimit.tar.gz</p>
<p>Next open archive, compile and install module with those commands:</p>
<p>tar zxvf mod_slotlimit.tar.gz<br />
cd mod_slotlimit-1.0<br />
make<br />
make install</p>
<p>Add in the main config file of your web server the following command in order to load mod_slotlimit module.</p>
<p>vi /etc/apache2/httpd.conf</p>
<table width="90%" border="1" cellspacing="0" cellpadding="2" bgcolor="#cccccc">
<tbody>
<tr>
<td>
<blockquote><p>[...]<br />
LoadModule slotlimit_module /usr/lib/apache2/modules/mod_slotlimit.so</p></blockquote>
</td>
</tr>
</tbody>
</table>
<h3>2. Configuration</h3>
<p>Before we are able to write our configuration, we should known what directives are supported by this module.</p>
<p>For more information read mod_slotlimit’s documentation:</p>
<p>AvailableSlotsPercent – Percentage of apache slots available in order to activate dynamic slot allocation algorithm<br />
MaxConnectionsPerSite – Max connections for each running site<br />
LimitSite – Specific site to limit<br />
LimitSiteConnections – Max connections for “LimitSite”<br />
ClientIpLimit – Number of maximum simultaneous connection per IP<br />
ForceVhostName – Force vhost hostname in scoreboard. Useful when vhost hostname do not match site visited, for example if you’re using mod_vhost_alias</p>
<p>Now we open config file of our web server in order to write the configuration:</p>
<p>vi /etc/apache2/apache2.conf</p>
<table width="90%" border="1" cellspacing="0" cellpadding="2" bgcolor="#cccccc">
<tbody>
<tr>
<td>
<blockquote><p>[...]<br />
&lt;IfModule mod_slotlimit.c&gt;<br />
AvailableSlotsPercent 15<br />
MaxConnectionsPerSite 30<br />
LimitSite www.BadSite.xxx<br />
LimitSiteConnections 15<br />
ClientIpLimit 15<br />
ForceVhostName On<br />
&lt;/IfModule&gt;<br />
[...]</p></blockquote>
</td>
</tr>
</tbody>
</table>
<p>Finally we restart Apache:</p>
<p>/etc/init.d/apache2 restart</p>
<h3>3. Links</h3>
<ul>
<li>mod_slotlimit: <a rel="nofollow" target="_blank" href="http://sourceforge.net/projects/mod-slotlimit/" target="_blank">http://sourceforge.net/projects/mod-slotlimit/</a></li>
<li>Apache: <a rel="nofollow" target="_blank" href="http://httpd.apache.org/" target="_blank">http://httpd.apache.org</a></li>
<li>Debian: <a rel="nofollow" target="_blank" href="http://www.debian.org/" target="_blank">http://www.debian.org</a></li>
</ul>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/web-server/apache/how-to-manage-apache-resources-limits-with-mod_slotlimit-debian-etch-2.html" title="msc_pcre c:70: error: invalid application of âsizeofâ to incomplete type âpcre_extraâ">msc_pcre c:70: error: invalid application of âsizeofâ to incomplete type âpcre_extraâ</a> (2)</li><li><a href="http://thegioinguonmo.com/web-server/apache/how-to-manage-apache-resources-limits-with-mod_slotlimit-debian-etch-2.html" title="apache mod_slotlimit so windows">apache mod_slotlimit so windows</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/web-server/apache/how-to-manage-apache-resources-limits-with-mod_slotlimit-debian-etch-2.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Host Based Intrusion Detection &#8211; Samhain</title>
		<link>http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html</link>
		<comments>http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html#comments</comments>
		<pubDate>Sun, 08 Jan 2012 15:28:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Samhain]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2197</guid>
		<description><![CDATA[I am not going to ramble on about what host based intrusion detection is or why to use it, as there are plenty of articles already covering those subjects. This article is just to show you how to get Samhain up and running in a client / server configuration with a couple bells and whistles [...]]]></description>
			<content:encoded><![CDATA[<p>I am not going to ramble on about what host based intrusion detection is or why to use it, as there are plenty of articles already covering those subjects. This article is just to show you how to get Samhain up and running in a client / server configuration with a couple bells and whistles thrown in for fun.</p>
<p><strong>I highly recommend you read the entire guide before you start, it will most certainly help.</strong></p>
<p>There is a lot of swapping between client and server as I try my best to confuse you, so stay sharp!</p>
<p>&nbsp;</p>
<h3>Prerequisites</h3>
<p>You will need all the required build tools installed as we are going to compile Samhain. Here is a quick refresher:</p>
<p>Red Hat</p>
<p>yum groupinstall &#8220;Development Tools&#8221;</p>
<p>Debian</p>
<p>apt-get install build-essential</p>
<p><strong>NOTE:</strong> Please keep in mind that development tools on production servers is perhaps not the best of ideas. These packages may further assist the wannebe hacker, fill up precious megabyte or eat your cat. It is recommended to build the required packages on your build server, test them, create rpm / deb package and then deploy said packages on your production environment.</p>
<p>Here is a short check list to follow:</p>
<ol>
<li>You will need MySQL and Apache running on your server. This guide will assume a vanilla MySQL and Apache configuration. I leave it up to the reader to figure out how to install and configure these services on your favourite distribution.</li>
<li>You will need the MySQL development package (generaly mysql-devel) installed for the server side of things.</li>
<li>MySQL must have a root password set. If the MySQL root password is not set, go and do that first. While your at MySQL, you may want to look at this : /usr/bin/mysql_secure_installation</li>
<li>The server and client(s) host name must be fully qualified.</li>
<li>The server and client(s) /etc/host file must be correct (really correct, not Red Hat default correct), and DNS must be working for both forward and reverse lookups.</li>
<li>Port 50888 TCP should be open, or whatever port you set when building.</li>
<li>ImageMagick is required on the client.</li>
</ol>
<p>&nbsp;</p>
<h3>Download And Install</h3>
<p><a rel="nofollow" target="_blank" href="http://www.la-samhna.de/samhain/s_download.html" target="_blank">http://www.la-samhna.de/samhain/s_download.html</a></p>
<p>The above page has a full description of where to download the latest version of Samhain, and how to verify the integrity of the package. <strong>It is critical that the integrity of the package is checked</strong>. If you do not have a good foundation to build on, your house will surely crumble <img src='http://thegioinguonmo.com/wp-includes/images/smilies/icon_smile.gif' alt="icon smile Host Based Intrusion Detection   Samhain" class='wp-smiley' title="Host Based Intrusion Detection   Samhain" /> </p>
<p>&nbsp;</p>
<h3>Server Setup</h3>
<p>Yule is the server side component of Samhain.</p>
<p>After you have extracted and checked the package, make sure you are the <strong>root</strong> user, in the top level directory of the unpacked source files.</p>
<p>We start by creating a user for the service, and generating a gpg key as that user:</p>
<pre class="brush:shell">adduser yule
su - yule
gpg --gen-key</pre>
<p>You will be asked the following questions:</p>
<p>gpg (GnuPG) 1.4.5; Copyright (C) 2006 Free Software Foundation, Inc.<br />
This program comes with ABSOLUTELY NO WARRANTY.<br />
This is free software, and you are welcome to redistribute it<br />
under certain conditions. See the file COPYING for details.<br />
gpg: directory `/home/mytest/.gnupg&#8217; created<br />
gpg: new configuration file `/home/yule/.gnupg/gpg.conf&#8217; created<br />
gpg: WARNING: options in `/home/yule/.gnupg/gpg.conf&#8217; are not yet active during this run<br />
gpg: keyring `/home/yule/.gnupg/secring.gpg&#8217; created<br />
gpg: keyring `/home/yule/.gnupg/pubring.gpg&#8217; created<br />
Please select what kind of key you want:<br />
(1) DSA and Elgamal (default)<br />
(2) DSA (sign only)<br />
(5) RSA (sign only)<br />
Your selection? &lt;&#8211; The default is fine, just press <strong>ENTER</strong><br />
DSA keypair will have 1024 bits.<br />
ELG-E keys may be between 1024 and 4096 bits long.<br />
What keysize do you want? (2048) <strong>4096 </strong>&lt;&#8211; 4096 For the paranoid<br />
Requested keysize is 4096 bits<br />
Please specify how long the key should be valid.<br />
0 = key does not expire<br />
&lt;n&gt; = key expires in n days<br />
&lt;n&gt;w = key expires in n weeks<br />
&lt;n&gt;m = key expires in n months<br />
&lt;n&gt;y = key expires in n years<br />
Key is valid for? (0) <strong>2y </strong>&lt;&#8211; Some may feel 2 years is to long, it&#8217;s up to you &#8230;<br />
Key expires at Sat 15 Dec 2012 22:24:38 GMT<br />
Is this correct? (y/N) <strong>y </strong>&lt;&#8211; If you are happy and you know it clap your hands<br />
You need a user ID to identify your key; the software constructs the user ID<br />
from the Real Name, Comment and Email Address in this form:<br />
&#8220;Heinrich Heine (Der Dichter)&lt;heinrichh@duesseldorf.de&gt;&#8221;</p>
<p>Real name: <strong>yules </strong>&lt;&#8211; Whatever name you want to use<br />
Email address: <strong>yules@you.com </strong> &lt;&#8211; Some e-mail address<br />
Comment: <strong>20 questions </strong> is a fun game<br />
You selected this USER-ID:<br />
&#8220;yules (20 questions) &lt;yules@you.com&gt;&#8221;</p>
<p>Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? <strong>O </strong>&lt;&#8211; If you are happy, OK it<br />
You need a Passphrase to protect your secret key.</p>
<p>Enter passphrase: <strong>This is a long passphrase ! </strong>&lt;&#8211; Enter a strong passphrase<br />
We need to generate a lot of random bytes. It is a good idea to perform<br />
some other action (type on the keyboard, move the mouse, utilize the<br />
disks) during the prime generation; this gives the random number<br />
generator a better chance to gain enough entropy.<br />
++++++++++++++++++++++++++++++++++++++++.++++++++++.++++++++++.++++++++++..+++++.+++++++++++++++.++++++++++.++++++++++++++++++++++++++++++<br />
++++++++++&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..+++++</p>
<p>Not enough random bytes available. Please do some other work to give<br />
the OS a chance to collect more entropy! (Need 284 more bytes)</p>
<p>gpg: /home/yule/.gnupg/trustdb.gpg: trustdb created<br />
gpg: key B7043C9A marked as ultimately trusted<br />
public and secret key created and signed.</p>
<p>gpg: checking the trustdb<br />
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model<br />
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u<br />
gpg: next trustdb check due at 2012-12-15<br />
pub 1024D/B7043C9A 2010-12-16 [expires: 2012-12-15]<br />
Key fingerprint = 421E CFE8 533E 017F 95C8 170A DB54 28E7 B704 3C9A<br />
uid yules (20 questions) &lt;yules@you.com&gt;<br />
sub 4096g/EB230E29 2010-12-16 [expires: 2012-12-15]</p>
<p>Quit this shell, so that we are back to the root user.</p>
<p>exit</p>
<p>So now we have a gpg key, lets get on with building the packages.</p>
<p>The default gpg binary does not support the TIGER192 checksum. As such, we first build a vanilla Samhain binary so that we can get that capability from the Samhain binary.</p>
<pre class="brush:shell">./configure
make</pre>
<p>Right, now we build the real thing &#8230;</p>
<pre class="brush:shell">./configure --with-gpg=/usr/bin/gpg --enable-network=server --with-database=mysql --enable-xml-log --with-port=50888 --enable-identity=yule
make
make install</pre>
<p>At this point, the following should come up:</p>
<p>You need to sign the configuration file now<br />
/usr/bin/gpg -a &#8211;clearsign yulerc<br />
using &#8211;homedir /home/yule/.gnupg<br />
gpg: WARNING: unsafe ownership on homedir `/home/yule/.gnupg&#8217;<br />
You need a passphrase to unlock the secret key for<br />
user: &#8220;yules (20 questions) &lt;yules@you.com&gt;&#8221;<br />
1024-bit DSA key, ID BAFB6B91, created 2010-12-21<br />
Enter passphrase: <strong>This is a long passphrase ! </strong>&lt;&#8211; This is the passphrase we set earlier.</p>
<p><strong>Side note: </strong> I am unsure why gpg is complaining about the ownership, as the permissions is just fine.</p>
<p>Now install the initialization script, set up MySQL user / permission and fix some file permissions.</p>
<pre class="brush:shell">make install-boot
mysql -p &lt; sql_init/samhain.mysql.init
echo "grant select, insert on samhain.log to samhain@localhost IDENTIFIED BY 'samhain';" | mysql -p &lt;-- This will ask for your root MySQL password.
echo "FLUSH PRIVILEGES;" | mysql -p &lt;-- This will ask for your root MySQL password.
chown yule:yule /var/log/yule
chown yule:yule /etc/yulerc
chown yule:yule /var/lib/yule</pre>
<p>Set yule to start at boot.</p>
<p>Red Hat</p>
<pre class="brush:shell">chkconfig --add yule
chkconfig yule on</pre>
<p>Debian</p>
<p>update-rc.d yule defaults</p>
<p>Start yule with:</p>
<p>/etc/init.d/yule start</p>
<p>Yule may complain with something like :</p>
<p>&lt;log sev=&#8221;WARN&#8221; tstamp=&#8221;2010-12-21T11:46:42+0000&#8243; msg=&#8221;Invalid line 102 in configuration file: incorrect format, unrecognized option, or missing section header&#8221; /&gt;<br />
&lt;log sev=&#8221;WARN&#8221; tstamp=&#8221;2010-12-21T11:46:42+0000&#8243; msg=&#8221;Invalid line 106 in configuration file: incorrect format, unrecognized option, or missing section header&#8221; /&gt;</p>
<p>However, the service should start fine. These two warnings are due to the [Database] header being commented out. Either uncomment it, or comment said two lines out. They are true by default.</p>
<p>For a list of configuration options with full explanations, see <a rel="nofollow" target="_blank" href="http://la-samhna.de/samhain/manual/compilation-options.html" target="_blank">http://la-samhna.de/samhain/manual/compilation-options.html</a></p>
<p>&nbsp;</p>
<h3>Apache Configuration</h3>
<p>Add the following in:</p>
<p>Red Hat</p>
<p>/etc/httpd/conf.d/samhain.conf</p>
<p>Debian</p>
<p>/etc/apache2/conf.d/samhain.conf</p>
<pre>&lt;Directory "/var/log/yule/"&gt;
   Options ExecCGI
   AllowOverride None
   Order allow,deny
   Allow from all
&lt;/Directory&gt;
Alias /yule.html "/var/log/yule/yule.html"</pre>
<p>Then reload Apache with:</p>
<p>Red Hat</p>
<p>service httpd restart</p>
<p>Debian</p>
<p>/etc/init.d/apache2 restart</p>
<p>Now visit http://yourserver/yule.hml</p>
<h3>Client Setup</h3>
<div></div>
<p>Log in on the server you wish to install the Samhain client on and make sure you are the <strong>root</strong> user. Also make sure you have all the essential build packages installed, refer to the overview for installation of these essential build packages.</p>
<p>First, we need a gpg key for root.</p>
<p>See previous example for detailed steps.</p>
<p>gpg &#8211;gen-key</p>
<p>Now we need to pull out the fingerprint for this key, so that we can use it when building the Samhain binary.</p>
<p>MY_FP=`gpg &#8211;fingerprint root | grep fingerpr | sed &#8216;s/ //g&#8217; | awk &#8216;BEGIN { FS = &#8220;=&#8221; } ; {print $2}&#8217;`</p>
<p>As before, we need TIGER192 checksum capability first.</p>
<p>./configure<br />
make</p>
<p>Now, since we are having a bit of fun, we are going to change the name of the binary and process. Classical security by obscurity. I&#8217;m picking the name <strong>john</strong>, a general purpose password cracker. Pick a name that will not stand out in a process listing and shout out &#8220;THIS IS A HIDS PROCESS !!!!11&#8243;. Then again, know how much/little a name change actually hides what this binary does before you rely on it to hide you&#8217;re HIDS from a l33t haxor.</p>
<p>We further specify that the configuration and data files should be pulled from the server. If you want to take this one step further, look into the following compile options : &#8211;enable-khide,&#8211;enable-suidcheck and &#8211;with-kcheck=/path/to/System.map</p>
<p>Make sure to change <strong>IP_OF_YOUR_SERVER</strong> to the actual IP address of your Yule server.</p>
<p>./configure &#8211;with-gpg=/usr/bin/gpg &#8211;enable-network=client &#8211;with-config-file=REQ_FROM_SERVER &#8211;with-data-file=REQ_FROM_SERVER/var/lib/john/john \<br />
&#8211;enable-stealth=129 &#8211;enable-install-name=john &#8211;enable-srp &#8211;with-fp=$MY_FP &#8211;with-port=50888 \<br />
&#8211;with-logserver=<strong>IP_OF_YOUR_SERVER</strong> &#8211;with-sender=john<br />
make</p>
<p>Make the required directories, copy the binary over (with the correct name) and put the initialization script in place.</p>
<pre class="brush:shell">mkdir /var/lib/john/
cp init/samhain.startLinux /etc/init.d/john
chmod 744 /etc/init.d/john
cp samhain /usr/local/sbin/john
cp samhain_setpwd /usr/local/sbin/john_setpwd
cp samhain_stealth /usr/local/sbin/john_stealth
cd /usr/local/sbin</pre>
<p>Set the password and overwrite the binary.</p>
<pre class="brush:shell">/usr/local/sbin/john_setpwd john jingle 161718abcd212324
mv john.jingle john</pre>
<p>&#8220;jingle&#8221; Does not matter, it&#8217;s just the append and the number is what you want in 16 bit 0-9, A-F (A.K.A HEX). You can use yule -G on the server to generate a random number for you.</p>
<p>The output should look something like:</p>
<p>INFO old password found<br />
INFO replaced: f7c312aaaa12c3f7 by: 161718abcd212324<br />
INFO finished</p>
<p>Change the description in the initialization script.</p>
<p>sed -i &#8216;s/File Integrity Checking/Password Cracking/&#8217; /etc/init.d/john</p>
<p>Make sure the daemon starts at boot.</p>
<p>Red Hat</p>
<pre class="brush:shell">chkconfig --add john
chkconfig john on</pre>
<p>Debian</p>
<pre class="brush:shell">update-rc.d john defaults</pre>
<p>&nbsp;</p>
<h3>A Little Work On The Server</h3>
<p>The HEX key we just embedded in the client binary, we need it now to tell the server about that client.</p>
<p>/usr/local/sbin/yule -P 161718abcd212324 | sed &#8216;s/HOSTNAME/<strong>CliENT_HOSTNAME_HERE</strong>/&#8217; &gt;&gt; /etc/yulerc &lt;&#8211; Make sure to put the client host name (FQDN) in.</p>
<p>Edit /etc/yulerc and move the key above the GPG signature.</p>
<p>For example, the last couple of lines of /etc/yulerc mihgt look like this:</p>
<pre># Client=HOSTNAME@00000000@C39F0EEFBC64E4A8BBF72349637CC07577F714B420B62882
# Client=HOSTNAME@8F81BA58956F8F42@8932D08C49CA76BD843C51EDD1D6640510FA032A7A2403E572BBDA2E5C6B753991CF7E091141D20A2499C5CD3E14C1639D17482E14E1548E5246ACF4E7193D524CDDAC9C9D6A9A36C596B4ECC68BEB0C5BB7082224946FC98E3ADE214EA1343E2DA8DF4229D4D8572AD8679228928A787B6E5390D3A713102FFCC9D0B2188C92
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
iD8DBQFNEI7oerU1Wrr7a5ERAkWqAJ9sZEuRLp8rPOjXdUokT03bEfjGuwCfa+Tr
pDK7/KmGj3Hx8vRMufxNx7A=
=zI4S
-----END PGP SIGNATURE-----
Client=rhc2.sys.local@F1DF72033799940C@37FC42534A812B2351007A24820537466495F97ED352EFC1D9DCAEACBBF5CB98AEF183057CE6D101151F112693C2DAE361435CED1C95E822272FE287A56B4D38EE91B00830A56AE2F26E4738DF099CAEF3372342BE0ACDB78C12FD176EED1FBA376A0399537F848B6FA9AD4E61E6C771A5566F43D62C1F9836AB976CB1111545</pre>
<p>We need to change that to look like this:</p>
<pre># Client=HOSTNAME@00000000@C39F0EEFBC64E4A8BBF72349637CC07577F714B420B62882
# Client=HOSTNAME@8F81BA58956F8F42@8932D08C49CA76BD843C51EDD1D6640510FA032A7A2403E572BBDA2E5C6B753991CF7E091141D20A2499C5CD3E14C1639D17482E14E1548E5246ACF4E7193D524CDDAC9C9D6A9A36C596B4ECC68BEB0C5BB7082224946FC98E3ADE214EA1343E2DA8DF4229D4D8572AD8679228928A787B6E5390D3A713102FFCC9D0B2188C92
Client=rhc2.sys.local@F1DF72033799940C@37FC42534A812B2351007A24820537466495F97ED352EFC1D9DCAEACBBF5CB98AEF183057CE6D101151F112693C2DAE361435CED1C95E822272FE287A56B4D38EE91B00830A56AE2F26E4738DF099CAEF3372342BE0ACDB78C12FD176EED1FBA376A0399537F848B6FA9AD4E61E6C771A5566F43D62C1F9836AB976CB1111545
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
iD8DBQFNEI7oerU1Wrr7a5ERAkWqAJ9sZEuRLp8rPOjXdUokT03bEfjGuwCfa+Tr
pDK7/KmGj3Hx8vRMufxNx7A=
=zI4S
-----END PGP SIGNATURE-----</pre>
<p>The following steps are always required when you&#8217;ve made changes to the configuration files.</p>
<p>Edit /etc/yulerc and remove the first 3 and last 7 lines, this is the GPG/PGP signature.</p>
<p>Example:</p>
<pre>-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
There will be another line here later on.
#####################################################################
#
# Configuration file template for yule.
#
#####################################################################

Lots of Yule configuration removed ...

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
iD8DBQFNEI7oerU1Wrr7a5ERAkWqAJ9sZEuRLp8rPOjXdUokT03bEfjGuwCfa+Tr
pDK7/KmGj3Hx8vRMufxNx7A=
=zI4S
-----END PGP SIGNATURE-----</pre>
<p>Then sign the configuration file again with the user yule and copy the file in place as the <strong>root</strong> user:</p>
<p>su &#8211; yule<br />
gpg -o yulerc.asc -a &#8211;clearsign &#8211;not-dash-escaped /etc/yulerc &lt;&#8211; Type in the passphrase we set earlier.<br />
exit<br />
/bin/mv /home/yule/yulerc.asc /etc/yulerc<br />
service yule reload</p>
<p>&nbsp;</p>
<h3>A Little More Work On The Client</h3>
<p>We will need to create the configuration file and embed it into a postscript file. Make sure you have Imagemagick installed, as you will need convert.</p>
<p>Go and download a good looking picture like <a rel="nofollow" target="_blank" href="http://apod.nasa.gov/apod/image/0903/tycho_chandra_big.jpg" target="_blank">http://apod.nasa.gov/apod/image/0903/tycho_chandra_big.jpg</a>. You will want at least a 200K size image, if not larger, to hide the configuration file in it. Also, it is handy to have an original configuration file as backup.</p>
<p><strong>NOTE:</strong> The following steps has to be done each time you wish to modify the configuration file of the client.</p>
<p>cd <strong>TOPLEVEL_OF_SOURCE_DIR</strong><br />
wget http://apod.nasa.gov/apod/image/0903/tycho_chandra_big.jpg<br />
convert tycho_chandra_big.jpg tycho_chandra_big.ps &lt;&#8211; Convert the JPG to a postscript file.<br />
cp samhainrc.linux rc.`hostname` &lt;&#8211; Get a default configuration.<br />
gpg -a &#8211;clearsign &#8211;not-dash-escaped rc.`hostname` &lt;&#8211; Clear sign the configuration.<br />
mv rc.`hostname`.asc rc.`hostname` &lt;&#8211; Move the signed file to the normal file name for the configuration file.<br />
/usr/local/sbin/john_stealth -s tycho_chandra_big.ps rc.`hostname`&lt;&#8211; Steganographically hide the configuration file inside the postscript file.<br />
rm rc.`hostname` tycho_chandra_big.* &lt;&#8211; Remove the &#8220;clean&#8221; files.</p>
<p>Make sure that the resulting postscript file is not very large, or Samhain will fail to download it. I do not have exact numbers, but from experience 66Mb is too large <img src='http://thegioinguonmo.com/wp-includes/images/smilies/icon_smile.gif' alt="icon smile Host Based Intrusion Detection   Samhain" class='wp-smiley' title="Host Based Intrusion Detection   Samhain" /> </p>
<p>Now copy the file over to your server:</p>
<p>scp tycho_chandra_big.ps <strong>YULE_SERVER</strong>:~/rc.`hostname` &lt;&#8211; Assuming scp with root. In real life, please do not open ssh for root.</p>
<p>Back to the <strong>server</strong>:</p>
<p>cp ~/rc.<strong>CliENT_FQDN</strong> /var/lib/yule/ &lt;&#8211; Make sure to fill in the clients FQDN.<br />
chown yule:yule /var/lib/yule/rc.<strong>CliENT_FQDN</strong> &lt;&#8211; Make sure to fill in the clients FQDN.</p>
<p>Back to the <strong>client</strong>:</p>
<p>/usr/local/sbin/john -t init -p info</p>
<p>This will now build the database in /var/lib/john. Don&#8217;t worry about all the output at this stage, we are just getting things up and running now.</p>
<p>After we have a database, we have to sign it and copy it over to the server.</p>
<p>gpg -a &#8211;clearsign &#8211;not-dash-escaped /var/lib/john/john<br />
scp /var/lib/john/john.asc <strong>YULE_SERVER</strong>:~/file.`hostname` &lt;&#8211; Assuming scp with root. In real life, please do not open ssh for root.<br />
rm /var/lib/john/john*</p>
<p>Back to the <strong>server</strong>, we move this file to the correct place:</p>
<p>mv ~/file.<strong>CliENT_FQDN</strong> /var/lib/yule<br />
chown yule:yule /var/lib/yule/*</p>
<p>It is important that all configuration files start with rc and all database files start with file.</p>
<p>&nbsp;</p>
<h3>Troubleshooting</h3>
<p>Trouble, what trouble?</p>
<ol>
<li>Start with tailing the log file on the server : tail -f /var/log/yule/yule_log</li>
<li>Change the log level in /etc/yulerc to info or above (always remember to re-sign the configuration file as described).</li>
<li>Recompile without some of the options to test.</li>
<li>Have a look at this link : <a rel="nofollow" target="_blank" href="http://www.la-samhna.de/samhain/s_documentation.html" target="_blank">http://www.la-samhna.de/samhain/s_documentation.html</a></li>
</ol>
<p>&nbsp;</p>
<h3>Clean Up</h3>
<p>Now we don&#8217;t want to be leaving breadcrumbs behind us, some clean up is required.</p>
<ol>
<li>Delete all the source files and any tarballs that was downloaded if you built directly on a production server.</li>
<li>Delete <strong>all</strong> entries from your shell history.</li>
<li>Remove all the development packages that was installed if you built directly on a production server.</li>
<li>Remove /usr/local/sbin/john_stealth and /usr/local/sbin/john_setpwd.</li>
</ol>
<p>Basically, get rid of any evidence of what you just did.</p>
<p>&nbsp;</p>
<h3>Tuning</h3>
<p>Arguably, this is where the guide should start. Samhain does not understand what is right and what is wrong for this particular server. As such, you need to tune it. The simplest way is to build Samhain without any options what so ever like:</p>
<p>./configure<br />
make<br />
mkdir /var/lib/samhain/</p>
<p>Put the configuration file in /etc/samhainrc, and run</p>
<p>samhain -t init -p info &gt; my_output 2&gt;&amp;1</p>
<p>You can then examine the output file and make the appropriate changes to the Samhain configuration file. The database will be created in /var/lib/samhain. Do not run samhain -t init more than once without deleting the database.</p>
<p>Once you are happy with the configuration, build Samhain in server / client mode.</p>
<p><strong>NOTE:</strong> It is however rather important that you profile your server and tune Samhain before it is connected to the Internet.</p>
<p>&nbsp;</p>
<h3>Honey Pot!</h3>
<p>Now for a bit of fun. We really <strong>do</strong> want intruders to let us know they are on our system. So, we create 2 (or more) files with catchy names and tell Samhain to monitor those files for <strong>any</strong> changes (that includes access times).</p>
<p>cp /etc/passwd /home/cracked_passwords<br />
cp /etc/hosts /home/customers/credit_cards_2008.xls</p>
<p>Now, in Samhain&#8217;s configuration file, there is a section called [IgnoreNone], add these files in that section. You can test this by simply catting those files and then run the check. The output should be something like:</p>
<p>CRIT : [2009-04-27T21:33:11+0100] msg=&lt;POliCY [User1] &#8212;&#8212;&#8211;T-&gt;, path=&lt;/home/cracked_passwords&gt;, atime_old=&lt;[2009-04-27T20:25:39]&gt;,<br />
atime_new=[2009-04-27T20:32:37]&gt;,</p>
<p>&nbsp;</p>
<h3>Nagios Integration</h3>
<p>I have not tested this yet, this is just on top of my head, so it may well be very wrong.</p>
<p>So now we have alerts for when things go wrong. By default, the standard Nagios plugin pack ships with check_log. Our Nagios check command will look something like:</p>
<pre>check_log -F /var/log/yule_log -O /var/log/yule/yule_nagios_diff_log -q "ERROR|CRIT|ALERT"</pre>
<p>You will need to modify how to alert on this particular service. By default Nagios will check 3 times before alerting, but with check_log you will never get an alert. The reason is as follows:</p>
<ol>
<li>check 1: The check returns an error, as it spotted your query (lets say CRIT) in the difference from the old stored log file and the current running log file. The check command now updates the old stored log file.</li>
<li>check 2: There is no longer a difference between the old stored log file and the current running one, thus the check passes OK.</li>
</ol>
<p>Either modify Nagios to alert after a single failure, or write a wrapper specifically for this check to create a lock file somewhere. You then check for this lock file and alert if it exists. Both approaches have some down sides. If we alert on a single check, be prepared for false alerts due to packet loss or a shift in the force. If we create a lock file, you will have to manually remove it.</p>
<p>Now that we are monitoring the log file for changes detected, we also need to monitor that the client process is still up and running. Of course, you will also want to monitor that the server process is running all the time.</p>
<p>I am sure someone will come up with a better way of Nagios integration, like I said, this is just thinking out loud.</p>
<p>&nbsp;</p>
<h3>What It All Means</h3>
<p>At the end of the day, the clear text configuration of each machine being monitored, is neither kept on the client nor on the server. The clear text configuration files should be kept on a different machine inside an encrypted partition.</p>
<p>Nagios makes sure we are alerted of anything (via e-mail or SMS) and hopefully, an intruder will bite on the honey so that we can see him, potentially, even quicker.</p>
<p>Further more, you can not access any help files (such as ./samhain &#8211;help or man pages) to indicate that there is a HIDS running on the client.</p>
<p>Of course, if you get access to the server, you can see all the clients who logs in. There are further compiler options so that the logs are also encrypted.</p>
<p>&nbsp;</p>
<h3>Layers</h3>
<p>In the voice of Shrek: &#8220;Security is like an onion, it has many layers.&#8221; Remember that host based intrusion detection is just one more layer in this onion. You also need a good firewall, network intrusion detection, monitoring, centralised logging, log analysis, TCP wrappers, SELinux (or some other mandatory access control mechanism), brute force blockers like fail2ban and much more.</p>
<p>As an example of this, the entire host based intrusion detection is rendered moot if the hacker just kills the process and you are not using monitoring to make sure that the service is running.</p>
<p>Please do not hesitate to contact me with any corrections or improvements or even some constructive criticism. <img src='http://thegioinguonmo.com/wp-includes/images/smilies/icon_smile.gif' alt="icon smile Host Based Intrusion Detection   Samhain" class='wp-smiley' title="Host Based Intrusion Detection   Samhain" /> </p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="samhain centos">samhain centos</a> (2)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="centos intrusion detection">centos intrusion detection</a> (2)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="installing samhain centos">installing samhain centos</a> (2)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="SAMHAIN windows">SAMHAIN windows</a> (2)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="samhain plesk">samhain plesk</a> (2)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="samhain install on windows machine">samhain install on windows machine</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="samhain linux">samhain linux</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="samhain network">samhain network</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="samhain rhel6">samhain rhel6</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html" title="samhain server reverse lookup failed">samhain server reverse lookup failed</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/os/linux/host-based-intrusion-detection-samhain.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Move or migrate user accounts from old Linux server to a new Linux server</title>
		<link>http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html</link>
		<comments>http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html#comments</comments>
		<pubDate>Tue, 27 Dec 2011 04:39:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[passwd]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[user]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=86</guid>
		<description><![CDATA[Q. How do I Move or migrate user accounts to from old Linux server a new Cent OS Linux server including mails? This new system a fresh installation. A. You can migrate users from old Linux server to new Linux sever with standard commands such as tar, awk, scp and others. This is also useful [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span style="color: #ff0000;">Q.</span></strong> How do I Move or migrate user accounts to from old Linux server a new Cent OS Linux server including mails? This new system a fresh installation.</p>
<p><strong><span style="color: #008000;">A.</span></strong> You can migrate users from old Linux server to new Linux sever with standard commands such as tar, awk, scp and others. This is also useful if you are using old Linux distribution such as Redhat 9 or Debian 2.x.</p>
<p>&nbsp;</p>
<p>Following files/dirs are required for traditional Linux user management:<br />
* <strong><a rel="nofollow" target="_blank" href="http://www.cyberciti.biz/faq/understanding-etcpasswd-file-format/">/etc/passwd</a></strong> – contains various pieces of information for each user account</p>
<p>* <strong><a rel="nofollow" target="_blank" href="http://www.cyberciti.biz/faq/understanding-etcshadow-file/">/etc/shadow</a></strong> – contains the encrypted password information for user’s accounts and optional the password aging information.</p>
<p>* <strong><a rel="nofollow" target="_blank" href="http://www.cyberciti.biz/faq/understanding-etcgroup-file/">/etc/group</a></strong> – defines the groups to which users belong</p>
<p>* <strong>/etc/gshadow</strong> – group shadow file (contains the encrypted password for group)</p>
<p>* <strong>/var/spool/mail</strong> – Generally user emails are stored here.</p>
<p>* <strong>/home</strong> – All Users data is stored here.</p>
<p>You need to backup all of the above files and directories from old server to new Linux server.</p>
<h3>Commands to type on old Linux system</h3>
<p>First create a tar ball of old uses (old Linux system). Create a directory:<br />
<code># mkdir /root/move/</code><br />
Setup UID filter limit:<br />
<code># export UGIDLIMIT=500</code><br />
Now copy /etc/passwd accounts to /root/move/passwd.mig using awk to filter out system account (i.e. only copy user accounts)<br />
<code># awk -v LIMIT=$UGIDLIMIT -F: '($3&gt;=LIMIT) &amp;&amp; ($3!=65534)' /etc/passwd &gt; /root/move/passwd.mig</code><br />
Copy /etc/group file:<br />
<code># awk -v LIMIT=$UGIDLIMIT -F: '($3&gt;=LIMIT) &amp;&amp; ($3!=65534)' /etc/group &gt; /root/move/group.mig</code><br />
Copy /etc/shadow file:<br />
<code># awk -v LIMIT=$UGIDLIMIT -F: '($3&gt;=LIMIT) &amp;&amp; ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow &gt; /root/move/shadow.mig</code><br />
Copy /etc/gshadow (rarely used):<br />
<code># cp /etc/gshadow /root/move/gshadow.mig</code><br />
Make a backup of /home and /var/spool/mail dirs:<br />
<code># tar -zcvpf /root/move/home.tar.gz /home<br />
# tar -zcvpf /root/move/mail.tar.gz /var/spool/mail</code></p>
<p>Where,</p>
<ul>
<li>Users that are added to the Linux system always start with UID and GID values of as specified by Linux distribution or set by admin. Limits according to different Linux distro:
<ul>
<li><strong>RHEL/CentOS/Fedora Core</strong> : Default is 500 and upper limit is 65534 (/etc/libuser.conf).</li>
<li><strong>Debian and Ubuntu Linux</strong> : Default is 1000 and upper limit is 29999 (/etc/adduser.conf).</li>
</ul>
</li>
<li>You should never ever create any new system user accounts on the newly installed Cent OS Linux. So above awk command filter out UID according to Linux distro.</li>
<li><strong>export UGIDLIMIT=500 </strong> – setup UID start limit for normal user account. Set this value as per your Linux distro.</li>
<li><strong>awk -v LIMIT=$UGIDLIMIT -F: ‘($3&gt;=LIMIT) &amp;&amp; ($3!=65534)’ /etc/passwd &gt; /root/move/passwd.mig</strong> – You need to pass UGIDLIMIT variable to awk using -v option (it assigns value of shell variable UGIDLIMIT to awk program variable LIMIT). Option -F: sets the field separator to : . Finally awk read each line from /etc/passwd, filter out system accounts and generates new file /root/move/passwd.mig. Same logic is applies to rest of awk command.</li>
<li><strong>tar -zcvpf /root/move/home.tar.gz /home</strong> – Make a backup of users /home dir</li>
<li><strong>tar -zcvpf /root/move/mail.tar.gz /var/spool/mail</strong> – Make a backup of users mail dir</li>
</ul>
<p>Use scp or usb pen or tape to copy /root/move to a new Linux system.<br />
<code># scp -r /root/move/* user@new.linuxserver.com:/path/to/location</code></p>
<h3>Commands to type on new Linux system</h3>
<p>First, make a backup of current users and passwords:<br />
<code># mkdir /root/newsusers.bak<br />
# cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak<br />
</code><br />
Now restore passwd and other files in /etc/<br />
<code># cd /path/to/location<br />
# cat passwd.mig &gt;&gt; /etc/passwd<br />
# cat group.mig &gt;&gt; /etc/group<br />
# cat shadow.mig &gt;&gt; /etc/shadow<br />
# /bin/cp gshadow.mig /etc/gshadow</code></p>
<p>Please note that you must use <strong>&gt;&gt;</strong> (append) and not <strong>&gt;</strong> (create) shell redirection.</p>
<p>Now copy and extract home.tar.gz to new server /home<br />
<code># cd /<br />
# tar -zxvf /path/to/location/home.tar.gz</code></p>
<p>Now copy and extract mail.tar.gz (Mails) to new server /var/spool/mail<br />
<code># cd /<br />
# tar -zxvf /path/to/location/mail.tar.gz</code></p>
<p>Now reboot system; when the Linux comes back, your user accounts will work as they did before on old system:<br />
<code># reboot</code></p>
<p>Please note that if you are new to Linux perform above commands in a sandbox environment. Above technique can be used to UNIX to UNIX OR UNIX to Linux account migration. You need to make couple of changes but overall the concept remains the same.</p>
<h3>Further readings</h3>
<ul>
<li>Read man pages of awk, passwd(5), shadow(5), group(5), tar command</li>
</ul>
<p>Updated for accuracy.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="move or migrate user accounts from old server to a new centos server">move or migrate user accounts from old server to a new centos server</a> (3)</li><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="cpanel user accounts /etc/passwd">cpanel user accounts /etc/passwd</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="plesk /etc/passwd">plesk /etc/passwd</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="move maildir on plesk to directadmin">move maildir on plesk to directadmin</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="migrating plesk to directadmin">migrating plesk to directadmin</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="migrate users to new centos server">migrate users to new centos server</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="migrate mail from linux plesk to cpanel">migrate mail from linux plesk to cpanel</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="migrate cpanel uid mail">migrate cpanel uid mail</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="mail migration plesk windows linux">mail migration plesk windows linux</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html" title="shell script for migrate groups /etc/group">shell script for migrate groups /etc/group</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/os/linux/move-or-migrate-user-accounts-from-old-linux-server-to-a-new-linux-server.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Install A Complete LEMP (Linux &#8211; EngineX (Nginx HTTP SERVER) &#8211; Mysql &#8211; PHP) Server (Not LAMP&#8230;) On Ubuntu/Debian</title>
		<link>http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html</link>
		<comments>http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html#comments</comments>
		<pubDate>Tue, 20 Dec 2011 16:39:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[nginx]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[Postfix]]></category>
		<category><![CDATA[yourdomain]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=17</guid>
		<description><![CDATA[This HowTo will describe the setup of an efficient http server and mail server for small or medium configurations (as low as 96 mb). So this config is ideal for a small VPS. You can find a good choice of cheap and performant VPS (XEN) at x&#124;encon, a german hosting company. they provide many scalable [...]]]></description>
			<content:encoded><![CDATA[<p>This HowTo will describe the setup of an efficient http server and mail server for small or medium configurations (as low as 96 mb). So this config is ideal for a small VPS. You can find a good choice of cheap and performant VPS (XEN) at <a rel="nofollow" target="_blank" href="http://www.xencon.net/" target="_blank">x|encon</a>, a german hosting company. they provide many scalable VPS solutions with pre-installed Debian and Ubuntu disc images.</p>
<p>Why LEMP instead of LAMP? NGINX is a great replacement for Apache with very low memory footprint and great stability.</p>
<p>Note: i will use the name yourdomain.com for all configurations on a fresh minimal installation of Ubuntu Feisty Fawn server edition.</p>
<p>We will have to install first Postfix to deal with emails and then Dovecot to deliver them with pop3 only (imap uses too much memory). But before that, let&#8217;s install some useful tools we need:</p>
<p>apt-get install wget telnet build-essential</p>
<h3>1. Installation of Postfix</h3>
<p>apt-get install postfix libsasl2 sasl2-bin libsasl2-modules libdb3-util procmail</p>
<p>Now the beautiful blue screen will appear and Postfix will ask you some questions. Answer as follow:</p>
<p>General type of configuration? &lt;&#8211; Internet Site<br />
Mail name? &lt;&#8211; yourdomain.com</p>
<p>Then run:</p>
<p>dpkg-reconfigure postfix</p>
<p>Again, you&#8217;ll be asked some questions:</p>
<p>General type of configuration? &lt;&#8211; Internet Site<br />
Where should mail for root go &lt;&#8211; [blank]<br />
Mail name? &lt;&#8211; yourdomain.com<br />
Other destinations to accept mail for? (blank for none) &lt;&#8211; yourdomain.com, localhost.yourdomain.com, localhost.localdomain, localhost<br />
Force synchronous updates on mail queue? &lt;&#8211; No<br />
Local networks? &lt;&#8211; 127.0.0.0/8<br />
Use procmail for local delivery? &lt;&#8211; Yes<br />
Mailbox size limit &lt;&#8211; 0<br />
Local address extension character? &lt;&#8211; +<br />
Internet protocols to use? &lt;&#8211; all</p>
<p>Type then the following commands (you can copy everything below and paste it in your terminal in one row, it will work but don&#8217;t forget to hit enter to validate the last command):</p>
<p>postconf -e &#8216;smtpd_sasl_local_domain =&#8217;<br />
postconf -e &#8216;smtpd_sasl_auth_enable = yes&#8217;<br />
postconf -e &#8216;smtpd_sasl_security_options = noanonymous&#8217;<br />
postconf -e &#8216;broken_sasl_auth_clients = yes&#8217;<br />
postconf -e &#8216;smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination&#8217;<br />
postconf -e &#8216;inet_interfaces = all&#8217;<br />
echo &#8216;pwcheck_method: saslauthd&#8217; &gt;&gt; /etc/postfix/sasl/smtpd.conf<br />
echo &#8216;mech_list: plain login&#8217; &gt;&gt; /etc/postfix/sasl/smtpd.conf</p>
<p>Now we have to create the certificates for TLS that will be available both for Postfix and Dovecot:</p>
<p>mkdir /etc/ssl/yourdomain (the folder name can be of course anything such as the name of your mother&#8230;)<br />
cd /etc/ssl/yourdomain<br />
openssl genrsa -des3 -rand /etc/hosts -out yourdomain.key 1024</p>
<p>chmod 600 yourdomain.key<br />
openssl req -new -key yourdomain.key -out yourdomain.csr</p>
<p>openssl x509 -req -days 3650 -in yourdomain.csr -signkey yourdomain.key -out yourdomain.crt</p>
<p>openssl rsa -in yourdomain.key -out yourdomain.key.unencrypted</p>
<p>mv -f yourdomain.key.unencrypted yourdomain.key<br />
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650</p>
<p>Next we configure Postfix for TLS:</p>
<p>postconf -e &#8216;smtpd_tls_auth_only = no&#8217;<br />
postconf -e &#8216;smtp_use_tls = yes&#8217;<br />
postconf -e &#8216;smtpd_use_tls = yes&#8217;<br />
postconf -e &#8216;smtp_tls_note_starttls_offer = yes&#8217;<br />
postconf -e &#8216;smtpd_tls_key_file = /etc/ssl/yourdomain/yourdomain.key&#8217;<br />
postconf -e &#8216;smtpd_tls_cert_file = /etc/ssl/yourdomain/yourdomain.crt&#8217;<br />
postconf -e &#8216;smtpd_tls_CAfile = /etc/ssl/yourdomain/cacert.pem&#8217;<br />
postconf -e &#8216;smtpd_tls_loglevel = 1&#8242;<br />
postconf -e &#8216;smtpd_tls_received_header = yes&#8217;<br />
postconf -e &#8216;smtpd_tls_session_cache_timeout = 3600s&#8217;<br />
postconf -e &#8216;tls_random_source = dev:/dev/urandom&#8217;<br />
postconf -e &#8216;myhostname = yourdomain.com&#8217;</p>
<p>Restart Postfix:</p>
<p>/etc/init.d/postfix restart</p>
<p>Authentication will be done by saslauthd. We have to change a few things to make it work properly. Because Postfix runs chrooted in /var/spool/postfix we have to do the following:</p>
<p>mkdir -p /var/spool/postfix/var/run/saslauthd</p>
<p>Now we have to edit /etc/default/saslauthd in order to activate saslauthd. Set START to yes and change the line OPTIONS=&#8221;-c&#8221; to OPTIONS=&#8221;-c -m /var/spool/postfix/var/run/saslauthd -r&#8221;:</p>
<p>vi /etc/default/saslauthd</p>
<pre>#
# Settings for saslauthd daemon
#
# Should saslauthd run automatically on startup? (default: no)
START=yes
# Which authentication mechanisms should saslauthd use? (default: pam)
#
# Available options in this Debian package:
# getpwent  -- use the getpwent() library function
# kerberos5 -- use Kerberos 5
# pam       -- use PAM
# rimap     -- use a remote IMAP server
# shadow    -- use the local shadow password file
# sasldb    -- use the local sasldb database file
# ldap      -- use LDAP (configuration is in /etc/saslauthd.conf)
#
# Only one option may be used at a time. See the saslauthd man page
# for more information.
#
# Example: MECHANISMS="pam"
MECHANISMS="pam"
# Additional options for this mechanism. (default: none)
# See the saslauthd man page for information about mech-specific options.
MECH_OPTIONS=""
# How many saslauthd processes should we run? (default: 5)
# A value of 0 will fork a new process for each connection.
THREADS=5
# Other options (default: -c)
# See the saslauthd man page for information about these options.
#
# Example for postfix users: "-c -m /var/spool/postfix/var/run/saslauthd"
# Note: See /usr/share/doc/sasl2-bin/README.Debian
OPTIONS="-c  -m /var/spool/postfix/var/run/saslauthd -</pre>
<p>Start then saslauthd:</p>
<p>/etc/init.d/saslauthd start</p>
<p>To see if SMTP-AUTH and TLS work properly now run the following command:</p>
<p>telnet yourdomain.com 25</p>
<p>After you have established the connection to your Postfix mail server type</p>
<p>ehlo yourdomain.com</p>
<p>The output should look something like:</p>
<p>250-yourdomain.com<br />
250-PIPELINING<br />
250-SIZE 10240000<br />
250-VRFY<br />
250-ETRN<br />
250-STARTTLS<br />
250-AUTH PLAIN LOGIN<br />
250-AUTH=PLAIN LOGIN<br />
250-ENHANCEDSTATUSCODES<br />
250-8BITMIME<br />
250 DSN</p>
<p>We have now Postfix running. If you add users (adduser command) Postfix will deliver then directly emails in users mail box located in the home folder.</p>
<h3>2. Installation of Dovecot</h3>
<p>Dovecot configuration is pretty straight forward (remember we will use only pop3 protocol to save memory):</p>
<p>apt-get install dovecot-common dovecot-pop3d</p>
<p>Open then dovecot conf situated in /etc/dovecot/. You have to add manually the protocol you want to use (pop3 pop3s</p>
<pre># Protocols we want to be serving: imap imaps pop3 pop3s
# If you only want to use dovecot-auth, you can set this to "none".
#protocols = imap imaps
protocols = pop3s pop3</pre>
<p>And uncomment the two following lines to tell Dovecot where to fint the certificate you have creted earlier</p>
<pre>ssl_cert_file = /etc/ssl/yourdomain/yourdomain.crt
ssl_key_file = /etc/ssl/yourdomain/yourdomain.key</pre>
<p>You have then to restart Dovecot</p>
<p>/etc/init.d/dovecot restart</p>
<p>and we have now a functionnal mail server.</p>
<h3>3. Installation of PHP5 (along with xcache)</h3>
<p>apt-get install php5-cli php5-cgi php5-mysql php5-xcache</p>
<p>Note that xcache has to be implemented manually by adding the following lines in the php.ini located in /etc/php5/cgi/ (please tune this config according to your system).</p>
<pre>[xcache-common]
extension = xcache.so
[xcache.admin]
xcache.admin.user = "mOo"
; xcache.admin.pass = md5($your_password)
xcache.admin.pass = ""
[xcache]
; ini only settings, all the values here is default unless explained
; select low level shm/allocator scheme implemenation
xcache.shm_scheme =        "mmap"
; to disable: xcache.size=0
; to enable : xcache.size=64M etc (any size &gt; 0) and your system mmap allows
xcache.size  =                32M
; set to cpu count (cat /proc/cpuinfo |grep -c processor)
xcache.count =                 1
; just a hash hints, you can always store count(items) &gt; slots
xcache.slots =                8K
; ttl of the cache item, 0=forever
xcache.ttl   =                 0
; interval of gc scanning expired items, 0=no scan, other values is in seconds
xcache.gc_interval =           0
; same as aboves but for variable cache
xcache.var_size  =            32M
xcache.var_count =             1
xcache.var_slots =            8K
; default ttl
xcache.var_ttl   =             0
xcache.var_maxttl   =          0
xcache.var_gc_interval =     300
xcache.test =                Off
; N/A for /dev/zero
xcache.readonly_protection = Off
; for *nix, xcache.mmap_path is a file path, not directory.
; Use something like "/tmp/xcache" if you want to turn on ReadonlyProtection
; 2 group of php won't share the same /tmp/xcache
; for win32, xcache.mmap_path=anonymous map name, not file path
xcache.mmap_path =    "/dev/zero"
; leave it blank(disabled) or "/tmp/phpcore/"
; make sure it's writable by php (without checking open_basedir)
xcache.coredump_directory =   ""
; per request settings
xcache.cacher =               On
xcache.stat   =               On
xcache.optimizer =            On
[xcache.coverager]
; per request settings
; enable coverage data collecting for xcache.coveragedump_directory and xcache_coverager_start/stop/get/clean() functions (will hurt executing performance)
xcache.coverager =          Off
; ini only settings
; make sure it's readable (care open_basedir) by coverage viewer script
; requires xcache.coverager=On
xcache.coveragedump_directory = ""</pre>
<p>Note: you have to adjust manually the xcache.size and xcache.var_size according to your server (it&#8217;s on 0 by default, meaning that xcache isn&#8217;t enabled at all). One other thing is the xcache.count variable. If you have a vps that takes advantage of 2 processors, you can put 2 instead of one.</p>
<p>You can do that right now even if your php configuration isn&#8217;t loaded yet so everything will be in good order when Nginx and fcgi process will be started.</p>
<h3>4. Installation of Mysql and PhpMyAdmin</h3>
<p>apt-get install mysql mysql-server</p>
<p>There is often a problem with mysql to setup the root password. So the best thing to do is first stopping mysql:</p>
<p>/etc/init.d/mysql stop</p>
<p>Then update the user table</p>
<p>mysqld &#8211;skip-grant-tables &#8211;skip-networking &amp;</p>
<p>mysql mysql</p>
<p>UPDATE user SET password=PASSWORD(&#8216;yourrootpassword&#8217;) WHERE User=&#8221;root&#8221; AND Host=&#8221;localhost&#8221;;</p>
<p>quit</p>
<p>/etc/init.d/mysql restart</p>
<h3>5. Installation of NGINX (Ubuntu only, see below for Debian users)</h3>
<p>The nginx version proposed by Feisty is a prehistoric one (not to mention drapper). Fortunately, there&#8217;s a place you can get the latest stable version, or if you are adventurous, the latest dev version.</p>
<p>Note for Debian users: I didn&#8217;t find a recent .deb package so you have either the choice to compile from sources or to do a apt-get install nginx to have a not so new version. For more informations about Nginx please go to the <a rel="nofollow" target="_blank" href="http://wiki.codemongers.com/" target="_blank">Nginx Wiki</a> website. You can find there the sources and a good doc about all the modules (ssl, auth_basic and so on).</p>
<p>wget http://technokracy.net/nginx/nginx_0.5.32~grrr-1_i386.deb</p>
<p>(Note that if you are running on AMD replace i386 by amd64.)</p>
<p>Then type:</p>
<p>dpkg -i nginx_0.5.32~grrr-1_i386.deb</p>
<p>Nginx is now up and running on default port 8000 (just in case you already have Apache or anything else on port 80).</p>
<p>The default root folder is Nginx-default and is located in /var/www/</p>
<p>To change that and to start to listen to the fast-cgi we will launch next, you have to open /etc/nginx/sites-available/default.</p>
<p>vi /etc/nginx/sites-available/default</p>
<p>You can find there all the obvious options to change and add (or uncomment the original php paragraph):</p>
<pre>        location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www/nginx-default$fastcgi_script_name;
    }</pre>
<p>We&#8217;ve just asked Nginx to listen to fcgi on port 9000. So we have to start now the fcgi process. I&#8217;ve chosen to use spawn-fcgi and to make my own init script of it (so the process will start after reboot). To have spawn-fcgi you have to get lighttpd configured but without the need to install it. Let&#8217;s grab the latest version:</p>
<p>wget http://www.lighttpd.net/download/lighttpd-1.4.18.tar.bz2</p>
<p>tar -xvjf lighttpd-1.4.18.tar.bz2</p>
<p>cd lighttpd-1.4.18</p>
<p>./configure</p>
<p>make</p>
<p>cp src/spawn-fcgi /usr/bin/spawn-fcgi</p>
<p>Note that we did not type make install so lighttpd is not running!</p>
<p>Then we create a shell script we can call php-fastcgi or whatever you want and place that file in /usr/bin/ to make it simple (as php5-cgi and spawn-fcgi are already there&#8230;).</p>
<p>touch /usr/bin/php-fastcgi</p>
<p>Then edit it:</p>
<p>vi /usr/bin/php-fastcgi</p>
<p>and add the following:</p>
<pre>#!/bin/sh
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -f /usr/bin/php5-cgi</pre>
<p>That means every time this script will be called, fcgi will be spawned on port 9000 for user www-data (default user).</p>
<p>To make it work at startup we need now to create an init script:</p>
<p>touch /etc/init.d/init-fastcgi</p>
<p>Edit and add:</p>
<p>vi /etc/init.d/init-fastcgi</p>
<pre>#!/bin/bash
PHP_SCRIPT=/usr/bin/php-fastcgi
RETVAL=0
case "$1" in
    start)
      $PHP_SCRIPT
      RETVAL=$?
  ;;
    stop)
      killall -9 php
      RETVAL=$?
  ;;
    restart)
      killall -9 php
      $PHP_SCRIPT
      RETVAL=$?
  ;;
    *)
      echo "Usage: php-fastcgi {start|stop|restart}"
      exit 1
  ;;
esac
exit $RETVAL</pre>
<p>You may have to change the permissions there by typing:</p>
<p>chmod 755 /etc/init.d/init-fastcgi</p>
<p>Check then if it works by typing:</p>
<p>/etc/init.d/init-fastcgi start</p>
<p>You should have an answer from spawn-fcgi attributing a PID process. To make now everything working after reboot type:</p>
<p>update-rc.d init-fastcgi defaults</p>
<p>And we are done. To check if php is working as fast-cgi you can first type:</p>
<p>ps ax | grep php</p>
<p>To check then if Nginx is listening to php, create an echo command in an empty php file:</p>
<pre>&lt;? echo phpinfo(); ?&gt;</pre>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="nginx directadmin">nginx directadmin</a> (9)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="lemp howto">lemp howto</a> (5)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="lemp with cpanel">lemp with cpanel</a> (3)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="vm lemp nginx">vm lemp nginx</a> (2)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="directadmin nginx howto">directadmin nginx howto</a> (2)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="install lemp rhel6">install lemp rhel6</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="ubuntu libdb3-util">ubuntu libdb3-util</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="rhel6 /etc/saslauthd conf">rhel6 /etc/saslauthd conf</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="postfix ldap dovecot ubuntu">postfix ldap dovecot ubuntu</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html" title="cpanel replacement lemp">cpanel replacement lemp</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/web-server/nginx/how-to-install-a-complete-lemp-linux-enginex-nginx-http-server-mysql-php-server-not-lamp-on-ubuntudebian.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lighttpd FasCGI PHP, MySQL chroot jail installation under Debian Linux</title>
		<link>http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html</link>
		<comments>http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html#comments</comments>
		<pubDate>Mon, 19 Dec 2011 05:38:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Lighttpd]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=1893</guid>
		<description><![CDATA[The instruction mentioned below only applies to Debian and Ubuntu Linux. I am going to document following things: =&#62; Install lighttpd =&#62; Prepare the file system for the jail =&#62; Run FastCGI PHP and MySQL from the jail =&#62; Add Perl support to the jail =&#62; Take care of sendmail =&#62; Run multiple domains (virtual [...]]]></description>
			<content:encoded><![CDATA[<p>The instruction mentioned below only applies to Debian and Ubuntu Linux. I am going to document following things:</p>
<p>=&gt; Install lighttpd<br />
=&gt; Prepare the file system for the jail<br />
=&gt; Run FastCGI PHP and MySQL from the jail<br />
=&gt; Add Perl support to the jail<br />
=&gt; Take care of sendmail<br />
=&gt; Run multiple domains (virtual hosting) from chrooted jail etc</p>
<p>Please note that information outlined below is for advanced UNIX users or admins only <img src='http://thegioinguonmo.com/wp-includes/images/smilies/icon_wink.gif' alt="icon wink Lighttpd FasCGI PHP, MySQL chroot jail installation under Debian Linux" class='wp-smiley' title="Lighttpd FasCGI PHP, MySQL chroot jail installation under Debian Linux" /> .</p>
<p><strong>Note:</strong> If you are using Ubuntu Linux read this howto.</p>
<p>&nbsp;</p>
<h3>Step # 1: Install lighttpd, php4-cgi and mysql server</h3>
<p>Use apt-get command to install packages:<code># apt-get install lighttpd php4-cgi php4-cli php4-mysql mysql-server </code>Note: If you need other php modules just install them using apt-get command.</p>
<h3>Step # 2: Prepare the file system</h3>
<p>Create a directory called /webroot:<code># mkdir /webroot</code></p>
<p>Create temporary /webroot/tmp directory:<code># mkdir /webroot/tmp/<br />
# chmod 1777 /webroot/tmp/</code></p>
<p>Create /etc directory to store php.ini file:<code># mkdir /webroot/etc</code></p>
<p>Create a log directory for lighttpd web server:<code># mkdir -p /webroot/var/log/lighttpd<br />
# chown www-data:www-data /webroot/var/log/lighttpd</code></p>
<p>Create a cache directory:<code># mkdir -p /webroot/var/tmp/lighttpd/cache/compress/<br />
# chown www-data:www-data /webroot/var/tmp/lighttpd/cache/compress/</code></p>
<p>Create a lighttpd home directory for virtual hosting<br />
<code># mkdir -p /webroot/home/lighttpd<br />
# chown www-data:www-data /webroot/home/lighttpd<br />
# chmod 0700 /webroot/home/lighttpd<br />
# ls -dl /webroot/home/lighttpd<br />
</code>Output:</p>
<pre>drwx------  2 www-data www-data 4096 Oct  5 23:15 /webroot/home/lighttpd</pre>
<p>A handy shell script (l2chroot [download] ) to copy necessary shared system libraries:</p>
<pre>#!/bin/bash
BASE="/webroot"
if [ $# -eq 0 ]; then
  echo "Syntax : $0 /path/to/executable"
  echo "Example: $0 /usr/bin/php5-cgi"
  exit 1
fi
[ ! $BASE ] &amp;&amp; mkdir -p $BASE || :
# iggy ld-linux* file as it is not shared one
FILES="$(ldd $1 | awk '{ print $3 }' |egrep -v ^'\(')"
echo "Copying shared files/libs to $BASE..."
for i in $FILES
do
  d="$(dirname $i)"
  [ ! -d $BASE$d ] &amp;&amp; mkdir -p $BASE$d || :
  /bin/cp $i $BASE$d
done
# copy /lib/ld-linux* or /lib64/ld-linux* to $BASE/$sldlsubdir
# get ld-linux full file location
sldl="$(ldd $1 | grep 'ld-linux' | awk '{ print $1}')"
# now get sub-dir
sldlsubdir="$(dirname $sldl)"
if [ ! -f $BASE$sldl ];
then
  echo "Copying $sldl $BASE$sldlsubdir..."
  /bin/cp $sldl $BASE$sldlsubdir
else
  :
fi</pre>
<p>Put l2chroot in /bin directory and set executable permission:<code># wget http://www.cyberciti.biz/files/lighttpd/l2chroot.txt<br />
# mv l2chroot.txt l2chroot<br />
# cp l2chroot /bin<br />
# chmod +x /bin/l2chroot</code></p>
<h3>Step 3: Put PHP in the jail</h3>
<p>Now you need to copy PHP executable files and necessary extensions (php-mysql) to /webroot directory.<br />
<code># mkdir -p /webroot/usr/bin<br />
# cp /usr/bin/php4-cgi /webroot/usr/bin/<br />
# cp /usr/bin/php4 /webroot/usr/bin/</code><br />
Copy /etc/php4/cgi/php.ini file to /webroot/etc/ directory.<br />
<code># cd /webroot/etc/<br />
# cp -avr /etc/php4 .</code></p>
<p>Now copy other config files in jail:<br />
<code># cp /etc/hosts /webroot/etc/<br />
# cp /etc/nsswitch.conf /webroot/etc/<br />
# cp /etc/resolv.conf /webroot/etc/<br />
# cp /etc/services /webroot/etc/<br />
# cp /etc/localtime /webroot/etc/</code></p>
<p>Copy all php shared libraries used by /usr/bin/php4 and /usr/bin/php4-cgi using your l2chroot script:<br />
<code># /bin/l2chroot /usr/bin/php4<br />
# /bin/l2chroot /usr/bin/php4-cgi</code></p>
<p>Now you have all shared libraries in /webroot directory. You can verify this with ls command. There is one more file, which you need to copy manually &#8211; /lib/ld-linux.so.2:<br />
<code># cp /lib/ld-linux.so.2 /webroot/lib</code></p>
<h3>Step 4: Put php MySQL extension in the jail</h3>
<p>To access MySQL database server you need to use php4-mysql extension.<br />
Copy php mysql extension from /usr/lib/php4/20050606 directory, use following command to determine exact location of mysql.so file:<br />
<code># dpkg -L php4-mysql</code>Output:</p>
<pre>/.
/usr
/usr/lib
/usr/lib/php4
/usr/lib/php4/20050606
/usr/lib/php4/20050606/mysql.so
/usr/share
/usr/share/doc
/usr/share/doc/php4-mysql</pre>
<p>Copy /usr/lib/php4/20050606/mysql.so file to /webroot/usr/lib/php4/20050606/mysql.so and related shared libs using /bin/l2chroot script:<br />
<code># mkdir -p /webroot/usr/lib/php4/20050606<br />
# cp /usr/lib/php4/20050606/mysql.so /webroot/usr/lib/php4/20050606/<br />
# /bin/l2chroot /usr/lib/php4/20050606/mysql.so</code></p>
<p>Repeat above procedure to copy all your php shared modules such as php-imap (required for webmail), php-gd (GD module for php4 used by wordpress and other softwares), php-memcache etc.</p>
<h3>Step # 5: Configure lighttpd to run from chrooted jail</h3>
<p>Make sure fastcgi module is enabled:<br />
<code># lighty-enable-mod fastcgi</code>Output:</p>
<pre>Available modules: auth cgi cml fastcgi proxy simple-vhost ssi ssl trigger-b4-dl userdir
Already enabled modules:
Enabling fastcgi: ok
Run /etc/init.d/lighttpd force-reload to enable changes</pre>
<p>Configure lighttpd by editing /etc/lighttpd/lighttpd.conf file:<br />
<code># vi /etc/lighttpd/lighttpd.conf </code></p>
<p>The most importat part is server.chroot directive. Open config file:<br />
<code># vi /etc/lighttpd/lighttpd.conf</code><br />
Set server.chroot to /webroot:<br />
<code>server.chroot = "/webroot"</code></p>
<p>Above directive applies chroot() call to directory called /webroot. Once applied no one (except root user) can access file system outside /webroot directory.</p>
<p>Rest of the configuration directives is documented very well in file itself. Start your lighttpd:<br />
<code># /etc/init.d/lighttpd start</code></p>
<h3>Test jail setup</h3>
<p>Create two test php files in /webroot/home/lighttpd</p>
<ul>
<li>db.php : Test MySQL database connectivity, make sure you modify this file for correct MySQL server hostname, username and password.</li>
<li>test.php : Test php via phpinfo()</li>
</ul>
<p>Open a web browser and type url http://yourdomain.com/test.php and http://yourdomain.com/db.php.</p>
<p>Congratulations, if you are able to run both db.php and test.php w/o problem. Always refer to /var/log/message (outside /webroot directory) for troubleshooting purpose. If you see error message that read as follows (tail -f /var/log/message) :</p>
<pre>php5-cgi[7325]: segfault at 0000000000001e98 rip 00002ad2cf6bd101 rsp 00007fffdb3f1ed0 error 4</pre>
<p>To fix this problem, copy all shared libs from /lib and /usr/lib to /chroot (or <strong>/lib64</strong> &amp; <strong>/usr/lib</strong> if you are using <em>64 bit Linux</em>) directory. But please do NOT copy any executable files from /bin/ /usr/bin or /usr/sbin directory.<br />
<code># cp -avr /lib/* /webroot/lib/<br />
# cp -avr /usr/lib/* /webroot/usr/lib/</code><br />
Follow these instructions for more information.</p>
<h3>Size of the /webroot jail</h3>
<p>Here is size of webroot jail:<br />
<code># du -ch</code>Output:</p>
<pre>28K     ./var/www
104K    ./var/log/lighttpd
108K    ./var/log
4.0K    ./var/run
4.0K    ./var/tmp/lighttpd/cache/compress
8.0K    ./var/tmp/lighttpd/cache
12K     ./var/tmp/lighttpd
16K     ./var/tmp
160K    ./var
4.0K    ./tmp
5.9M    ./usr/bin
2.7M    ./usr/lib/i686/cmov
2.7M    ./usr/lib/i686
48K     ./usr/lib/php4/20050606
52K     ./usr/lib/php4
7.5M    ./usr/lib
14M     ./usr
1.7M    ./lib/tls
2.0M    ./lib
44K     ./etc/php4/cgi
48K     ./etc/php4
56K     ./etc
16K     ./home/lighttpd
20K     ./home
16M     .
<strong>16M total </strong></pre>
<p>As you see our jail only took 16MB disk space. I will address rest of the issues such as perl support and sendmail problem tomorrow <img src='http://thegioinguonmo.com/wp-includes/images/smilies/icon_smile.gif' alt="icon smile Lighttpd FasCGI PHP, MySQL chroot jail installation under Debian Linux" class='wp-smiley' title="Lighttpd FasCGI PHP, MySQL chroot jail installation under Debian Linux" /> </p>
<p>Continue reading the rest of Lighttpd series articles.</p>
<p>Updated for accuracy.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="centos chroot jail lighttpd 2012">centos chroot jail lighttpd 2012</a> (2)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="lighttpd php debian">lighttpd php debian</a> (2)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="Starting lighttpd: /bin/bash: /usr/sbin/lighttpd: No such file or directory in fedora">Starting lighttpd: /bin/bash: /usr/sbin/lighttpd: No such file or directory in fedora</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="run php in jail windows">run php in jail windows</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="php chroot issues windows">php chroot issues windows</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="mysql chrooted bash plesk">mysql chrooted bash plesk</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="linux plesk php chroot">linux plesk php chroot</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="lighttpd php jail mysql">lighttpd php jail mysql</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="lighttpd chroot jail security">lighttpd chroot jail security</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html" title="directadmin jail resolv conf">directadmin jail resolv conf</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/web-server/lighttpd/lighttpd-fascgi-php-mysql-chroot-jail-installation-debian-linux.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How Do I Run a Firewall Script As Soon As eth0 Interface Brings Up?</title>
		<link>http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html</link>
		<comments>http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html#comments</comments>
		<pubDate>Sun, 18 Dec 2011 06:26:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[etc network]]></category>
		<category><![CDATA[iptables firewall]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[shell script]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=1832</guid>
		<description><![CDATA[I use ADSL at home via ISP modem. As soon as my eth0 comes up I would like to have my firewall script get executed and setup the iptables firewall rules for me. Earlier, I used to type the command /root/fs.dsl.start via the sudo command. However, while reading the man page of interfaces command I [...]]]></description>
			<content:encoded><![CDATA[<p>I use ADSL at home via ISP modem. As soon as my eth0 comes up I would like to have my firewall script get executed and setup the iptables firewall rules for me.</p>
<p>Earlier, I used to type the command /root/fs.dsl.start via the sudo command. However, while reading the man page of interfaces command I came across the <strong>post-up</strong> option which run command after bringing the interface up. Following step demonstrates the usage of post-up option:</p>
<div><img src="http://files.cyberciti.biz/cbzcache/3rdparty/ubuntu-logo.jpg" alt="ubuntu logo How Do I Run a Firewall Script As Soon As eth0 Interface Brings Up?" border="0" title="How Do I Run a Firewall Script As Soon As eth0 Interface Brings Up?" /></div>
<p>1) Copy your firewall shell script to /etc/network/if-up.d/ directory:<br />
<code># cp /root/fw.dsl.start /etc/network/if-up.d/</code></p>
<p>2) Open Debian / Ubuntu networking configuration file /etc/network/interfaces:<br />
<code># vi /etc/network/interfaces</code></p>
<p>3) Setup post-up option, append following line to eth0 configuration section:<br />
<code># post-up /etc/network/if-up.d/fw.dsl.start</code></p>
<p>Where,</p>
<ul>
<li><strong>post-up command</strong> : Run <em>command or shell script</em> after bringing the interface eth0 up.</li>
</ul>
<p>Here is my /etc/network/interfaces after modification:</p>
<pre>auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
name Ethernet LAN card
address 192.168.1.1
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
gateway 192.168.1.254
post-up /etc/network/if-up.d/fw.dsl.start</pre>
<p>4) Save and close the file. Restart networking service:<br />
<code># /etc/init.d/networking restart</code></p>
<p>5) Verify that iptables rules are loaded:<br />
<code># iptables -L -n -v</code></p>
<h2>Additional Options</h2>
<p>To run command before bringing the interface up, enter:<br />
<code>pre-up command<br />
pre-up /scripts/networking.accounting_on</code><br />
To run command before taking the interface down, enter:<br />
<code>pre-down command</code><br />
To run command or script after taking the interface down, enter:<br />
<code>post-down command<br />
post-down /path/to/script.sh</code></p>
<h2>Example: Setting Up Static Routing</h2>
<p>The up and down options can be used to set up Debian static routing as follows as soon as eth0 interface available or down:<br />
<code>up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.8.18.17<br />
down route del -net 10.0.0.0 netmask 255.0.0.0 gw 10.8.18.17</code></p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="centos execute a script when interface eth0 comes up">centos execute a script when interface eth0 comes up</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="centos execute command on interface up">centos execute command on interface up</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="centos execute script when eth0 up">centos execute script when eth0 up</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="centos iptables firewall script">centos iptables firewall script</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="centos network post-up script">centos network post-up script</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="if-up d eth0 debian">if-up d eth0 debian</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="rum command on network up centos">rum command on network up centos</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html" title="run script after eth0 interface comes up centos">run script after eth0 interface comes up centos</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/security/how-do-i-run-a-firewall-script-as-soon-as-eth0-interface-brings-up.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to: Linux flush or remove all iptables rules</title>
		<link>http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html</link>
		<comments>http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html#comments</comments>
		<pubDate>Sun, 18 Dec 2011 06:25:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[enterprise linux]]></category>
		<category><![CDATA[Firewall]]></category>
		<category><![CDATA[gnu linux]]></category>
		<category><![CDATA[init]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[stop]]></category>
		<category><![CDATA[ubuntu linux]]></category>
		<category><![CDATA[use]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=1830</guid>
		<description><![CDATA[Here is small script that does this. Debian or Ubuntu GNU/Linux does not comes with any SYS V init script (located in /etc/init.d directory) . You create a script as follows and use it to stop or flush the iptables rules. Please don&#8217;t type rules at command prompt. Use the script to speed up work. [...]]]></description>
			<content:encoded><![CDATA[<p>Here is small script that does this. Debian or Ubuntu GNU/Linux does not comes with any SYS V init script (located in /etc/init.d directory) .</p>
<p>You create a script as follows and use it to stop or flush the iptables rules.</p>
<p>Please don&#8217;t type rules at command prompt. Use the script to speed up work.</p>
<h3>Procedure for Debian / Ubuntu Linux</h3>
<p>A) Create /root/fw.stop /etc/init.d/fw.stop script using text editor such as vi:</p>
<pre>#!/bin/sh
echo "Stopping firewall and allowing everyone..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT</pre>
<p>(B) Make sure you can execute the script:<br />
<code># chmod +x /root/fw.stop</code></p>
<p>(C) You can run the script:<br />
<code># /root/fw.stop</code></p>
<h2>A note for RedHat and friends Linux user</h2>
<p>Please note that RedHat enterprise Linux (RHEL) and Fedora / Centos Linux comes with pre-installed script, which can be used to stop the firewall:<br />
<code>#/etc/init.d/iptables stop</code></p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="/etc/init d/iptables stop no such file or directory centos">/etc/init d/iptables stop no such file or directory centos</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="script ipchains plesk">script ipchains plesk</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="plesk flush firewall">plesk flush firewall</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="flush plesk iptables">flush plesk iptables</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="flush plesk firewall">flush plesk firewall</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="flush firewalll rules plesk">flush firewalll rules plesk</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="debian iptables directadmin">debian iptables directadmin</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="cpanel remove iptables rules">cpanel remove iptables rules</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="cpanel iptables rules delete">cpanel iptables rules delete</a> (1)</li><li><a href="http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html" title="cpanel init network iptables">cpanel init network iptables</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/security/how-to-linux-flush-or-remove-all-iptables-rules.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: thegioinguonmo.com @ 2012-05-20 18:26:56 -->
