<?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; Apache</title>
	<atom:link href="http://thegioinguonmo.com/tag/apache/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>DirectAdmin 1.391 : pcfg_openfile: unable to check htaccess file, ensure it is readable</title>
		<link>http://thegioinguonmo.com/hosting-controller/directadmin/directadmin-1391-pcfgopenfile-unable-check-htaccess-file-ensure-readable.html</link>
		<comments>http://thegioinguonmo.com/hosting-controller/directadmin/directadmin-1391-pcfgopenfile-unable-check-htaccess-file-ensure-readable.html#comments</comments>
		<pubDate>Sat, 19 May 2012 21:40:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DirectAdmin]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[directadmin]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2059</guid>
		<description><![CDATA[Today, I got a problem with one of my website. Suddenly, I could access my website using Nginx but all themes were gone. I, then, switched back to Apache. It became worse. I can&#8217;t access my website at all. The error when access my website using Apache is below : Forbidden You don't have permission [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I got a problem with one of my website. Suddenly, I could access my website using Nginx but all themes were gone. I, then, switched back to Apache. It became worse. I can&#8217;t access my website at all. The error when access my website using Apache is below :</p>
<div>
<div><strong><span style="color: #ff0000;"><code>Forbidden</code></span></strong></div>
<div></div>
<div><strong><span style="color: #ff0000;"><code>You don't have permission to access / on this server.</code></span></strong></div>
<div></div>
<div><strong><span style="color: #ff0000;"><code>Additionally, a 403 Forbidden error was encountered </code><code>while</code> <code>trying to use an ErrorDocument to handle the request.</code></span></strong></div>
</div>
<div></div>
<div>At first, I thought something is wrong with my configuration but then, I could access DA control panel, Munin, phpmyadmin and any other pages without any problem. Also checked permission but it looks like it&#8217;s ok. Nothing is wrong. So, I checked error log and found error like below :</div>
<div>
<pre class="brush:shell">[Thu Dec 29 14:53:01 2011] [crit] [client xx.xx.xx.xx] (13)Permission denied: /home/admin/domains/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable</pre>
<p>Google and found in DirectAdmin. Basically, it&#8217;s something about permission which I may not know what it is. John is kindly provided an updated <strong>set_permissions.sh</strong> allow us to set permission to specific user. You can get it from here -&gt; <a rel="nofollow" target="_blank" href="http://files.directadmin.com/services/all/set_permissions.sh">http://files.directadmin.com/services/all/set_permissions.sh</a></p>
<p>Use it by type :</p>
<pre class="brush:shell">./set_permisions.sh set_user_home username</pre>
<p>where <strong>username</strong> has to changed to the one you want. John said that <strong>set_permissions.sh</strong> will be included in the future version of DirectAdmin.</p>
<p><strong>Source : </strong><a rel="nofollow" target="_blank" href="http://www.directadmin.com/forum/showthread.php?t=39278">http://www.directadmin.com/forum/showthread.php?t=39278</a></p>
</div>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/hosting-controller/directadmin/directadmin-1391-pcfgopenfile-unable-check-htaccess-file-ensure-readable.html" title="(13)permission denied: / htaccess pcfg_openfile: unable to check htaccess file ensure it is readable cpanel vps">(13)permission denied: / htaccess pcfg_openfile: unable to check htaccess file ensure it is readable cpanel vps</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/hosting-controller/directadmin/directadmin-1391-pcfgopenfile-unable-check-htaccess-file-ensure-readable.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache2 mod_fastcgi: Connect to External PHP via UNIX Socket or TCP/IP Port</title>
		<link>http://thegioinguonmo.com/web-server/apache/apache2-modfastcgi-connect-external-php-unix-socket-tcpip-port.html</link>
		<comments>http://thegioinguonmo.com/web-server/apache/apache2-modfastcgi-connect-external-php-unix-socket-tcpip-port.html#comments</comments>
		<pubDate>Mon, 14 May 2012 21:40:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=1922</guid>
		<description><![CDATA[Now, mod_fastcgi is configured and running. FastCGI supports connection via UNIX sockets or TCP/IP networking. This is useful to spread load among various backends. For example, php will be severed from 192.168.1.10 and python / ruby on rails will be severed from 192.168.1.11. This is only possible with mod_fastcgi. Required utilities You can spawn FastCGI [...]]]></description>
			<content:encoded><![CDATA[<p>Now, <a rel="nofollow" target="_blank" href="http://www.cyberciti.biz/faq/rhel-fedora-centos-linux-enable-epel-repo/">mod_fastcgi is configured and running</a>. FastCGI supports connection via UNIX sockets or TCP/IP networking. This is useful to spread load among various backends. For example, php will be severed from 192.168.1.10 and python / ruby on rails will be severed from 192.168.1.11. This is only possible with mod_fastcgi.</p>
<h2>Required utilities</h2>
<div><a rel="nofollow" target="_blank" title="See all PHP related tips/articles" href="http://www.cyberciti.biz/tips/category/php"><img src="http://files.cyberciti.biz/cbzcache/3rdparty/php-logo.png" alt="php logo Apache2 mod fastcgi: Connect to External PHP via UNIX Socket or TCP/IP Port" border="0" title="Apache2 mod fastcgi: Connect to External PHP via UNIX Socket or TCP/IP Port" /></a></div>
<p>You can spawn FastCGI processes using a dispatcher script or using spawn-fcgi utility, which is used to spawn remote FastCGI processes. spawn-fcgi included with lighttpd web server. You can grab source code from lighttpd.net or simply install it using lighttpd as follows (you need <a rel="nofollow" target="_blank" href="http://www.cyberciti.biz/faq/rhel-fedora-centos-linux-enable-epel-repo/">EPEL repo enabled</a> under RHEL / CentOS / Fedora Linux):<br />
<code># yum install lighttpd-fastcgi<br />
# cp /usr/bin/spawn-fcgi /tmp<br />
# yum remove lighttpd-fastcgi<br />
# mv /tmp/spawn-fcgi /usr/bin/spawn-fcgi</code><br />
lighttpd-fastcgi is FastCGI module and spawning helper for lighttpd and PHP configuration.</p>
<h3>How do spawning php as TCP/IP remote app?</h3>
<p>Use /usr/bin/spawn-fcgi as follows, enter:<br />
<code># /usr/bin/spawn-fcgi -f /usr/bin/php-cgi -a 192.168.1.10 -p 9000 -P /var/run/php-cgi.fastcgi.pid -u apache -g apache</code><br />
You can also jail php, using following syntax (make sure /var/run/ and /usr/bin/php-cgi exists inside jail directory):<br />
<code># /usr/bin/spawn-fcgi -c /httpdjail -a 192.168.1.10 -p 9000 -P /var/run/php-cgi.fastcgi.pid -u apache -g apache -- /usr/bin/php-cgi</code><br />
Where,</p>
<ul>
<li><strong> -f /usr/bin/php-cgi</strong>: Filename of the fcgi-application</li>
<li><strong>-a 192.168.1.10 </strong>: Bind to ip address</li>
<li><strong>-p 9000</strong> : Bind to tcp-port</li>
<li><strong>-P /var/run/php-cgi.fastcgi.pid</strong>: Name of PID-file for spawed process</li>
<li><strong>-c /httpdjail</strong> : Chroot to directory (security feature)</li>
<li><strong>-u apache</strong> : Change to user-id (security feature &#8211; drop root user privileges to apache user)</li>
<li><strong>-g apache </strong>: Change to group-id (security feature &#8211; drop root group privileges to apache group)</li>
</ul>
<h3>Configure Apache 2 mod_fastcgi connect to external PHP fcgi application</h3>
<p>Above command will run php fcgi on 192.168.1.10:9000. Here is our sample setup:</p>
<ol>
<li>192.168.1.10 port 9000 : PHP FastCGI server</li>
<li>192.168.1.11 port 9000 : Python or Ruby on rails cgi process</li>
<li>202.54.1.20 port 80 : Apache 2 running mod_fastcgi (DocumentRoot set to /webroot/http)</li>
</ol>
<p>Open your httpd.conf on 202.54.1.20, enter:<br />
<code># vi /etc/httpd/conf/httpd.conf </code><br />
Locate your domain VirtualHost configuration and append following two directives:</p>
<pre>AddHandler php5-fastcgi .php
FastCgiExternalServer /webroot/http -host 192.168.1.10:9000</pre>
<p>Here is complete snippet from one my box:</p>
<pre>&lt;VirtualHost nixcraft.com:80&gt;
    ServerAdmin webmaster@nixcraft.com
    DocumentRoot /webroot/http
    ServerName nixcraft.com
    ErrorLog logs/nixcraft.com-error_log
    CustomLog logs/nixcraft.com-access_log common
    AddHandler php5-fastcgi .php
    FastCgiExternalServer /webroot/http -host 192.168.1.10:9000
&lt;/VirtualHost&gt;</pre>
<p>Save and close the file. Restart httpd:<br />
<code># service httpd restart</code><br />
Make sure iptables is configured to allow communication between public and private fastcgi server.</p>
<h3>How do I configure PHP FastCGI via UNIX sockets?</h3>
<p>UNIX sockets are faster as compare to TCP/IP sockets. However, they do not support remote spawning. Create /tmp/php.socket as follows:<br />
<code># /usr/bin/spawn-fcgi -f /usr/bin/php-cgi -s /tmp/php.socket -u apache -g apache</code><br />
Add following configuration to your httpd.conf virtual host:</p>
<pre>AddHandler php5-fastcgi .php
FastCgiExternalServer /webroot/http -socket /tmp/php.socket</pre>
<p>Save and close the file. Restart httpd, type:<br />
<code># service httpd restart</code></p>
<p>mod_fastcgi has lots of other options. Please refer to <a rel="nofollow" target="_blank" href="http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html" target="_blank">Apache and mod_fastcgi documentation</a> for further information.</p>
<h2>A note about mod_fastcgi limitation</h2>
<p>You can not load balance between multiple php backend. You need to use lighttpd or nginx or other reverse proxy software.</p>
]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/web-server/apache/apache2-modfastcgi-connect-external-php-unix-socket-tcpip-port.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>500 error when you try to access the website</title>
		<link>http://thegioinguonmo.com/os/linux/500-error-when-you-try-to-access-the-website.html</link>
		<comments>http://thegioinguonmo.com/os/linux/500-error-when-you-try-to-access-the-website.html#comments</comments>
		<pubDate>Sun, 13 May 2012 09:40:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=1387</guid>
		<description><![CDATA[If the .htaccess has an error you should get a 500 error when you try to access the website. Is that the case? You can check if mod_rewrite is compiled in with Apache doing: httpd -l &#124; grep mod_rewrite.c If it’s not then you should re-compile Apache. You could also enable mod_rewrite logging: RewriteLog “/var/log/httpd/rewrite.log” [...]]]></description>
			<content:encoded><![CDATA[<p>If the .htaccess has an error you should get a 500 error when you try to access the website. Is that the case?</p>
<p>You can check if mod_rewrite is compiled in with Apache doing:</p>
<pre class="brush:plain">httpd -l | grep mod_rewrite.c</pre>
<p>If it’s not then you should re-compile Apache.</p>
<p>You could also enable mod_rewrite logging:</p>
<blockquote>
<pre class="brush:plain">RewriteLog “/var/log/httpd/rewrite.log”
RewriteLogLevel 9 # Maximum debug level, should be disabled on production environment</pre>
</blockquote>
<p>Note that this must be added on the VirtualHost or at the httpd.conf and *NOT* in the .htaccess.</p>
<p>After this you can check the file /var/log/httpd/rewrite.log to see what happens when you try to access an URL that should be rewritten.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/os/linux/500-error-when-you-try-to-access-the-website.html" title="accessing a website with network programming">accessing a website with network programming</a> (1)</li><li><a href="http://thegioinguonmo.com/os/linux/500-error-when-you-try-to-access-the-website.html" title="download httpd-2 2 17 for linux">download httpd-2 2 17 for linux</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/os/linux/500-error-when-you-try-to-access-the-website.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOS, Apache &amp; mod_fcgid: IPCCommTimeout not working as expected</title>
		<link>http://thegioinguonmo.com/web-server/apache/centos-apache-modfcgid-ipccommtimeout-working-expected.html</link>
		<comments>http://thegioinguonmo.com/web-server/apache/centos-apache-modfcgid-ipccommtimeout-working-expected.html#comments</comments>
		<pubDate>Sat, 12 May 2012 21:44:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mod_fcgid]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2102</guid>
		<description><![CDATA[If you&#8217;re running Apache with the mod_fcgid module to let your PHP scripts be handled in a seperate module, you can run into this annoying little bug in the mod_fcgid 2.2.x implementations. The problem: mod_fcgid: read data timeout in xx seconds First, check if you have the mod_fcgid module that is causing these problems. # [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re running Apache with the mod_fcgid module to let your PHP scripts be handled in a seperate module, you can run into this <a rel="nofollow" target="_blank" href="http://loeki.tv/log/archives/93-IPCCommTimeout-not-working-with-mod_fcgid-2.2.html">annoying little bug</a> in the mod_fcgid 2.2.x implementations.</p>
<h2>The problem: mod_fcgid: read data timeout in xx seconds</h2>
<p>First, check if you have the mod_fcgid module that is causing these problems.</p>
<pre class="brush:plain"># rpm -qa |grep -i mod_fcgid
mod_fcgid-2.2-11.el5</pre>
<p>Apparently, any 2.2.x branche has this bug.</p>
<p>The problem exists <strong>if any VirtualHost does not have the IPCommTimeout value</strong>. If there&#8217;s a VirtualHost where this setting is not defined, it will reset the configuration globally back to the default of 40 seconds, resulting in the following error you Apache&#8217;s error logs.</p>
<pre class="brush:plain">[warn] mod_fcgid: read data timeout in 40 seconds
Premature end of script headers: php-cgi, referer: [snip]</pre>
<p>And they will throw a <strong>500 Internal Server Error</strong> in your access logs.</p>
<pre class="brush:plain">“GET /path/to/url HTTP/1.1″ 500 537</pre>
<h2>The solution: IPCommTimeout in every virtual host</h2>
<p>The solution sucks if you have many (manually controlled) virtual hosts, but you have to define the IPCommTimeout option in every Virtual Host on the server. If one is missing, it will reset the config of that parameter to the default <em>serverwide</em>. So place the following codeblock in every Virtual Host you have.</p>
<pre class="brush:plain">&lt;IfModule mod_fcgid.c&gt;
IPCCommTimeout          360
IPCConnectTimeout       360
&lt;/IfModule&gt;</pre>
<p>The values above are expressed in seconds.</p>
]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/web-server/apache/centos-apache-modfcgid-ipccommtimeout-working-expected.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is .htaccess and how to disable .htaccess?</title>
		<link>http://thegioinguonmo.com/os/linux/what-is-htaccess-and-how-to-disable-htaccess.html</link>
		<comments>http://thegioinguonmo.com/os/linux/what-is-htaccess-and-how-to-disable-htaccess.html#comments</comments>
		<pubDate>Mon, 07 May 2012 09:45:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[use]]></category>
		<category><![CDATA[way]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=1043</guid>
		<description><![CDATA[What is .htaccess and how to disable .htaccess? .htaccess is use to modify the way Apache behaves for a directory and it’s sub-directories. It gives you an extra control on your server, like setting up custom error messages, password protect a directory, writing rewrite rules, blocking IPs etc. However, it can be a potentially dangerous [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><strong>What is .htaccess and how to disable .htaccess?</strong></p></blockquote>
<p><strong>.htaccess is use to modify the way Apache behaves for a directory and it’s sub-directories.</strong> It gives you an extra control on your server, like setting up custom error messages, password protect a directory, writing rewrite rules, blocking IPs etc.</p>
<p>However, it can be a potentially dangerous file. For example, a hacker can redirect your website to an external website say a malware website.</p>
<p><strong>In order to disable .htaccess server wide</strong>, edit the Apache configuration file</p>
<blockquote><p><strong>pico /etc/httpd/conf/httpd.conf</strong></p></blockquote>
<p><strong>Search for</strong></p>
<pre class="brush:plain">    AllowOverride All

replace it with

    AllowOverride None</pre>
<p>Save the file and restart the Apache service.</p>
<blockquote><p><strong>service httpd restart</strong></p></blockquote>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/os/linux/what-is-htaccess-and-how-to-disable-htaccess.html" title="howto htaccess centos and plesk">howto htaccess centos and plesk</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/os/linux/what-is-htaccess-and-how-to-disable-htaccess.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chroot Apache 2 Web Server</title>
		<link>http://thegioinguonmo.com/web-server/apache/chroot-apache-2-web-server.html</link>
		<comments>http://thegioinguonmo.com/web-server/apache/chroot-apache-2-web-server.html#comments</comments>
		<pubDate>Sun, 06 May 2012 21:41:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[Install]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=330</guid>
		<description><![CDATA[A chroot on Red Hat / CentOS / Fedora Linux operating changes the apparent disk root directory for the Apache process and its children. Once this is done attacker or other php / perl / python scripts cannot access or name files outside that directory. This is called a “chroot jail” for Apache. You should [...]]]></description>
			<content:encoded><![CDATA[<p>A chroot on Red Hat / CentOS / Fedora Linux operating changes the apparent disk root directory for the Apache process and its children. Once this is done attacker or other php / perl / python scripts cannot access or name files outside that directory. This is called a “chroot jail” for Apache. You should never ever run a web server without jail. There should be privilege separation between web server and rest of the system.</p>
<p>In this exclusive series, you will learn more about:</p>
<ul>
<li>Securing an Apache 2 web server under Red Hat Enterprise Linux / CentOS Linux using mod_chroot</li>
<li>Virtual hosting configuration under chrooted jail.</li>
<li>Troubleshooting Chrooted Apache jail problem.</li>
</ul>
<p>&nbsp;</p>
<h2>Requirements</h2>
<ol>
<li>Server: <strong>Apache 2 Web</strong> server.</li>
<li>Jail directory: <strong>/httpdjail</strong>.</li>
<li>User / Group: <strong>apache</strong> / <strong>apache</strong> (never ever run chroot using root user).</li>
<li>Virtual domain directory for all domain inside jail: <strong>/home/httpd</strong>.</li>
<li>PHP is configured via default mod_php.</li>
<li>Instructions are tested under CentOS / RHEL 5.x.</li>
</ol>
<h3>More about Jail directory: /httpdjail</h3>
<p>Create a jail directory as follows:<br />
<code># J=/httpdjail<br />
# mkdir $J</code></p>
<ol>
<li>Do <strong>not create /dev</strong> directory inside your jail.</li>
<li>Do not create<strong> special device files</strong> inside jail.</li>
<li>Do not<strong> copy shell or any other single executable</strong> files inside your jail.</li>
<li>Do not run <strong>httpd or php / perl / python as root</strong> user.</li>
<li>If possible mount $J using a separate partition with nosuid, nodev and noexec options. This will improve security as user will not able to run suid enabled programs and device files inside a jail.</li>
</ol>
<h3>Install Apache, PHP and MySQL</h3>
<p>Install required packages using yum command, enter:<br />
<code># yum install mysql mysql-server httpd php-mysql php-pear php-xml php-mysql php-cli php-imap php-gd php-pdo php-devel php-mbstring php-common php-ldap php httpd-devel</code><br />
Now, create required directories inside your jail:<br />
<code># mkdir -p $J/var/run<br />
# chown -R root.root $J/var/run<br />
# mkdir -p $J/home/httpd<br />
# mkdir -p $J/var/www/html<br />
# mkdir -p $J/tmp<br />
# chmod 1777 $J/tmp<br />
# mkdir -p $J/var/lib/php/session<br />
# chown root.apache $J/var/lib/php/session<br />
</code></p>
<ol>
<li><strong>$J/var/run</strong> will store PID and other files.</li>
<li><strong>$J/var/lib/php/session</strong> PHP session file path (configured in php.ini).</li>
<li><strong>$J/tmp</strong> – Used by many scripts and cms software to upload files.</li>
</ol>
<h2>Install mod_chroot</h2>
<p>mod_chroot makes running Apache in a secure chroot environment easy. You don’t need to create a special directory hierarchy containing /dev, /lib, /etc. mod_chroot allows you to run Apache in a chroot jail with no additional files. The chroot() system call is performed at the end of startup procedure – when all libraries are loaded and log files open. Download mod_chroot using wget command:<br />
<code># cd /opt/<br />
# wget http://core.segfault.pl/~hobbit/mod_chroot/dist/mod_chroot-0.5.tar.gz</code><br />
Untar it:<br />
<code># tar -zxvf mod_chroot-0.5.tar.gz</code><br />
Compile and install mod_chroot for using apxs, enter:<br />
<code># cd mod_chroot-0.5<br />
# apxs -cia mod_chroot.c</code></p>
<h3>Configure Apache mod_chroot</h3>
<p>Open /etc/httpd/conf/httpd.conf file, type:<br />
<code># C=/etc/httpd/conf/httpd.conf<br />
# vi $C</code><br />
Set PidFile path in which the server should record its process identification number when it starts. Find line that reads as follows:</p>
<blockquote><p>PidFile run/httpd.pid</p></blockquote>
<p>Replace with:<br />
<code>PidFile /var/run/httpd.pid</code><br />
Next add ChrootDir directive, enter:<br />
<code>ChrootDir /httpdjail</code><br />
Find line that read as follows:<br />
<code>ServerRoot "/etc/httpd"</code><br />
Append following lines:</p>
<p><code><br />
LockFile /var/run/httpd.lock<br />
CoreDumpDirectory /var/run<br />
ScoreBoardFile /var/run/httpd.scoreboard</code></p>
<p>Make sure mod_chroot.so line exists. For example, 64 bit Linux should have line as follows:</p>
<p><code>LoadModule chroot_module /usr/lib64/httpd/modules/mod_chroot.so</code></p>
<p>32 bit Linux config line:</p>
<p><code>LoadModule chroot_module /usr/lib/httpd/modules/mod_chroot.so</code></p>
<p>Save and close the file.<br />
Disable SELinux for Apache</p>
<p>You need to disable SELinux for apache, enter:<br />
<code># setsebool httpd_disable_trans 1</code><br />
See article “disabling SELinux for only Apache / httpd in Linux” for further details.<br />
Patch up /etc/init.d/httpd</p>
<p>Open /etc/init.d/httpd file, enter:<br />
# <code>vi /etc/init.d/httpd</code><br />
Find out line that read as follows:</p>
<p># Start httpd in the C locale by default.<br />
<code>HTTPD_LANG=${HTTPD_LANG-"C"}</code></p>
<p>Add following line (set ROOT to $J):</p>
<p><code>ROOT=/httpdjail</code></p>
<p>Find stop() that read as follows:</p>
<p><code>stop() {<br />
echo -n $"Stopping $prog: "<br />
killproc -d 10 $httpd<br />
RETVAL=$?<br />
echo<br />
[ $RETVAL = 0 ] &amp;&amp; rm -f ${lockfile} ${pidfile}<br />
}</code></p>
<p>Replace it as follows (you need to link /var/run/httpd.pid to $J/var/run/httpd.pid; so that stop operation works):</p>
<p><code>stop() {<br />
/bin/ln -s $ROOT/var/run/httpd.pid /var/run/httpd.pid<br />
echo -n $"Stopping $prog: "<br />
killproc -d 10 $httpd<br />
RETVAL=$?<br />
echo<br />
[ $RETVAL = 0 ] &amp;&amp; rm -f ${lockfile} ${pidfile}<br />
}</code></p>
<p>Save and close the file. Set immutable permission on /etc/init.d/httpd so that file cannot be modified, updated by yum, deleted or renamed, no link can be created to this file and no data can be written to the file. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute:<br />
<code># chattr +i /etc/init.d/httpd</code><br />
How do I start chrooted httpd?</p>
<p>Type the following command:<br />
<code># /etc/init.d/httpd start</code><br />
You should not see any error in /var/log/httpd/error_log file:</p>
<blockquote><p>[Sun Dec 21 18:43:09 2008] [notice] core dump file size limit raised to 18446744073709551615 bytes<br />
[Sun Dec 21 18:43:09 2008] [notice] SELinux policy enabled; httpd running as context root:system_r:initrc_t<br />
[Sun Dec 21 18:43:09 2008] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)<br />
[Sun Dec 21 18:43:09 2008] [notice] Digest: generating secret for digest authentication …<br />
[Sun Dec 21 18:43:09 2008] [notice] Digest: done<br />
[Sun Dec 21 18:43:10 2008] [notice] mod_chroot: changed root to /httpdjail.<br />
[Sun Dec 21 18:43:10 2008] [notice] Apache/2.2.3 (CentOS) configured — resuming normal operations</p></blockquote>
<h3>How do I stop chrooted httpd?</h3>
<p><code># /etc/init.d/httpd stop</code></p>
<h3>How do I restart chrooted httpd?</h3>
<p><code># /etc/init.d/httpd restart</code></p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/web-server/apache/chroot-apache-2-web-server.html" title="centos router">centos router</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/web-server/apache/chroot-apache-2-web-server.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mapping subdomains to parametered web pages in Apache</title>
		<link>http://thegioinguonmo.com/web-server/apache/mapping-subdomains-parametered-web-pages-apache.html</link>
		<comments>http://thegioinguonmo.com/web-server/apache/mapping-subdomains-parametered-web-pages-apache.html#comments</comments>
		<pubDate>Tue, 24 Apr 2012 09:40:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2171</guid>
		<description><![CDATA[Mapping john.webserver.com to http://www.webserver.com/user.php?name=john is just by changing a few parameters in http.conf file In httpd.conf file, &#60;VirtualHost se.rv.er.ip.ad.re.ss&#62; ServerAdmin info@servername.com DocumentRoot /var/www ErrorLog /var/log/apache/apache-error.log TransferLog /var/log/apache/apache.log ServerName www.servername.com ServerAlias *.servername.com RewriteEngine on RewriteCond %{HTTP_HOST} !^www.* [NC] RewriteCond %{HTTP_HOST} ^([^\.]+)\.servername\.com RewriteRule ^/$ http://www.servername.com/user.php?user=%1 &#60;/VirtualHost&#62; The lines for this feature, RewriteEngine on activating rewrite option RewriteCond [...]]]></description>
			<content:encoded><![CDATA[<p>Mapping <strong>john.webserver.com</strong> to <strong>http://www.webserver.com/user.php?name=john</strong><br />
is just by changing a few parameters in http.conf file<br />
In httpd.conf file,</p>
<pre class="brush:shell">&lt;VirtualHost se.rv.er.ip.ad.re.ss&gt;
        ServerAdmin info@servername.com
        DocumentRoot /var/www
        ErrorLog /var/log/apache/apache-error.log
        TransferLog /var/log/apache/apache.log
        ServerName www.servername.com
        ServerAlias *.servername.com
        RewriteEngine on
        RewriteCond %{HTTP_HOST} !^www.* [NC]
        RewriteCond %{HTTP_HOST} ^([^\.]+)\.servername\.com
        RewriteRule ^/$ http://www.servername.com/user.php?user=%1
&lt;/VirtualHost&gt;</pre>
<p>The lines for this feature,<br />
<strong>RewriteEngine on</strong> activating rewrite option</p>
<p><strong>RewriteCond %{HTTP_HOST} !^www.* [NC]</strong>  the rule will not be applied to subdomain &#8220;www&#8221;</p>
<p><strong>RewriteCond %{HTTP_HOST} ^([^\.]+)\.servername\.com</strong>  subdomain section will be our parameter</p>
<p><strong>RewriteRule ^/$ </strong><strong>http://www.servername.com/user.php?user=%1</strong>  parameter section which is grabbed as subdomain name will be our value for user variable to user.php file.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/web-server/apache/mapping-subdomains-parametered-web-pages-apache.html" title="thttpd centos 500 error">thttpd centos 500 error</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/web-server/apache/mapping-subdomains-parametered-web-pages-apache.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vbulltin PHP Xcache Displaying Same Forum Data For Both Boards Error and Solution</title>
		<link>http://thegioinguonmo.com/programing/php/vbulltin-php-xcache-displaying-forum-data-boards-error-solution.html</link>
		<comments>http://thegioinguonmo.com/programing/php/vbulltin-php-xcache-displaying-forum-data-boards-error-solution.html#comments</comments>
		<pubDate>Thu, 22 Mar 2012 14:27:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[vbuletin]]></category>
		<category><![CDATA[XCache]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2570</guid>
		<description><![CDATA[Q. I’ve followed your Xcache php 5.x opcode cacher installation under RHEL 5 for my vbulltin board. I see good boosting in performance. Now I’ve installed 2nd VB forum on the same server and I see all sub-forums hosted from 1st forum. So I had to disable Xcache. I want Xcache for both board on same host. How [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff0000;"><strong>Q</strong></span>. I’ve followed your <a rel="nofollow" target="_blank" href="http://www.cyberciti.biz/faq/howto-rhel-install-xcahce-php-opcode-cacher/">Xcache php 5.x opcode cacher</a> installation under RHEL 5 for my vbulltin board. I see good boosting in performance. Now I’ve installed 2nd VB forum on the same server and I see all sub-forums hosted from 1st forum. So I had to disable Xcache. I want Xcache for both board on same host. How do I fix this mess?</p>
<p><span style="color: #008000;"><strong>A</strong></span>. Xcache caches both php files and variable. Since vbulltin is the same product, it will cache and use same variable within cache. This is performance boosting feature. However, you can force xcache , so that VB do not try to use the same variable within the cache by specific to use a prefix. Make sure following two line exists in your VB config.php file (located in /path/to/forum/includes/config.php):</p>
<pre class="brush:plain"># vi config.php</pre>
<p>Append or modify settings as follows:<br />
<code>$config['Datastore']['class'] = 'vB_Datastore_XCache';<br />
$config['Datastore']['prefix'] = 'yourforumname';</code><br />
Save and close the file. Make sure you restart Apache:</p>
<pre class="brush:plain"># service httpd restart</pre>
<p>OR</p>
<pre class="brush:plain"># service lighttpd restart</pre>
<p>This works in a similar manner to the database table prefix. This is also applicable to other PHP caching systems such as APC and eAccelerator with more than one set of boards installed on same UNIX / Linux / Windows host.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/programing/php/vbulltin-php-xcache-displaying-forum-data-boards-error-solution.html" title="cent os unable to make action: unable to manage service by dnsmng">cent os unable to make action: unable to manage service by dnsmng</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/programing/php/vbulltin-php-xcache-displaying-forum-data-boards-error-solution.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Configure The AIDE (Advanced Intrusion Detection Environment) File Integrity Scanner For Your Website</title>
		<link>http://thegioinguonmo.com/security/configure-aide-advanced-intrusion-detection-environment-file-integrity-scanner-website.html</link>
		<comments>http://thegioinguonmo.com/security/configure-aide-advanced-intrusion-detection-environment-file-integrity-scanner-website.html#comments</comments>
		<pubDate>Thu, 15 Mar 2012 09:44:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[aide]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[ids]]></category>
		<category><![CDATA[Intrusion]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[scan]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=2457</guid>
		<description><![CDATA[A file integrity scanner is something you need to have.  Imagine a hacker placing a backdoor on your web site, or changing your order form to email him a copy of everyone&#8217;s credit card while leaving it appear to be functionally normally. By setting up daily reporting, this notifies you within, at most, 24 hours [...]]]></description>
			<content:encoded><![CDATA[<p>A file integrity scanner is something you need to have.  Imagine a hacker placing a backdoor on your web site, or changing your order form to email him a copy of everyone&#8217;s credit card while leaving it appear to be functionally normally.</p>
<p>By setting up daily reporting, this notifies you within, at most, 24 hours of when any file was changed, added, or removed.  It also helps establish an audit trail in the event your site is compromised.</p>
<p>These instructions are designed for an end user, where you don&#8217;t need to have root access, to implement and assumes your server has the aide binary installed.  Most hosts will have this installed already, or will install it for you upon request.</p>
<p>&nbsp;</p>
<h3>Step 1: Download A Sample AIDE config file</h3>
<p>We will start with a simple one, this will scan your web root directory for md5 hash changes.</p>
<p>To download the file, SSH into your account and run:</p>
<pre class="brush:plain">$ wget securehostingdirectory.com/aide.conf</pre>
<p>What you will want to change in this file, is replace &#8220;username&#8221; on the first line, and confirm that is the path to your root directory.</p>
<p>Then on the last line, confirm that public_html is your web root directory.  If your host uses the cPanel control panel, then public_html is your web root.</p>
<p>&nbsp;</p>
<h3>Step 2: Initialize the AIDE database</h3>
<p>The command to initialize the AIDE database is:</p>
<pre class="brush:plain">$ nice -19 aide --init --config=/home/username/aide.conf</pre>
<p>AIDE is not the least resource intensive software in the world so we are running it with a 19 priority using nice.</p>
<p>Now copy your AIDE output database file to the input file:</p>
<pre class="brush:plain">$ cp aide.db.out aide.db.in</pre>
<p>You can test aide by doing:</p>
<pre class="brush:plain">$ nice -19 aide -C --config=/home/username/aide.conf</pre>
<p>Go ahead and run that now, it will say all files match, then make a change to a file and add a file, rerun it and see what the report says.</p>
<p>&nbsp;</p>
<h3>Step 3: Daily Reporting</h3>
<p>There are a few ways to get the aide reports, a common one is to have it email you the reports, for this you can set a cronjob to run aide everyday, or even more frequently if you&#8217;d like.</p>
<p>Open up the crontab editor and paste in:</p>
<pre>0 1 * * * nice -19 /usr/local/bin/aide --config=/home/username/aide.conf -C| mail you@domain -saide\ domain</pre>
<p>The reports can get rather lengthy overtime, so if you want to reset the database, say weekly, you can add this to the crontab:</p>
<pre>0 2 * * 0  nice -19 /usr/local/bin/aide --config=/home/username/aide.conf --init;mv -f /home/username/aide.db.out /home/username/aide.db.in</pre>
<p>&nbsp;</p>
<h3>Step 4: Extras</h3>
<p>We have covered the basics, and that is actually only the tip of the iceberg of what you can do with AIDE.</p>
<p>You can get the full AIDE config file here: <a rel="nofollow" target="_blank" href="http://securehostingdirectory.com/aide.conf.full.txt" target="_blank">Full AIDE Config File</a></p>
<p>And you might want to exclude certain files, for example if you have a forum or gallery and a lot of images are added regularly you can exclude those from the report. For example to exclude all jpg files in images/ you would put the following in the config file:</p>
<pre> !@@{TOPDIR}/public_html/images/.*\.jpg$</pre>
<p>And that would go right above this line:</p>
<pre>@@{TOPDIR}/public_html MD</pre>
<p>Another thing you can do for extra security is, have your host chown your in database file, and your config file to another user, this way if your user is compromised, the hacker could not compromise your AIDE database, without also gaining access to the second user.</p>
<p>To be even more secure, you can download your AIDE database after creating it, and then upload it before you run a scan.</p>
<p>I hope this Howto lets you see the need for a file integrity checker, and makes it easy to setup, no matter what your user level is.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/security/configure-aide-advanced-intrusion-detection-environment-file-integrity-scanner-website.html" title="advanced intrusion detection environment">advanced intrusion detection environment</a> (1)</li><li><a href="http://thegioinguonmo.com/security/configure-aide-advanced-intrusion-detection-environment-file-integrity-scanner-website.html" title="aide conf example">aide conf example</a> (1)</li><li><a href="http://thegioinguonmo.com/security/configure-aide-advanced-intrusion-detection-environment-file-integrity-scanner-website.html" title="centos aide config">centos aide config</a> (1)</li><li><a href="http://thegioinguonmo.com/security/configure-aide-advanced-intrusion-detection-environment-file-integrity-scanner-website.html" title="configure aide in shell script">configure aide in shell script</a> (1)</li><li><a href="http://thegioinguonmo.com/security/configure-aide-advanced-intrusion-detection-environment-file-integrity-scanner-website.html" title="htdocs centos 5 5 location">htdocs centos 5 5 location</a> (1)</li><li><a href="http://thegioinguonmo.com/security/configure-aide-advanced-intrusion-detection-environment-file-integrity-scanner-website.html" title="nice 19 aide --check">nice 19 aide --check</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/security/configure-aide-advanced-intrusion-detection-environment-file-integrity-scanner-website.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache give each user their own cgi-bin directory</title>
		<link>http://thegioinguonmo.com/web-server/apache/apache-give-user-cgibin-directory.html</link>
		<comments>http://thegioinguonmo.com/web-server/apache/apache-give-user-cgibin-directory.html#comments</comments>
		<pubDate>Sat, 03 Mar 2012 09:40:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[home]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[user]]></category>

		<guid isPermaLink="false">http://thegioinguonmo.com/?p=1846</guid>
		<description><![CDATA[Apache has public_html directory support. With this you specify the name of the directory which is appended onto a user&#8217;s home directory if a ~user request is received. For example http://domain.com/~rocky/file.html will be rocky&#8217;s home directory /home/rocky/public_html/file.html. Recently I took small part time job to setup web server for university. I want to give every [...]]]></description>
			<content:encoded><![CDATA[<p>Apache has public_html directory support. With this you specify the name of the directory which is appended onto a user&#8217;s home directory if a ~user request is received. For example http://domain.com/~rocky/file.html will be rocky&#8217;s home directory /home/rocky/public_html/file.html. Recently I took small part time job to setup web server for university. I want to give every student access to cgi-bin so that they can use perl. I don&#8217;t wanna give everyone access to /var/www/cgi-bin or /usr/lib/cgi-bin directory. ScriptAliases enables documents in the cgi-bin directory treated as applications and run by the server when requested rather than as documents sent to the client. So first I did setup ScriptAlias. However it was not working.<br />
So all students was able to see each others perl source code <img src='http://thegioinguonmo.com/wp-includes/images/smilies/icon_sad.gif' alt="icon sad Apache give each user their own cgi bin directory" class='wp-smiley' title="Apache give each user their own cgi bin directory" />  so I was called again to fix this problem. After searching little bit, I found solution from offical Apache docs. So I modified httpd.conf and added following two directives to /home/*/public_html/cgi-bin section:</p>
<pre>Options ExecCGI
SetHandler cgi-script</pre>
<p>At the end final entry looked like as follows:</p>
<pre>&lt;Directory /home/*/public_html/cgi-bin&gt;
Options ExecCGI
SetHandler cgi-script
&lt;/Directory&gt;</pre>
<p>Then I restarted apache and it worked like a charm. See Apache document <a rel="nofollow" target="_blank" href="http://httpd.apache.org/docs/1.3/howto/cgi.html">Dynamic Content with CGI</a>. Update: As pointed out by Randal you just need to add above four lines.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://thegioinguonmo.com/web-server/apache/apache-give-user-cgibin-directory.html" title="apache directadmin hide version">apache directadmin hide version</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/apache/apache-give-user-cgibin-directory.html" title="apache user directory cgi">apache user directory cgi</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/apache/apache-give-user-cgibin-directory.html" title="apache2 server name *">apache2 server name *</a> (1)</li><li><a href="http://thegioinguonmo.com/web-server/apache/apache-give-user-cgibin-directory.html" title="cpanel /cgi-bin/ for each user">cpanel /cgi-bin/ for each user</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://thegioinguonmo.com/web-server/apache/apache-give-user-cgibin-directory.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:13:45 -->
