<?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>dragffy.com &#187; Server</title>
	<atom:link href="http://dragffy.com/blog/posts/tag/server/feed" rel="self" type="application/rss+xml" />
	<link>http://dragffy.com/blog</link>
	<description>The development, documentation, and blogging domain of Gabriel Dragffy.</description>
	<lastBuildDate>Wed, 16 Nov 2011 11:17:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Apache 2 with SSL on FreeBSD 6</title>
		<link>http://dragffy.com/blog/posts/apache-2-with-ssl-on-freebsd-62</link>
		<comments>http://dragffy.com/blog/posts/apache-2-with-ssl-on-freebsd-62#comments</comments>
		<pubDate>Mon, 15 Oct 2007 15:30:37 +0000</pubDate>
		<dc:creator>Gabe</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[wiki]]></category>

		<guid isPermaLink="false">http://dragffy.com/blog/articles/apache-2-with-ssl-on-freebsd-62</guid>
		<description><![CDATA[It wasn&#8217;t exactly trivial installing and configuring Apache 2 on FreeBSD. Much of the configuration had to be done manually, which depending on your point-of-view is good or bad. This describes how I went about getting Apache 2 with SSL support up and running on FreeBSD 6. I did this on 6.2 but it should [...]]]></description>
			<content:encoded><![CDATA[<p>It wasn&#8217;t exactly trivial installing and configuring Apache 2 on FreeBSD. Much of the configuration had to be done manually, which depending on your point-of-view is good or bad. This describes how I went about getting Apache 2 with SSL support up and running on FreeBSD 6. I did this on 6.2 but it should equally apply to  6.x.<span id="more-3"></span></p>
<p>Note: These instructions use &#8220;www.example.com&#8221; as an example.</p>
<p>To Install Apache2:</p>
<p>After the UpdatePorts, install apache2 as follows:</p>
<p><code> cd /usr/ports/www/apache2 </code></p>
<pre>make install clean</pre>
<p>Enable Apache2 in <code>/etc/rc.conf</code> by adding the following&#8230;<br />
<code> </code></p>
<pre>apache2_enable="YES"

apache2ssl_enable="YES"</pre>
<p>Setup the certificates:</p>
<pre>mkdir /usr/local/etc/apache2/ssl.crt

mkdir /usr/local/etc/apache2/ssl.key</pre>
<p>Edit <code>/usr/local/etc/apache2/ssl.conf</code> and set the following&#8230;</p>
<pre>SSLCertificateFile /usr/local/etc/apache2/ssl.crt/server.crt

SSLCertificateKeyFile /usr/local/etc/apache2/ssl.key/server.key</pre>
<p>After saving the certificates in their appropriate directories run:</p>
<p><code>chmod -R 700 /usr/local/etc/apache2/ssl.key</code></p>
<p>Edit <code>/usr/local/etc/apache2/httpd.conf</code> and set the following:</p>
<pre>ServerAdmin mshurst@engmail.uwaterloo.ca
UseCanonicalName On
DocumentRoot "/homepages"
UserDir disabled
ServerSignature Off</pre>
<p>In <code>&lt;Directory "/homepages"&gt;</code> set&#8230;</p>
<pre>Options FollowSymlinks Multiview Includes ExecCGI

AllowOverride All</pre>
<p>Comment out the <code>&lt;Directory /home/*/public_html&gt;</code> section and replace it with&#8230;</p>
<pre>&lt;Directory /u1/*/public_html&gt;
   Options All -Indexes
   AllowOverride All
   Order allow,deny
   Allow from all
&lt;/Directory&gt;

&lt;Directory /u2/*/public_html&gt;
   Options All -Indexes
   AllowOverride All
   Order allow,deny
   Allow from all
&lt;/Directory&gt;

&lt;Directory /u3/*/public_html&gt;
   Options All -Indexes
   AllowOverride All
   Order allow,deny
   Allow from all
&lt;/Directory&gt;

&lt;Directory /u4/*/public_html&gt;
   Options All -Indexes
   AllowOverride All
   Order allow,deny
   Allow from all
&lt;/Directory&gt;</pre>
<p>Restart apache2 to start using the new certificate&#8230;</p>
<p><code><br />
/usr/local/etc/rc.d/apache2.sh stop<br />
/usr/local/etc/rc.d/apache2.sh start<br />
</code></p>
<p>To enable CGIWrap<br />
Allows execution of cgi scripts using user permissions</p>
<p>To install cgiwrap&#8230;</p>
<pre>cd /usr/ports/www/cgiwrap
make
make install</pre>
<p>Add AddHandler cgi-script .cgi to <code>/usr/local/etc/apache2/httpd.conf</code>.</p>
<p>Access control files are required for cgiwrap. To allow open access&#8230;</p>
<p><code>touch /usr/local/etc/cgiwrap.deny</code></p>
<p>To enable the &#8220;debug&#8221; version of cgiwrap&#8230;</p>
<p><code>chmod 4755 /usr/local/www/cgi-bin/cgiwrapd</code></p>
<p>In <code>&lt;Directory "/usr/local/www/cgi-bin"&gt;</code> set&#8230;</p>
<pre>  <code>Options ExecCGI</code></pre>
<p>To restrict &#8220;debug&#8221; access to on-campus only, add the following to httpd.conf&#8230;</p>
<p><code> &lt;Location /cgi-bin/cgiwrapd&gt; </code></p>
<pre>     order deny,allow
     deny from all
     allow from 129.97
&lt;/Location&gt;

&lt;Location /cgi-bin/nph-cgiwrapd&gt;
     order deny,allow
     deny from all
     allow from 129.97
&lt;/Location&gt;</pre>
<p>To enable Server Side Includes<br />
Allows server side parsing of html files.</p>
<p>Make the following changes in <code>/usr/local/etc/apache2/httpd.conf</code>&#8230;</p>
<p>uncomment (or add)</p>
<p><code>AddType text/html .shtml</code></p>
<p><code>AddHandler server-parsed .shtml</code></p>
<p>Allow <code>index.shtml</code> to be a default page</p>
<p><code>DirectoryIndex index.html ... index.shtml</code></p>
<p>Add the &#8220;Includes&#8221; option</p>
<p><code>Options Indexes FollowSymLinks MultiViews ExecCGI Includes</code></p>
<p><strong>Customized Virtual Host settings</strong></p>
<pre>   * Make the following changes to <code>/usr/local/etc/apache2/ssl.conf</code>...</pre>
<pre>#&lt;VirtualHost _default_:443&gt;

&lt;VirtualHost www.eng.uwaterloo.ca:443&gt;
DocumentRoot "/homepages"
ServerName www.eng.uwaterloo.ca

ServerAdmin mshurst@engmail.uwaterloo.ca</pre>
<pre>   * Configure logging to include the virtual host name by adding %v to the end of the LogFormat entry in httpd.conf</pre>
<p><code>LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-Agent}i\" %v" combined</code></p>
<pre>   * Add the following CustomLog entry to the www.example.com virtual host entry.</pre>
<p><code>CustomLog /var/log/httpd-sydewww.log combined</code></p>
<pre>   * Update the <code>rollapachelogs.csh</code> script to include the <code>httpd-sydewww.log</code> files.</pre>
<p>==<br />
Rolling the Apache logs ==<br />
The logs must be rolled occasionally to prevent the disk from filling with logs. This isn&#8217;t as trivial as it should be, because:</p>
<pre>   * If you roll the logs, and send a SIGTERM to httpd, all httpd processes will abort, possibly resulting in incomplete database updates etc

   * If you roll the logs, and send a SIGUSR1 to httpd, you must wait some unknown period of time to allow all child httpd processes to complete, before compressing logs.</pre>
<p>Alternatives:</p>
<pre>   * Don't compress the logs, and use newsyslog with signal 30 (USR1)

   * pipe the logs in httpd.conf through some other process

   * use a custom log roller script</pre>
<p>To do the latter, run:</p>
<p><code> fetch -o /usr/local/bin/rollapachelogs.csh <a href="http://www.freebsd.uwaterloo.ca/rollapachelogs.csh" class="external free" title="http://www.freebsd.uwaterloo.ca/rollapachelogs.csh" rel="nofollow">http://www.freebsd.uwaterloo.ca/rollapachelogs.csh</a></code></p>
<pre>chmod u+x /usr/local/bin/rollapachelogs.csh</pre>
<p>Add to <code>/etc/crontab</code>:<br />
<code> </code></p>
<pre># rotate apache logs

0       3       *       *       *       root    /usr/local/bin/rollapachelogs.csh</pre>
<p>Configuring Name-based virtual hosting</p>
<p>Set the folloowing in <code>/usr/local/etc/apache2/httpd.conf</code>&#8230;</p>
<p><code> NameVirtualHost *</code></p>
<pre># Default VirtualHost is listed here

# others are listed in /usr/local/etc/apache2/Includes/vhosts.conf

&lt;VirtualHost *&gt;
   ServerName www.eng.uwaterloo.ca
   ServerAlias www.eng
   DocumentRoot /homepages
   UserDir public_html
   ErrorDocument 403 /lookup.cgi
   ErrorDocument 404 /lookup.cgi
   ErrorDocument 410 /lookup.cgi
&lt;/VirtualHost&gt;</pre>
<p>Then add the other virtual hosts to <code>/usr/local/etc/apache2/Includes/vhosts.conf</code>&#8230;</p>
<pre>   ServerName www.engcomp.uwaterloo.ca
   ServerAlias www.engcomp www.engineeringcomputing.uwaterloo.ca www.engineeringcomputing
   DocumentRoot /u2/engcomp/public_html

   &lt;Directory /u2/engcomp/public_html&gt;      Options All
      AllowOverride All
      Order allow,deny
      Allow from all
   &lt;/Directory&gt;

   ScriptAlias /cgi-bin/ "/u2/eng_comp/public_html/cgi-bin/"
   &lt;Directory "/u2/eng_comp/public_html/cgi-bin/"&gt;
      AllowOverride None
      Options None
      Order allow,deny
      Allow from all
   &lt;/Direcotry&gt;</pre>
<p>Restrict access to printman pages</p>
<pre>&lt;Directory "/u2/eng_comp/public_html/printers"&gt;
   Order deny,allow
   Deny from all
   Allow from 129.97
&lt;/Directory&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://dragffy.com/blog/posts/apache-2-with-ssl-on-freebsd-62/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introduction to DNS</title>
		<link>http://dragffy.com/blog/posts/introduction-to-dns</link>
		<comments>http://dragffy.com/blog/posts/introduction-to-dns#comments</comments>
		<pubDate>Sun, 30 Sep 2007 16:07:35 +0000</pubDate>
		<dc:creator>Gabe</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[guide]]></category>

		<guid isPermaLink="false">http://dragffy.com/blog/posts/introduction-to-dns</guid>
		<description><![CDATA[If you are a beginner with DNS then you might find this quick article useful. Recently I have had to play with various DNS records to get mail servers and web servers working. Introduction to DNS DNS stands for Domain Name System. In simple terms it&#8217;s like this: people are good at remembering and writing [...]]]></description>
			<content:encoded><![CDATA[<p>If you are a beginner with DNS then you might find this quick article useful. Recently I have had to play with various DNS records to get mail servers and web servers working. <span id="more-10"></span></p>
<h4>Introduction to DNS</h4>
<p>DNS stands for Domain Name System. In simple terms it&#8217;s like this: people are good at remembering and writing names. Computers are great with numbers and calculations. When you open your browser you may type in an address such as <em>google.com</em> or <em>fartymarty.com</em>, but that is not what the computers use. They use numbers, each and every computer on the internet has a unique number assigned to it. This is called an IP address. This is where DNS comes in to play, it translates your names into numbers (computer addresses). For example if you go to <em>google.com</em> your browser will send a DNS query, the reply comes back has the numeric IP address of the google server, which in my case is 72.14.207.99. If you were to go to this IP or type in google.com you would get to the same place!</p>
<p>If you have your own domain name you may need to configure the DNS for it, so people typing in <em>yourdomain.com</em> are given back the correct IP address of your server &#8211; otherwise they won&#8217;t be able to find your site!</p>
<h4>&#8216;A&#8217; record</h4>
<p>Firstly we will concern ourselves with three DNS record types, the most commonly used ones. Perhaps the most useful is the A record. This is what will convert your domain <em>mydomain.com</em> in to a numbered address that computers use (IP address). Thus, if you have a web server (for example) listening at the address 12.34.56.78 and you want to be able to type in <em>mydomain.com</em> to your browser to visit it, you will need to create an A record. The cool thing is that mail servers will fall back to using it in the event you haven&#8217;t created an MX record&#8230; something that we are going to move on to.</p>
<h4>MX record</h4>
<p>MX record stands for &#8216;mail exchanger&#8217; and it is unique to email servers. If you have an email server at 12.34.56.78 and you want it to be able to receive emails that people address to you at <em>mydomain.com</em> you will want to create an MX DNS record. This record includes the hostname, the priority and the domain. Your first MX entry will probably want to have a priority of 0 or 10. The hostname for the mail server can be (for example) <em>mail.mydomain.com</em> and your domain can be <em>mydomain.com</em>. Whatever hostname you use for the mail server must also have an appropriate A record. So you might end up with something like this:</p>
<table>
<tr>
<th>NAME</th>
<th>TYPE</th>
<th>DATA</th>
</tr>
<tr>
<td>mydomain.com</td>
<td>A</td>
<td>12.34.56.78</td>
</tr>
<tr>
<td>mail.mydomain.com</td>
<td>A</td>
<td>12.34.56.78</td>
</tr>
<tr>
<td>mydomain.com</td>
<td>MX</td>
<td>10 mail.mydomain.com.</td>
</tr>
</table>
<p>Notice the &#8217;10&#8242; for the MX server, denoting priority. You can configure backup mail servers in case the primary one fails. You would create another MX record for the same name, with a higher priority (20 for example) and the address of another server. So ultimately you could have:</p>
<table>
<tr>
<th>NAME</th>
<th>TYPE</th>
<th>DATA</th>
</tr>
<tr>
<td>mydomain.com</td>
<td>A</td>
<td>11.11.11.11</td>
</tr>
<tr>
<td>mail.mydomain.com</td>
<td>A</td>
<td>11.11.11.11</td>
</tr>
<tr>
<td>mail2.mydomain.com</td>
<td>A</td>
<td>22.22.22.22</td>
</tr>
<tr>
<td>mydomain.com</td>
<td>MX</td>
<td>10 mail.mydomain.com.</td>
</tr>
<tr>
<td>mydomain.com</td>
<td>MX</td>
<td>20 mail2.mydomain.com.</td>
</tr>
</table>
<h4>CNAME record</h4>
<p>That leaves CNAME records. These are easy and are basically aliases. They come in useful when you want to create wildcards and subdomains. It is normally a good idea to create at least one CNAME for <em>www</em> so that if someone types in <em>www.mydomain.com</em> they will still get to <em>mydomain.com</em>:</p>
<table>
<tr>
<th>NAME</th>
<th>TYPE</th>
<th>DATA</th>
</tr>
<tr>
<td>www</td>
<td>CNAME</td>
<td>mydomain.com.</td>
</tr>
</table>
<p>And that&#8217;s it for the basics. Just be sure you use IP addresses for some things and hostnames for the others. &#8216;A&#8217; records always resolve to an IP address. MX and CNAME records resolve to a hostname. Hope that helps you.</p>
]]></content:encoded>
			<wfw:commentRss>http://dragffy.com/blog/posts/introduction-to-dns/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL 5 Server on FreeBSD</title>
		<link>http://dragffy.com/blog/posts/mysql-5-server-on-freebsd</link>
		<comments>http://dragffy.com/blog/posts/mysql-5-server-on-freebsd#comments</comments>
		<pubDate>Fri, 28 Sep 2007 15:35:29 +0000</pubDate>
		<dc:creator>Gabe</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[guide]]></category>

		<guid isPermaLink="false">http://dragffy.com/blog/articles/mysql-5-server-on-freebsd-6</guid>
		<description><![CDATA[MySQL is a very popular relational database. It can be used by many different applications and thankfully the installation procedure is a snap. For this tutorial we will be compiling MySQL 5.0.45 from ports with some custom options. I did this on FreeBSD 6.2 release but it should work on FreeBSD 6.3 and 6.x.Change to [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL is a very popular relational database. It can be used by many different applications and thankfully the installation procedure is a snap. For this tutorial we will be compiling MySQL 5.0.45 from ports with some custom options. I did this on FreeBSD 6.2 release but it should work on FreeBSD 6.3 and 6.x.<span id="more-6"></span>Change to the MySQL ports directory</p>
<pre><code>cd /usr/ports/databases/mysql50-server</code></pre>
<h4>Compile and install with custom options</h4>
<p>The following should be typed all on one line, the double backslash (\\) indicates that it has been broken up for better viewing on the internet.</p>
<pre><code>make WITH_CSV=yes WITH_FEDERATED=yes WITH_ARCHVIVE=yes \\
WITH_CHARSET=utf8 WITH_COLLATION=utf8__general_ci install clean</code></pre>
<p>This sets it up to use UTF8 as the default character sets and collations, of course you can change these. It also gives support to alternative database formats such as CSV, I don&#8217;t actually use them at the moment but thought I&#8217;d add them for good measure. For a production system it is good practice to install only what is absolutely necessary, so if you don&#8217;t need them for a production environment you might want to leave them out.</p>
<h4>Starting MySQL on boot</h4>
<p>To start the server you will need to make sure it is enabled in rc.conf, this will also make it start on boot-up:</p>
<pre><code>echo 'mysql_enable="YES"' &gt;&gt; /etc/rc.conf</code></pre>
<p>Now you will be able to start the server:</p>
<pre><code>/usr/local/etc/rc.d/mysql-server start</code></pre>
<h4>Securing MySQL</h4>
<p>By default MySQL is installed in an insecure way. The root user (different to the system root) can authenticate without a password. It is best to set a good password for the MySQL root user&#8230;</p>
<pre><code>mysql -u root -p</code></pre>
<p>It will now prompt you for the current password.  After you enter the current password, you will enter the mysql client where you should use something like the following query to change your password:</p>
<pre><code>SET PASSWORD FOR root = PASSWORD('secret');</code></pre>
<p>In this case root&#8217;s password is changed to the word &#8220;secret&#8221;.  There is only one problem with this.  It will only change root&#8217;s password for connections from wherever you are currently connected from, probably localhost.  mysql usually has another entry for root for myhost.www.example.org.  To change this you can use the following query:</p>
<pre><code>SET PASSWORD FOR root@"myhost.www.example.org" = PASSWORD('secret');</code></pre>
<p>Of course you could also use a different password if you would like, although I&#8217;m not sure what purpose this would serve.  If you want to try out this second password you can connect in the following way:</p>
<pre><code>mysql -h myhost.www.example.org -u root -p</code></pre>
<p>If you want to check for all root entries you can do the following:</p>
<pre><code>mysql -u root -p mysql</code></pre>
<p>Then enter the following query:</p>
<pre><code>SELECT Host, User, Password FROM user WHERE User = 'root';</code></pre>
<h4>MySQL Config File</h4>
<p>If you want to use a config file for MySQL you can copy either <code>my-small.cnf</code>, <code>my-medium.cnf</code>, <code>my-large.cnf</code>, or <code>my-huge.cnf</code> to <code>/etc</code>:</p>
<pre><code>cp /usr/local/share/mysql/my-small.cnf /etc/my.cnf</code></pre>
<p>Edit at will!</p>
]]></content:encoded>
			<wfw:commentRss>http://dragffy.com/blog/posts/mysql-5-server-on-freebsd/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

