<?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>Rob Spencer</title>
	<atom:link href="http://robspencer.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://robspencer.net</link>
	<description>Programming and Web Development</description>
	<lastBuildDate>Thu, 06 Aug 2009 02:05:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>One Wordpress Installation For All Of Your Domains</title>
		<link>http://robspencer.net/one-wordpress-installation-for-all-of-your-domains/</link>
		<comments>http://robspencer.net/one-wordpress-installation-for-all-of-your-domains/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 02:01:58 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
		
		<guid isPermaLink="false">http://robspencer.net/?p=38</guid>
		<description><![CDATA[If you have a lot of wordpress sites like myself, you are probably annoyed with having to update each and every install on all of your domains. Not to mention that having so many installs takes up a lot of unnecessary hard drive space with all of the duplicate files for wordpress and all of [...]]]></description>
			<content:encoded><![CDATA[<p>If you have a lot of wordpress sites like myself, you are probably annoyed with having to update each and every install on all of your domains. Not to mention that having so many installs takes up a lot of unnecessary hard drive space with all of the duplicate files for wordpress and all of the plugins we seem to use on every blog install. Wouldn&#8217;t it be nice to just upgrade wordpress and your plugins one time and have it reflect on all your domains? Well you may be surprised by how easy this actually is to accomplish. <span id="more-38"></span></p>
<p>For this to work, you will need to have a <a href="http://robspencer.net/recommends/servint/" target="_blank" rel="nofollow">VPS</a> or <a href="http://robspencer.net/recommends/the-planet/" target="_blank" rel="nofollow">dedicated server</a>. This won&#8217;t work on a shared hosting account as you will need to modify your httpd.conf</p>
<p>The first thing we will need to do is edit our wp-config.php file. We will put all of the domains that will be pointed to this installation in an array. We then check which domain the user is visiting and change our table prefix to reflect this. Add the following code to the top of your wp-config.php file.</p>
<pre name="code" class="php">
&lt;?php
$domains = array(
    'website1.com' => 'wp1_',
    'website2.com' => 'wp2_',
    'website3.com' => 'wp3_'
    //Add more as necessary
);
$domain = $_SERVER['HTTP_HOST'];
if(array_key_exists($domain, $domains))
    $prefix = $domains[$domain];
else
    die('Blog Doesn\'t Exist');
</pre>
<p>Then you want to find the line <code>$table_prefix = 'wp_';</code> and change it to <code>$table_prefix = $prefix;</code>. This will allow any domain pointing to this wordpress installation to use a different table prefix for each domain. </p>
<p>If you prefer to setup separate databases for each domain then instead of using a table prefix as the array values, you could use the database name. That would look something like this:</p>
<pre name="code" class="php">
&lt;?php
$domains = array(
    'website1.com' => 'dbname1',
    'website2.com' => 'dbname2',
    'website3.com' => 'dbname3'
    //Add more as necessary
);
$domain = $_SERVER['HTTP_HOST'];
if(array_key_exists($domain, $domains))
    $dbname = $domains[$domain];
else
    die('Blog Doesn\'t Exist');
</pre>
<p>Then instead of changing <code>$table_prefix = 'wp_';</code>, you would leave that as is and change the line <code>define('DB_NAME', 'yourdbname');</code> to <code>define('DB_NAME', $dbname);</code> and this will use completely separate databases for each domain. However, the problem with this is that you would have to create each database separately. If you do it this way then be sure to use the same user and password for each database to keep it simple.</p>
<p>The next step for this to work is to modify your httpd.conf. There are 2 ways you can do this. The longer and more complicated way is to create a virtual host for each domain and point each of them to your single wordpress installation. So if you have your wordpress files in /home/wordpress/ then you would create your virtal hosts like the following.</p>
<pre name="code" class="c">
&lt;VirtualHost 123.45.67.89:80&gt;
    ServerName website1.com
    ServerAlias www.website1.com
    DocumentRoot /home/wordpress
&lt;/VirtualHost&gt;
</pre>
<p>You would then repeat this for each domain.</p>
<p>The easier and more preferred way is to simply point your server&#8217;s ip addresses to the wordpress installation. This way you can simply use your domain registrar&#8217;s DNS Servers and point the A records to your server. You would then set up your httpd.conf virtual hosts as follows.</p>
<pre name="code" class="c">
&lt;VirtualHost 123.45.67.89:80&gt;
    DocumentRoot /home/wordpress
    &lt;Directory "/home/wordpress"&gt;
        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
    &lt;/Directory&gt;
&lt;/VirtualHost&gt;
</pre>
<p>Add this to the beginning of your virtual hosts section in the httpd.conf file, usually located in <code>/usr/local/apache/conf/</code> on most server configurations. If you are using more than 1 ip address on your server then add an additional virtual host entry for each ip address. If you have other domains on your server with a proper virtual host entry then those domains will still work and point to the correct location. All domains that don&#8217;t have a specific virtual host will be pointed to your wordpress installation.</p>
<p>That&#8217;s about all there is to it. Just restart apache (<code>/etc/init.d/httpd restart</code>) and you should be good to go. You can now point your A records at your domain registrar to one of your server&#8217;s ip addresses and when you visit the domain for the first time you will be asked to install wordpress.</p>
<p>PS &#8211; As with everything I post on this site, I take no responsibility if you screw up your server. Use this at your own risk and if you don&#8217;t know what your doing then don&#8217;t do it. If you are uncomfortable doing this yourself and you would like me to do it for you then contact me and I can do it for a respectable fee.</p>
]]></content:encoded>
			<wfw:commentRss>http://robspencer.net/one-wordpress-installation-for-all-of-your-domains/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Auto Update Wordpress Without FTP</title>
		<link>http://robspencer.net/auto-update-wordpress-without-ftp/</link>
		<comments>http://robspencer.net/auto-update-wordpress-without-ftp/#comments</comments>
		<pubDate>Mon, 18 May 2009 18:13:16 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
		
		<guid isPermaLink="false">http://robspencer.net/?p=15</guid>
		<description><![CDATA[
When using the auto update feature to update wordpress to the newest version or to update your plugins, some users wonder why they need to enter ftp details when others don&#8217;t. Or maybe you have to enter the ftp information for your wordpress install on one server but not another. Not only do you have [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://robspencer.net/wp-content/uploads/2009/05/connecinfo-300x176.jpg" alt="Wordpress Automatic Upgrade Asking for FTP Information" title="Wordpress Automatic Upgrade Asking for FTP Information" alt="Wordpress Automatic Upgrade Asking for FTP Information" width="300" height="176" class="alignnone size-medium wp-image-19" /></p>
<p>When using the auto update feature to update wordpress to the newest version or to update your plugins, some users wonder why they need to enter ftp details when others don&#8217;t. Or maybe you have to enter the ftp information for your wordpress install on one server but not another. Not only do you have to enter your ftp details to use the automatic upgrade feature, you also have to chmod your wp-content folder to 0777 or 0775 rather than the default 0755 just so you can use the image uploader. If you have root access to your server, I will show you how to fix that.</p>
<p><span id="more-15"></span></p>
<p>First you want to login to your server as the root user with whatever SSH client you prefer. I use the free and open source <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">Putty</a>.</p>
<p>We need to see what user apache is running as. We can do this by simply typing the &#8216;top&#8217; command checking our httpd processes.</p>
<p><code>root@host # top</code></p>
<p><img src="http://robspencer.net/wp-content/uploads/2009/05/httpduser-500x82.jpg" alt="Check which user is running apache" title="Check which user is running apache" width="500" height="82" class="size-large wp-image-20" /></p>
<p>As you can see in the above picture, httpd is running as the user &#8216;nobody.&#8217; Your user may be different depending on your server configuration. Some common ones are nobody, www, or www-data. Just make sure its not root. Generally you will have one httpd process running as root so it can bind to port 80, then a few sub processes running as a different user. When in doubt, you can also find the user in the httpd.conf.</p>
<p>Now that we have our apache user, let see what user owns our website files. You can do this with <code>root@host # ls -l /home</code>.</p>
<p><img src="http://robspencer.net/wp-content/uploads/2009/05/siteuser-500x18.jpg" alt="Check which user owns our website files." title="Check which user owns our website files." width="500" height="18" class="alignnone size-medium wp-image-21" /></p>
<p>From the image above, we can see that the fakeuser/ folder belongs to the user &#8216;fakeuser&#8217; and the group &#8216;fakeuser.&#8217; All we need to do here is <code>chown</code> our folder to change the user to the same one as the webserver.</p>
<p><code>root@host # chown -R nobody /home/fakeuser</code></p>
<p>Now if you <code>ls -l /home</code> again, you will see that the fakeuser folder is now owned by &#8216;nobody&#8217; as well as all files and folders within it (by using -R for recursive). Now go into your wp-admin and try to use the automatic upgrade again. It will now jump straight into the upgrade without asking for your ftp details. You also wont have to edit permissions when using the image uploader.</p>
<p>Disclaimer: Although this eases your use of wordpress, you may have to change settings for other things such as awstats or cpanel, among other things. All server configurations are different. Use this at your own risk and don&#8217;t blame me if you mess something up.</p>
]]></content:encoded>
			<wfw:commentRss>http://robspencer.net/auto-update-wordpress-without-ftp/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Quick and Easy Way to Keep Bots Off Your Forms</title>
		<link>http://robspencer.net/quick-and-easy-way-to-keep-bots-off-your-forms/</link>
		<comments>http://robspencer.net/quick-and-easy-way-to-keep-bots-off-your-forms/#comments</comments>
		<pubDate>Sat, 02 May 2009 05:31:23 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
		
		<guid isPermaLink="false">http://robspencer.net/?p=7</guid>
		<description><![CDATA[A lot of people ask me how to keep bots from spamming their contact forms. Here is a simple way to do it without implementing a captcha code or other complicated security measures.
Most bots will fill in form fields they recognize with the data they are spamming. When they come across an unknown field, they [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of people ask me how to keep bots from spamming their contact forms. Here is a simple way to do it without implementing a captcha code or other complicated security measures.</p>
<p>Most bots will fill in form fields they recognize with the data they are spamming. When they come across an unknown field, they will usually fill it in with a random string just so the form is submitted without error. This is where we can take advantage. <span id="more-7"></span></p>
<p>Create an input field in your form.</p>
<p><code>&lt;input type="text" name="botcatcher" id="botcatcher" /&gt;</code></p>
<p>Then in your css you wanna hide this field.</p>
<p><code>#botcatcher { display:none; }</code></p>
<p>When the form is submitted, you want to check if this field has a value. If it does, discard the form as it&#8217;s usually a bot. I just send them to the thanks page so it appears to be successful. If it doesn&#8217;t have a value then its usually a real user.</p>
<pre name="code" class="php">
&lt;?php
if(empty($_POST['botcatcher'])) {
    //Valid user, Process the form
} else {
    //Invalid user. Discard the form
}
?&gt;
</pre>
<p>I have been using this little technique on my forms for a few years now and it has drastically cut down on spam bots. Try it out and let me know what you think.</p>
]]></content:encoded>
			<wfw:commentRss>http://robspencer.net/quick-and-easy-way-to-keep-bots-off-your-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It has begun!</title>
		<link>http://robspencer.net/it-has-begun/</link>
		<comments>http://robspencer.net/it-has-begun/#comments</comments>
		<pubDate>Fri, 01 May 2009 23:01:26 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
		
		<guid isPermaLink="false">http://robspencer.net/?p=1</guid>
		<description><![CDATA[Welcome to RobSpencer.net. If you cannot tell from the domain name or the large title above, my name is Rob Spencer.
This is a site I been planning to build for the past few years and finally getting around to it. I plan to talk about the things I do in my everyday work as a [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to RobSpencer.net. If you cannot tell from the domain name or the large title above, my name is Rob Spencer.</p>
<p>This is a site I been planning to build for the past few years and finally getting around to it. I plan to talk about the things I do in my everyday work as a webmaster and web programmer. I will be providing tutorials, code snippets, maybe some free wordpress plugins, some blackhat and whitehat SEO, general rants and bitches, or whatever else I feel like talking about. Some topics may be advanced concepts while others will be noob stuff.</p>
<p>I am usually pretty busy with my programming and site development and I don&#8217;t really enjoy writing, so don&#8217;t expect daily updates. If I start a multi part tutorial and say the next part will be available tomorrow, it probably won&#8217;t be available until next week. If you like what I write about, feel free to stick around, post some comments with your opinions or experiences, subscribe to my rss feeds, or whatever else floats your boat. If you don&#8217;t like it, just click that little back arrow button at the top of your browser. I can&#8217;t please everyone.</p>
<p>In all actuality, I will try to provide something useful for everyone. I hope you enjoy it and decide to stick around.</p>
]]></content:encoded>
			<wfw:commentRss>http://robspencer.net/it-has-begun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
