<?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>command line idiot &#187; apache</title>
	<atom:link href="http://www.commandlineidiot.com/blog/category/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.commandlineidiot.com/blog</link>
	<description>one man's dawning realization that linux is waaaaay smarter than he is</description>
	<lastBuildDate>Mon, 05 Oct 2009 15:10:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Plate Up! Bash Script for Apache VHost Setup</title>
		<link>http://www.commandlineidiot.com/blog/2007/plate-up-bash-script-for-apache-vhost-setup/</link>
		<comments>http://www.commandlineidiot.com/blog/2007/plate-up-bash-script-for-apache-vhost-setup/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 00:17:41 +0000</pubDate>
		<dc:creator>command line idiot</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://www.commandlineidiot.com/blog/2007/plate-up-bash-script-for-apache-vhost-setup/</guid>
		<description><![CDATA[In the sisyphian marathon of blowing up and rebuilding my server, I&#8217;ve had to go through the process of reconfiguring my virtual hosts for Apache2 several times. Well, that gets a bit tedious. How can my hands do the very important jobs of holding a beer up to my lips whilst scratching my man candy [...]]]></description>
			<content:encoded><![CDATA[<p>In the sisyphian marathon of blowing up and rebuilding my server, I&#8217;ve had to go through the process of reconfiguring my virtual hosts for Apache2 several times. Well, that gets a bit tedious. How can my hands do the very important jobs of holding a beer up to my lips whilst scratching my man candy if they have to keep typing &#8220;sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/newdomain.com&#8221; over and over again?</p>
<h3>bash it!</h3>
<p>Fear not, my young linux adventurers. There IS a better way! Pop that cold beer, pull up some sweats, and feast your eyes on my hand dandy little bash script for automatically setting up yon website. Here&#8217;s what it does, in a nutshell:</p>
<ol>
<li>Asks for the new domain name</li>
<li>Creates a new folder in the user folder with the domain name (/home/user/DOMAIN.COM)</li>
<li>Creates a basic index.html file in the new domain folder that displays the name of the domain when accessed.</li>
<li>Rolls 2d6 for Hacker Shield, to prevent magic-based attacks against your website. (planned for version 0.2)</li>
<li>Generates a vanilla Apache vhost config file spelling out how Apache should handle requests for that domain.</li>
<li>Generates an access log and an error log</li>
<li>Generates a cgi-bin folder within the DOMAIN.COM folder</li>
</ol>
<p>The script assumes you have Apache 2.2+ installed.</p>
<h3>The non-compliance disclosure</h3>
<p>Keep in mind that this script was written by me, for me, to help save me some effort. Because of that, it uses some non-standard locations for things. Why? Because I likes my shit where I likes my shit, that&#8217;s why!</p>
<p>I like having my apache vhost config files in my user folder, so that I don&#8217;t have to hassle with permissions. You can do the same thing with these two commands. First, make yourself a few new directories:</p>
<p><code>mkdir -p ~/www-config/sites-available</code><br />
Then, link the apache site config folder to your new folder. Make sure this all goes on one line:</p>
<p><code>sudo ln -s /home/USERNAME/www-config/sites-available /etc/apache2/sites-available/</code></p>
<p>So where are things placed with this script?</p>
<p>config:<br />
/home/USERNAME/www-config/sites-available/DOMAIN.COM</p>
<p>website documents:<br />
/home/USERNAME/DOMAINNAME.COM</p>
<p>index page:<br />
/home/USERNAME/DOMAIN.COM/index.html</p>
<p>access log:<br />
/home/USERNAME/logs/DOMAINNAME.COM/access.log</p>
<p>error log:<br />
/home/USERNAME/logs/DOMAINNAME.COM/error.log</p>
<p>cgi-bin:<br />
/home/USERNAME/DOMAIN.COM/cgi-bin</p>
<h3>The Script</h3>
<p>Here &#8217;tis. Click here to view or download a .txt file with the script.</p>
<p><a href="http://commandlineidiot.com/scripts/siteup.txt">http://commandlineidiot.com/scripts/siteup.txt</a></p>
<p>To use it, do the following:</p>
<p><code>mkdir ~/bin<br />
cd ~/bin<br />
wget http://commandlineidiot.com/scripts/siteup.txt<br />
mv siteup.txt siteup<br />
chmod 755 siteup<br />
</code></p>
<p>Now, to invoke the script, type the following:<br />
<code>. ~/bin/siteup</code></p>
<p>If you want to find out more about bash scripts, including how to handle permissions and setting paths so that your scripts can be called by name, I highly recommend the following tutorial by William Shotts Jr. at LinuxCommands.org: <a href="http://linuxcommand.org/writing_shell_scripts.php" title="LinuxCommand.org: Writing shell scripts.">Writing Shell Scripts</a></p>
<p>Questions? Comments? Feck Off! I&#8217;m too busy drinking this cold beer and fiddling my diddly.</p>
<img src="http://www.commandlineidiot.com/blog/?ak_action=api_record_view&id=18&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.commandlineidiot.com/blog/2007/plate-up-bash-script-for-apache-vhost-setup/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
