<?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>Linux Admin Zone &#187; Web Server</title>
	<atom:link href="http://linuxadminzone.com/category/web-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://linuxadminzone.com</link>
	<description>Adding more reasons to celebrate Open Source.</description>
	<lastBuildDate>Wed, 09 May 2012 10:17:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>How to setup Git http authentication using LDAP in Apache</title>
		<link>http://linuxadminzone.com/how-to-setup-git-http-authentication-using-ldap-in-apache/</link>
		<comments>http://linuxadminzone.com/how-to-setup-git-http-authentication-using-ldap-in-apache/#comments</comments>
		<pubDate>Wed, 18 Apr 2012 13:05:37 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[Web Server]]></category>
		<category><![CDATA[git http ldap]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=495</guid>
		<description><![CDATA[In earlier article, I have described setting up git server with gitolite, gitweb, ssh and http auth using passwd file. Here as an extension of that article, I am describing how to do authentication using LDAP so that authentication become more seamless and avoid any sort of manual work for managing access when you have [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://linuxadminzone.com/quickly-setup-git-server-with-gitolite-gitweb-ssh-and-http-auth/" target="_blank">earlier article</a>, I have described setting up git server with gitolite, gitweb, ssh and http auth using passwd file. Here as an extension of that article, I am describing how to do authentication using LDAP so that authentication become more seamless and avoid any sort of manual work for managing access when you have LDAP for authenticating users. </p>
<p>Before proceeding for change in config, you should confirm that ldap and authnz_ldap modules are there in Apache. You can check that using <strong>httpd -M</strong> command, following should be there in output:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ httpd <span style="color: #660033;">-M</span> 
..
 ldap_module <span style="color: #7a0874; font-weight: bold;">&#40;</span>shared<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 authnz_ldap_module <span style="color: #7a0874; font-weight: bold;">&#40;</span>shared<span style="color: #7a0874; font-weight: bold;">&#41;</span>
..</pre></div></div>

<p>If this is not the case, then please install these modules and make sure you load them in your Apache config (usually <strong>/etc/httpd/conf/httpd.conf</strong>) like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LoadModule ldap_module modules<span style="color: #000000; font-weight: bold;">/</span>mod_ldap.so
LoadModule authnz_ldap_module modules<span style="color: #000000; font-weight: bold;">/</span>mod_authnz_ldap.so</pre></div></div>

<p>After having these modules to facilitate authentication, we need to remove or comment out following lines in our git config file <strong>/etc/httpd/conf.d/git.conf</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>Location <span style="color: #000000; font-weight: bold;">/&gt;</span>
    AuthType Basic
    AuthName <span style="color: #ff0000;">&quot;Private Git Access&quot;</span>
    Require valid-user
    AuthUserFile <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>gitweb<span style="color: #000000; font-weight: bold;">/</span>passfile
<span style="color: #000000; font-weight: bold;">&lt;/</span>Location<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>After removing or commenting out above lines, put these lines in the file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>Location <span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
    AuthType Basic
    AuthName <span style="color: #ff0000;">&quot;Git Authentication&quot;</span>
    AuthBasicProvider ldap
    AuthzLDAPAuthoritative off
    AuthLDAPURL <span style="color: #ff0000;">&quot;ldap://&lt;my ad server&gt;:389/ou=xx,dc=xx,dc=xx,dc=com?sAMAccountName?sub?(objectClass=user)&quot;</span>
    AuthLDAPBindDN <span style="color: #000000; font-weight: bold;">&lt;</span>user<span style="color: #000000; font-weight: bold;">&gt;@&lt;</span>mydomain<span style="color: #000000; font-weight: bold;">&gt;</span>
    AuthLDAPBindPassword <span style="color: #000000; font-weight: bold;">&lt;</span>user password<span style="color: #000000; font-weight: bold;">&gt;</span>
    Require valid-user
<span style="color: #000000; font-weight: bold;">&lt;/</span>Location<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Here make sure to supply correct LDAP url and provide info of one user and its password so that Apache can contact LDAP to retrieve authentication information. You also needs to update <strong>gitolite.conf</strong> to manage authorization for git repositories for LDAP user. </p>
<p>Reload Apache to apply new settings and you should be able to access Git repository over http using LDAP user.</p>
<p><strong>Common issues:</strong><br />
If authentication not working, put &#8220;<strong>Loglevel Debug</strong>&#8221; option in your Apache VirtualHost and check Apache error logs. In case you notice following error:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>Wed Apr <span style="color: #000000;">18</span> <span style="color: #000000;">15</span>:02:<span style="color: #000000;">13</span> <span style="color: #000000;">2012</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>debug<span style="color: #7a0874; font-weight: bold;">&#93;</span> mod_authnz_ldap.c<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">454</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>: <span style="color: #7a0874; font-weight: bold;">&#91;</span>client xx.xx.xx.xx<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25749</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> auth_ldap authenticate: accepting user.name
<span style="color: #7a0874; font-weight: bold;">&#91;</span>Wed Apr <span style="color: #000000;">18</span> <span style="color: #000000;">15</span>:02:<span style="color: #000000;">13</span> <span style="color: #000000;">2012</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>debug<span style="color: #7a0874; font-weight: bold;">&#93;</span> mod_authnz_ldap.c<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">821</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>: <span style="color: #7a0874; font-weight: bold;">&#91;</span>client xx.xx.xx.xx<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25749</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> auth_ldap authorise: declining to authorise</pre></div></div>

<p>Then make sure <strong>AuthzLDAPAuthoritative off</strong> entry is there in Apache git config file, I have already mentioned it above just in case if you missed it.</p>
<p>In case you notice &#8220;<strong>[User Not Found]</strong>&#8221; in error log, then check your user name again and make sure the user exist in correct OU/group specified in ldap url.</p>
<p>Related articles:<br />
* <a href="http://linuxadminzone.com/quickly-setup-git-server-with-gitolite-gitweb-ssh-and-http-auth/" target="_blank"> Quickly setup Git server with gitolite, gitweb, ssh and http auth </a><br />
* <a href="http://linuxadminzone.com/configure-password-based-subversion-access-via-http-for-multiple-users/" target="_blank"> Configure password based subversion access via http </a><br />
* <a href="http://linuxadminzone.com/download-install-and-configure-viewvc-for-subversion/" target="_blank"> Download, install and configure ViewVC for Subversion </a></p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/how-to-setup-git-http-authentication-using-ldap-in-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quickly setup git server with gitolite, gitweb, ssh and http auth</title>
		<link>http://linuxadminzone.com/quickly-setup-git-server-with-gitolite-gitweb-ssh-and-http-auth/</link>
		<comments>http://linuxadminzone.com/quickly-setup-git-server-with-gitolite-gitweb-ssh-and-http-auth/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 08:26:17 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[gitolite]]></category>
		<category><![CDATA[gitweb]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=482</guid>
		<description><![CDATA[As per the official definition, Git is a free &#38; open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency. I am describing here steps which I followed to setup a Git server along with Gitolite, Gitweb, ssh and http auth in RHEL5 machine. I [...]]]></description>
			<content:encoded><![CDATA[<p>As per the official definition, <a href="http://git-scm.com/" target="_blank">Git</a> is a <strong>free &amp; open source, distributed version control system</strong> designed to handle everything from small to very large projects with speed and efficiency. I am describing here steps which I followed to setup a Git server along with Gitolite, Gitweb, ssh and http auth in RHEL5 machine. I have done the installations using RPMs (lazy men&#8217;s method) which I got from here: <a href="http://pkgs.repoforge.org/git/">http://pkgs.repoforge.org/git/</a></p>
<p><strong>Step 1: Download the required RPMs or install using source</strong></p>
<p>Here are the RPMs I downloaded from source mentioned above (of course, download the latest version of these RPMs when you wants to do installation):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git-1.7.8.2-<span style="color: #000000;">2</span>.el5.rf.x86_64.rpm
gitolite-1.5.9.1-<span style="color: #000000;">2</span>.el5.noarch.rpm
gitweb-1.7.8.2-<span style="color: #000000;">2</span>.el5.rf.x86_64.rpm</pre></div></div>

<p>You may also need to have some perl dependencies which you can install through CPAN or can also download the RPMs for them, I needed below ones:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">perl-DBI-<span style="color: #000000;">1.617</span>-<span style="color: #000000;">1</span>.el5.rfx.x86_64.rpm
perl-Git-1.7.8.2-<span style="color: #000000;">2</span>.el5.rf.x86_64.rpm
perl-TermReadKey-<span style="color: #000000;">2.30</span>-<span style="color: #000000;">3</span>.el5.rf.x86_64.rpm <span style="color: #7a0874; font-weight: bold;">&#40;</span>Optional<span style="color: #7a0874; font-weight: bold;">&#41;</span>
perl-Error-<span style="color: #000000;">0.17017</span>-<span style="color: #000000;">1</span>.el5.rf.noarch.rpm <span style="color: #7a0874; font-weight: bold;">&#40;</span>Optional<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p><strong>Step 2: Install the RPMs:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ rpm <span style="color: #660033;">-ivh</span> perl-DBI-<span style="color: #000000;">1.617</span>-<span style="color: #000000;">1</span>.el5.rfx.x86_64.rpm perl-TermReadKey-<span style="color: #000000;">2.30</span>-<span style="color: #000000;">3</span>.el5.rf.x86_64.rpm perl-Error-<span style="color: #000000;">0.17017</span>-<span style="color: #000000;">1</span>.el5.rf.noarch.rpm git-1.7.8.2-<span style="color: #000000;">2</span>.el5.rf.x86_64.rpm perl-Git-1.7.8.2-<span style="color: #000000;">2</span>.el5.rf.x86_64.rpm  gitolite-1.5.9.1-<span style="color: #000000;">2</span>.el5.noarch.rpm gitweb-1.7.8.2-<span style="color: #000000;">2</span>.el5.rf.x86_64.rpm</pre></div></div>

<p>We have Git, Gitolite and Gitweb installed now.</p>
<p><strong>Step 3: Configure Gitolite for authentication/authorization: </strong></p>
<p>We need to configure Gitolite and the information for that is already described <a href="http://sitaramc.github.com/gitolite/rpmdeb.html" target="_blank">here</a> so I am skipping that part.</p>
<p><strong>Step 4: (Optional) Test Git with Gitolite:</strong></p>
<p>Its worth a try to quickly test Git with Gitolite you just installed/configured. Jump to your pc and if you have Linux, generate public/private keys using ssh-keygen utility in case you already don’t have, for testing purposes, you can use following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-N</span> <span style="color: #ff0000;">''</span> <span style="color: #660033;">-t</span> rsa <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa</pre></div></div>

<p>In case you are using Windows (which unfortunately I am using as of now), you can use puttygen utility and can refer a good tutorial <a href="http://sshcontrol.com/help/puttygen_keys" target="_blank">here</a> for exact process.</p>
<p>Copy your public key file to Git server, rename it to yourname.pub and put it in this directory so that Gitolite can refer/read them when needed: /var/lib/gitolite/.gitolite/keydir/</p>
<p>Time to clone gitolite-admin repository now, for Linux, just use:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>serverip:gitolite-admin</pre></div></div>

<p>For Windows, you can install <a href="http://code.google.com/p/msysgit/downloads/detail?name=Git-1.7.9-preview20120201.exe&amp;can=2&amp;q" target="_blank">msysgit</a> and optionally you can install a cool Git client like TortoiseGit from <a href="http://code.google.com/p/tortoisegit/downloads/detail?name=TortoiseGit-1.7.7.0-32bit.msi&amp;can=2&amp;q" target="_blank">here</a>. To Clone the gitolite-admin repository now, browse any directory, right click, choose <strong>Git Clone…</strong> and put required information. A sample screenshot is below:</p>
<p>Clone should get successful and you will get gitolite-admin repository in your pc. Go inside and update gitolite.conf to add new repositories/users. This process is described <a href="http://sitaramc.github.com/gitolite/pictures.html#1000_words_adding_users_to_gitolite_" target="_blank">here</a> if you want to continue testing.</p>
<p><strong>Step 5: Configure Gitweb, http access of Git</strong></p>
<p>This process is also documented by original author <a href="http://sitaramc.github.com/gitolite/ggshb.html" target="_blank">here</a> but that is for OpenSuSE and while following that, I ran in some issues, so here posting information to setup this in RHEL machine which is working for me. You may want to refer that documentation in case things are not very clear reading my instructions because I am not diving in details and focus is more on practical execution.</p>
<p>Add following line in <strong>/var/lib/gitolite/.gitolite.rc</strong> file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$GL_GITCONFIG_KEYS</span> = <span style="color: #ff0000;">&quot;gitweb.url receive.denyNonFastforwards receive.denyDeletes&quot;</span>;</pre></div></div>

<p>Add some config entries in gitolite.conf file along with entry for daemon user. My gitolite.conf looks like below:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>gitolite<span style="color: #000000; font-weight: bold;">/</span>.gitolite<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>gitolite.conf
repo    gitolite-admin
RW+     =   <span style="color: #c20cb9; font-weight: bold;">git</span> daemon
&nbsp;
repo    tproject
RW      = <span style="color: #c20cb9; font-weight: bold;">git</span> jagbir daemon
R       = <span style="color: #000000; font-weight: bold;">@</span>all
config  gitweb.url = <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>serverip:tproject
config  receive.denyNonFastforwards = <span style="color: #c20cb9; font-weight: bold;">true</span>
config  receive.denyDeletes         = <span style="color: #c20cb9; font-weight: bold;">true</span>
&nbsp;
repo    <span style="color: #000000; font-weight: bold;">@</span>all
R       =   daemon gitweb</pre></div></div>

<p>Don’t forget to add daemon in all repositories, whether for Read write or just read to enabling browsing through http.</p>
<p><strong>Step 6: Configure Apache under SuExec:</strong><br />
Apache runs under <strong>Apache</strong> user while our Git repositories are under <strong>Gitolite</strong> user. We have to use <strong>SuExec</strong> module in Apache so that it will also run under <strong>Gitolite</strong> user and be able to update information in repositories. Confirm that SuExec module is there in you Apache by running: <strong>$ httpd –M</strong> command and you should have <strong>suexec_module (shared)</strong> line in output.</p>
<p>Update permissions of suexec program. We also needs to have a wrapper script and to know where to put it check options of suexec, here are commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">chgrp</span> apache <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>suexec
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">4750</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>suexec
$ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>suexec <span style="color: #660033;">-V</span>
<span style="color: #660033;">-D</span> <span style="color: #007800;">AP_DOC_ROOT</span>=<span style="color: #ff0000;">&quot;/var/www&quot;</span>
<span style="color: #660033;">-D</span> <span style="color: #007800;">AP_GID_MIN</span>=<span style="color: #000000;">100</span>
<span style="color: #660033;">-D</span> <span style="color: #007800;">AP_HTTPD_USER</span>=<span style="color: #ff0000;">&quot;apache&quot;</span>
<span style="color: #660033;">-D</span> <span style="color: #007800;">AP_LOG_EXEC</span>=<span style="color: #ff0000;">&quot;/var/log/httpd/suexec.log&quot;</span>
<span style="color: #660033;">-D</span> <span style="color: #007800;">AP_SAFE_PATH</span>=<span style="color: #ff0000;">&quot;/usr/local/bin:/usr/bin:/bin&quot;</span>
<span style="color: #660033;">-D</span> <span style="color: #007800;">AP_UID_MIN</span>=<span style="color: #000000;">500</span>
<span style="color: #660033;">-D</span> <span style="color: #007800;">AP_USERDIR_SUFFIX</span>=<span style="color: #ff0000;">&quot;public_html&quot;</span></pre></div></div>

<p>So path for our wrapper script and Gitweb is /var/www as shown above in AP_DOC_ROOT value. Create a wrapper script in /var/www/bin/ directory (create bin directory first). My script looks like below which you can copy as is:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gitolite-suexec-wrapper.sh
<span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">USER</span>=<span style="color: #007800;">$1</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">GIT_PROJECT_ROOT</span>=<span style="color: #ff0000;">&quot;/var/lib/gitolite/repositories&quot;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">GITOLITE_HTTP_HOME</span>=<span style="color: #ff0000;">&quot;/var/lib/gitolite&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gl-auth-command <span style="color: #007800;">$USER</span></pre></div></div>

<p>Because Gitweb will also runs under gitolite user, copy all of its files to /var/www directory and make sure the owner of /var/www directory (along with all subdirectories/files should be gitolite user), here are commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>gitweb <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www
$ <span style="color: #c20cb9; font-weight: bold;">chown</span> –R gitolite.gitolite <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www</pre></div></div>

<p>Update gitweb.conf file to point to gitolite directory where all repositories are there, below line should be there in <strong>/etc/gitweb.conf</strong> file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">our <span style="color: #007800;">$projectroot</span> = <span style="color: #ff0000;">&quot;/var/lib/gitolite&quot;</span>;</pre></div></div>

<p><strong>Step 7: Configure Virtualhost in Apache:</strong><br />
Here is my apache virtual host file, which you can copy as is (of course, change ServerName, Alias etc as per your values):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$  <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span>conf.d<span style="color: #000000; font-weight: bold;">/</span>git.conf
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>VirtualHost <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
ServerName  git.mydomain.com
ServerAlias <span style="color: #c20cb9; font-weight: bold;">git</span>
&nbsp;
DocumentRoot <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>gitweb
&nbsp;
SuexecUserGroup gitolite gitolite
&nbsp;
SetEnv GIT_PROJECT_ROOT <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>gitolite<span style="color: #000000; font-weight: bold;">/</span>projects
SetEnv GIT_HTTP_EXPORT_ALL
&nbsp;
SetEnv GITOLITE_HTTP_HOME <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>gitolite
&nbsp;
ScriptAliasMatch \
<span style="color: #ff0000;">&quot;(?x)^/(.*/(HEAD | <span style="color: #000099; font-weight: bold;">\
</span>info/refs | <span style="color: #000099; font-weight: bold;">\
</span>objects/(info/[^/]+ | <span style="color: #000099; font-weight: bold;">\
</span>[0-9a-f]{2}/[0-9a-f]{38} | <span style="color: #000099; font-weight: bold;">\
</span>pack/pack-[0-9a-f]{40}\.(pack|idx)) | <span style="color: #000099; font-weight: bold;">\
</span>git-(upload|receive)-pack))$&quot;</span> \
<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gitolite-suexec-wrapper.sh<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$1</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>Directory <span style="color: #ff0000;">&quot;/var/www/gitweb&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
Options ExecCGI
AllowOverride None
AddHandler cgi-script .cgi
DirectoryIndex gitweb.cgi
Order allow,deny
Allow from all
<span style="color: #000000; font-weight: bold;">&lt;/</span>Directory<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>Directory <span style="color: #ff0000;">&quot;/var/www/bin&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>Files <span style="color: #ff0000;">&quot;gitolite-suexec-wrapper.sh&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
Order allow,deny
Allow from all
<span style="color: #000000; font-weight: bold;">&lt;/</span>Files<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>Directory<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>Location <span style="color: #000000; font-weight: bold;">/&gt;</span>
AuthType Basic
AuthName <span style="color: #ff0000;">&quot;Git Access&quot;</span>
Require valid-user
AuthUserFile <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>gitweb<span style="color: #000000; font-weight: bold;">/</span>authfile
<span style="color: #000000; font-weight: bold;">&lt;/</span>Location<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;/</span>VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>As you can see we are using basic authentication here and for that, you need to create file which will have auth information, create file and sample user (gitolite) to test it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ htpasswd <span style="color: #660033;">-cmd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>gitolite<span style="color: #000000; font-weight: bold;">/</span>authfile gitolite
New password:
Re-type new password:
Adding password <span style="color: #000000; font-weight: bold;">for</span> user gitolite
&nbsp;
$ <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>gitolite<span style="color: #000000; font-weight: bold;">/</span>authfile
gitolite:wG7<span style="color: #000000; font-weight: bold;">/</span>EAcl9kdvU</pre></div></div>

<p>Make sure you have initialize the repository to enable its access via http, let&#8217;s prepare testing repository for this purpose:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>gitolite<span style="color: #000000; font-weight: bold;">/</span>repositories<span style="color: #000000; font-weight: bold;">/</span>testing.git
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #660033;">-u</span> gitolite <span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #660033;">--bare</span> init
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #660033;">-u</span> gitolite <span style="color: #c20cb9; font-weight: bold;">git</span> update-server-info
$ <span style="color: #c20cb9; font-weight: bold;">mv</span> hooks<span style="color: #000000; font-weight: bold;">/</span>post-update.sample hooks<span style="color: #000000; font-weight: bold;">/</span>post-update
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x hooks<span style="color: #000000; font-weight: bold;">/</span>post-update</pre></div></div>

<p>The above steps are needed for http access otherwise you will get error like below in your apache error logs when trying to clone:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>Tue Apr <span style="color: #000000;">10</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">34</span>:<span style="color: #000000;">16</span> <span style="color: #000000;">2012</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>error<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>client <span style="color: #000000;">10.100</span>.xx.xx<span style="color: #7a0874; font-weight: bold;">&#93;</span> Repository not exported: <span style="color: #ff0000;">'/var/lib/gitolite/repositories/testing'</span></pre></div></div>

<p>All files under /var/www should have gitolite as owner, let’s update permissions once more:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$  <span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> gitolite:gitolite <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www</pre></div></div>

<p><strong>Step 7: Test it out: </strong><br />
Restart apache and try to browse your server now: <a href="http://serverip">http://serverip</a>. It should ask username/password and after supply correct, you should be able to see gitweb interface showing your repositories where you can traverse in them.</p>
<p>In case you see a blank page, then it might be issue with SuExec. Check suexec log file:  /var/log/httpd/suexec.log. You may see a message like:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2012</span>-03-<span style="color: #000000;">30</span> 04:<span style="color: #000000;">14</span>:<span style="color: #000000;">26</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: cannot run <span style="color: #c20cb9; font-weight: bold;">as</span> forbidden uid <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">/</span>gitweb.cgi<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>This means suexec won’t execute under user/group have userid/groupid less than 500 (system). In this case you can change this id for our gitolite user as per below:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ usermod <span style="color: #660033;">-u</span> <span style="color: #000000;">650</span> gitolite
$ groupmod <span style="color: #660033;">-g</span> <span style="color: #000000;">650</span> gitolite</pre></div></div>

<p>650 is just an example here, you can use any value above 500 in case 650 is already used by existing user/group. As user/group id get changed, you need to set permissions again for your directories:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">chown</span> –R gitolite:gitolite <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www</pre></div></div>

<p>Try now and you should be able to browse smoothly. Please put a comment below if you are still facing any issues, I would try to help you out.</p>
<p>Update: If you want to perform authentication using LDAP for git which I have described in next article, you can access it using below link: </p>
<p>* <a href="http://linuxadminzone.com/how-to-setup-git-http-authentication-using-ldap-in-apache/" target="_blank"> Setup Git auth using LDAP </a></p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/quickly-setup-git-server-with-gitolite-gitweb-ssh-and-http-auth/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dynamically manage Apache virtualhosts in Linux</title>
		<link>http://linuxadminzone.com/dynamically-manage-apache-virtualhosts-in-linux/</link>
		<comments>http://linuxadminzone.com/dynamically-manage-apache-virtualhosts-in-linux/#comments</comments>
		<pubDate>Sun, 11 Sep 2011 12:18:43 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web Server]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=446</guid>
		<description><![CDATA[This is second part of article to describe how to dynamically manage Apache Virtual host. You can read first article here. In earlier article I mentioned using a php script to dynamically create/remove virtualhost entry in Apache (httpd) config file and then reload it using cron. Here I would describe how to manage DNS to [...]]]></description>
			<content:encoded><![CDATA[<p>This is second part of article to describe how to dynamically manage Apache Virtual host. You can read first article <a href="http://linuxadminzone.com/php-script-to-dynamically-create-remove-apache-virtual-hosts-subdomains/">here</a>. </p>
<p>In earlier article I mentioned using a php script to dynamically create/remove virtualhost entry in Apache (httpd) config file and then reload it using cron. </p>
<p>Here I would describe how to manage DNS to dynamically recognize newly created virtualhosts. Again, this might not be the best or efficient way to implement this but this is what worked for me. After creating virtualhosts in Apache, you need to update DNS so that new virtualhosts start working. To update DNS dynamically, your DNS provider should have some way (like API) which enable you to manipulate its records. There are few providers offering this facility. For this experiment, I selected <a href="www.dnsmadeeasy.com" target="_blank">DNSMadeEasy</a> which provides <a href="http://www.dnsmadeeasy.com/enterprise-dns/rest-api/" target="_blank">APIs</a> to add/remove/update records on fly using scripts.</p>
<p>You can see the script below written in php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">date_default_timezone_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;GMT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$reqDate</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D, d M Y H:i:s T&quot;</span><span style="color: #339933;">,</span><span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;H&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;i&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;s&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">45</span><span style="color: #339933;">,</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;m&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;d&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$apiKey</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;my-api-key&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$secretKey</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'my-secret-key'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$secretKey2</span> <span style="color: #339933;">=</span> <span style="color: #990000;">hash_hmac</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sha1'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$reqDate</span><span style="color: #339933;">,</span> <span style="color: #000088;">$secretKey</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$URL</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://api.dnsmadeeasy.com/V1.2/domains/example.com/records&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;b&gt;Endpoint :&lt;/b&gt; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$URL</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$headers</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'x-dnsme-requestId: '</span><span style="color: #339933;">.</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'x-dnsme-apiKey: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$apiKey</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'x-dnsme-requestDate: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$reqDate</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'x-dnsme-hmac: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$secretKey2</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'accept:application/xml'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'content-type:application/xml'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;br&gt;&lt;br&gt;&lt;b&gt;Request Headers&lt;/b&gt;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'x-dnsme-requestId: '</span><span style="color: #339933;">.</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">.</span>
<span style="color: #0000ff;">'x-dnsme-apiKey: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$apiKey</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">.</span>
<span style="color: #0000ff;">'x-dnsme-requestDate: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$reqDate</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">.</span>
<span style="color: #0000ff;">'x-dnsme-hmac: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$secretKey2</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">.</span>
<span style="color: #0000ff;">'accept:application/xml'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">.</span>
<span style="color: #0000ff;">'content-type:application/xml'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$body</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'
&lt;record&gt;
&lt;data&gt;xx.xx.xx.xx&lt;/data&gt;
&lt;gtdLocation&gt;Default&lt;/gtdLocation&gt;
&lt;id&gt;123456&lt;/id&gt;
&lt;name&gt;dummy&lt;/name&gt;
&lt;ttl&gt;1800&lt;/ttl&gt;
&lt;type&gt;A&lt;/type&gt;
&lt;/record&gt;
'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;br&gt;&lt;br&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$body</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$URL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_CONNECTTIMEOUT<span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_HTTPHEADER<span style="color: #339933;">,</span> <span style="color: #000088;">$headers</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//curl_setopt($ch, CURLOPT_PUT, 1);</span>
<span style="color: #666666; font-style: italic;">//curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POST<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$body</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_HEADER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$ResponseStr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_close</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;pre&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$ResponseStr</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>You need to have Api key and Secret key which you will get upon registration on DNSMadeEasy. This is very basic script to update DNS record dynamically. You can extend it further to incorporate more functions. </p>
<p>So basically to manage Apache virtalhosts dynamically, you need following functionality:<br />
* Script to create/update/remove them from Apache (httpd) config file.<br />
* Reload Apache to apply new settings which can be done through a simple cron entry.<br />
* Script to update DNS records to reflect changes.</p>
<p>Let me know if you have some other way/idea to implement this.</p>
<p>Helpful related articles:<br />
* <a href="http://linuxadminzone.com/php-script-to-dynamically-create-remove-apache-virtual-hosts-subdomains/">PHP script to dynamically add/remove/update virtualhosts in Apache</a><br />
* <a href="http://linuxadminzone.com/upgrade-apachehttpd-to-2-2-17-in-centos-linux/"> Upgrade Apache in Linux quickly </a><br />
* <a href="http://linuxadminzone.com/upgrade-update-php-to-latest-5-2-17-in-linux/"> Upgrade to latest PHP using yum upgrade </a><br />
* <a href="http://linuxadminzone.com/5-steps-to-secure-your-linux-server/"> 5 Steps to secure your Linux Server </a><br />
* <a href="http://linuxadminzone.com/disable-weak-ssl-ciphers-in-lighttpd-in-linux/"> Disable weak ssl ciphers in lighttpd in Linux </a><br />
* <a href="http://linuxadminzone.com/disable-ssl-ver-2-in-apache-for-pci-compliance/"> Disable SSL ver 2 in Apache for security and PCI Compliance </a></p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/dynamically-manage-apache-virtualhosts-in-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP script to dynamically create/remove apache virtual hosts/ subdomains</title>
		<link>http://linuxadminzone.com/php-script-to-dynamically-create-remove-apache-virtual-hosts-subdomains/</link>
		<comments>http://linuxadminzone.com/php-script-to-dynamically-create-remove-apache-virtual-hosts-subdomains/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 11:08:17 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=438</guid>
		<description><![CDATA[There&#8217;s situation with my friend where his team wanted to dynamically create/remove virtual hosts or subdomains using php. This can be achieved in several ways. You can use a control panel which obviously use resources or develop your own script to do this. There&#8217;s security aspects attached with script because it needs to update file [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s situation with my friend where his team wanted to dynamically create/remove virtual hosts or subdomains using php. This can be achieved in several ways. You can use a control panel which obviously use resources or develop your own script to do this. There&#8217;s security aspects attached with script because it needs to update file which is read by Apache and to apply settings, you need to reload Apache. Here I am describing how my friend achieved their goal, again I&#8217;m saying that this might not be the best way to do this thing and may be comparatively insecure or inefficient but this is what worked for them in Ubuntu host.</p>
<p>Create script to update Apache config file to create/remove subdomains/virtual hosts, here&#8217;s the script which I called here as subdmanager.php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$templateStr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'##-- Entry start for &lt;usersubdomain&gt; --
&lt;VirtualHost x.x.x.x:80&gt;
    ServerAdmin webmaster@&lt;usersubdomain&gt;.exampledomain.com
    ServerName &lt;usersubdomain&gt;.exampledomain.com
    ServerAlias www.&lt;usersubdomain&gt;.exampledomain.com
    UseCanonicalName Off
    DirectoryIndex index.php 
    DocumentRoot /var/www/maindomains/exampledomain.com/subdomains/&lt;usersubdomain&gt;/
        ErrorLog /var/www/logsvhosts/exampledomain.com/users-error-log
        LogLevel error
&nbsp;
        &lt;IfModule mod_ssl.c&gt;
                SSLEngine off
        &lt;/IfModule&gt;
        &lt;Directory /var/www/maindomains/exampledomain.com/subdomains/&lt;usersubdomain&gt;.com&gt;
                Options -Includes -ExecCGI
        &lt;/Directory&gt;
&lt;/VirtualHost&gt;
##-- Entry End for &lt;usersubdomain&gt; --'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$argv</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$k</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$argvStr</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$v</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;-----&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$argvStr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$argvStr</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&lt;-----&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$argvArr</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;-----&gt;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$argvStr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$case</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$argvArr</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//&quot;create&quot;;</span>
<span style="color: #000088;">$subdomain_name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$argvArr</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Here we are making a template for virtualhost entry. the string</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"> &lt;usersubdomain&gt;</pre></div></div>

<p> will be replaced by actual subdomain selected by user. exampledomain.com is the main website. No need to mention that all path, IP address (denoted by x.x.x.x here) are used as an example here, please replace them with your own actual values. </p>
<p>Then we are checking the command line option (create or remove), subdomain name and store values in respective variable.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$case</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$case</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'create'</span><span style="color: #339933;">:</span>
&nbsp;
		<span style="color: #000088;">$domainStr2</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;usersubdomain&gt;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$subdomain_name</span><span style="color: #339933;">,</span><span style="color: #000088;">$templateStr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/etc/apache2/sites-enabled/user-sites&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$mainStr1</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$fp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #339933;">,</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mainStr1</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">''</span>?<span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$domainStr2</span><span style="color: #339933;">:</span><span style="color: #000088;">$domainStr2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'remove'</span><span style="color: #339933;">:</span>
&nbsp;
		<span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/etc/apache2/sites-enabled/user-sites&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$contents</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$contents</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$line</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$line</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Entry start for &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$subdomain_name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; --&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$myStartKey</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$key</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$line</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Entry End for &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$subdomain_name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; --&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$myLastKey</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$key</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #000088;">$myStartKey</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&lt;=</span><span style="color: #000088;">$myLastKey</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$contents</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$newContents</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$contents</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$fp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;w&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #339933;">,</span><span style="color: #000088;">$newContents</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #990000;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/usr/sbin/apache2 -t&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$output2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$retval2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$retval2</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>	<span style="color: #666666; font-style: italic;">// 0 == Syntax OK; 1 = Syntax Wrong</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;touch /tmp/.reapache&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;OK&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Syntax Error&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Here, if user is supplied &#8216;create&#8217; as command line argument, we are create a new virtual host and saving it in a file which is stored in Apache directory and read by Apache. This file (/etc/httpd/conf.d/user-sites) is readable by PHP. We are removing the subdomain if user supply &#8216;remove&#8217; as command line option. After this we are checking the Apache syntax and if its OK then we are creating/touching a simple file in tmp directory. Why? Its because PHP can not reload Apache (as initial apache process is started by root and we can&#8217;t let php to reload/restart it), so what we are doing here is that a cron is running every minute in Server and check existing of this file (/tmp/.reapache), if its exist then reload Apache else do nothing. So every minute settings get applied. Of course, this will add a delay of maximum 1 minute for you to create or remove subdomains but initially I guess its acceptable. </p>
<p>You also needs to make sure to create directory (which hold subdomains files) etc. before executing script or update this script itself to create required directories/files for you.</p>
<p>You can see that this is pretty simple script and needs a lots of enhancements before deploying it in production environment but still its giving an idea as how can we achieve that functionality. </p>
<p>As an example, you can run this script like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ php subdmanager.php <span style="color: #660033;">--create</span> mynewsubdomain
&nbsp;
or 
&nbsp;
$ php subdmanager.php <span style="color: #660033;">--remove</span> myoldsubdomain</pre></div></div>

<p>or call this script from your website php files using syntax mentioned above.</p>
<p>Here&#8217;s the contents of simple cron file (bash script) which you can set to run every minute which will reload Apache in case /tmp/.reapache is present:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-a</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>.reapache <span style="color: #7a0874; font-weight: bold;">&#93;</span>; 
<span style="color: #000000; font-weight: bold;">then</span> 
	<span style="color: #000000; font-weight: bold;">`/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 reload<span style="color: #000000; font-weight: bold;">`</span>; 
	<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>.reapache<span style="color: #000000; font-weight: bold;">`</span>;
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>Hah, pretty simple, isn&#8217;t it? yah but don&#8217;t rush and put it in production. I guess it needs to be fine tuned/needs better exception handling etc. </p>
<p>So things from Server side is completed but what about DNS? To make new subdomian work, you need to update DNS as well, right? Let me cover up that part in next article which I will post here after 2-3 days as the process is still in testing phase.</p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/php-script-to-dynamically-create-remove-apache-virtual-hosts-subdomains/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Disable weak ssl ciphers in lighttpd in Linux</title>
		<link>http://linuxadminzone.com/disable-weak-ssl-ciphers-in-lighttpd-in-linux/</link>
		<comments>http://linuxadminzone.com/disable-weak-ssl-ciphers-in-lighttpd-in-linux/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 15:59:36 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[Web Server]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=309</guid>
		<description><![CDATA[To tighten security or again to pass PCI test, you can disable weak SSL cipher. Let&#8217;s do it in a host running lighttpd web server in CentOS Linux. Normally, you get message like this for this issue: Synopsis : The remote service supports the use of medium strength SSL ciphers. Description : The remote host [...]]]></description>
			<content:encoded><![CDATA[<p>To tighten security or again to pass PCI test, you can disable weak SSL cipher. Let&#8217;s do it in a host running lighttpd web server in CentOS Linux. </p>
<p>Normally, you get message like this for this issue:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Synopsis : The remote service supports the use of medium strength SSL ciphers. Description : The remote host supports the use of SSL ciphers that offer medium strength encryption, <span style="color: #c20cb9; font-weight: bold;">which</span> we currently regard <span style="color: #c20cb9; font-weight: bold;">as</span> those with key lengths at least <span style="color: #000000;">56</span> bits and <span style="color: #c20cb9; font-weight: bold;">less</span> than <span style="color: #000000;">112</span> bits.
&nbsp;
Note: This is considerably easier to exploit <span style="color: #000000; font-weight: bold;">if</span> the attacker is on the same physical network. Solution: Reconfigure the affected application <span style="color: #000000; font-weight: bold;">if</span> possible to avoid use of medium strength ciphers. Risk Factor: Medium <span style="color: #000000; font-weight: bold;">/</span> CVSS Base Score : <span style="color: #000000;">4.3</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>CVSS2<span style="color: #666666; font-style: italic;">#AV:N/AC:M/Au:N/C/I:N/A:N)</span></pre></div></div>

<p>Let&#8217;s disable these weak cipher&#8217;s now: </p>
<p>Update config file to add or modify following lines. After addition/editing, lines should look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>lighttpd<span style="color: #000000; font-weight: bold;">/</span>lighttpd.conf
ssl.use-sslv2 = <span style="color: #ff0000;">&quot;disable&quot;</span>
ssl.cipher-list = <span style="color: #ff0000;">&quot;TLSv1+HIGH !SSLv2 RC4+MEDIUM !aNULL !eNULL !3DES @STRENGTH&quot;</span></pre></div></div>

<p>make sure that you have to put these lines in any blocks/vhosts etc. also because these are global options and if you not put these in vhosts blocks, then they will not be effective. </p>
<p>Time to verify things, you can check whether ssl2 is disabled first:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ openssl s_client <span style="color: #660033;">-connect</span> localhost:<span style="color: #000000;">443</span> <span style="color: #660033;">-ssl2</span></pre></div></div>

<p>you should get error while connecting. </p>
<p>Now check whether weak ciphers are disabled:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ openssl s_client <span style="color: #660033;">-connect</span> localhost:<span style="color: #000000;">443</span> <span style="color: #660033;">-cipher</span> EXP:LOW</pre></div></div>

<p>here as well, you should get error while connecting. </p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/disable-weak-ssl-ciphers-in-lighttpd-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

