<?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; FreeBSD</title>
	<atom:link href="http://dragffy.com/blog/posts/tag/freebsd/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>Sun, 29 Apr 2012 11:55:12 +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>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>

