Archive for the ‘FreeBSD’ Category.

See my article on Mono in the BSD Magazine May issue

The BSD Magazine has released and there is an article in it by yours truly.

Check it out.

May issue of BSD magazine- Embedded BSD: FreeBSD and Alix

10 Step process for developing a new WPF application the right way using C#

It makes a difference if you do something the right way from the beginning.  Everything seems to work out so much better and takes less time over all.

Here are some basic steps that I have learned will help you do it right the first time. These steps are from my experience, mostly because I did it wrong the first few times.  These are not exact steps. They are subject to change and improve.  In fact, you might have improvements to suggest immediately when you read this. But if you are new to WPF, then reading these steps before you start and following them, will have you closer it doing it the right way the first time.  It is much more pleasant to tweak a pretty good process than it is to go in with no idea for a process and do it wrong.

Step 1 – Prepare the idea

  1. Some one has an idea
  2. Determine the minimal features for release 1.
  3. Determine the minimal features for release 2.
    1. Alter minimal features for release 1 if it makes sense to do so.
  4. Determine the minimal features for release 3.
    1. Alter minimal features for release 1 and 2 if it makes sense to do so.

Step 2 – Design the Application’s back end business logic (simultaneous to Step 3)

  1. Design the backend
  2. Apply the “Keep it simple” idea to the business logic and makes changes as necessary.
  3. Apply the “Keep it secure” idea to the business logic and makes changes as necessary.
  4. Repeats steps 2 and 3 if necessary.
  5. Backend development can start now as the UI and the back end should not need to know about each other, though this coding is listed as the Step 5 item.

Step 3 – Design the UI using WPF (simultaneous to Step 2)

  1. Determine what development model should be used to separate the UI from the business logic.
    1. Model-View-ViewModel (MVVM) is the model I recommend for WPF.
    2. Gather libraries used for the model (such as common MVVM libraries that include the common ViewModelBase and RelayCommand objects)
  2. Consider using a 3rd party WPF control set will be used.  Many 3rd party companies provide WPF controls that are better and easier to use than those included by default.
    1. If you decided to use 3rd party controls, purchase or otherwise obtain the libraries for these 3rd party controls.
  3. Consider designing two WPF interfaces or skins (I will call these Views from here on out) for each screen. This will help drive the separation of the back end code from the WPF code. Also if developing two Views is not simple, it indicates a poor design.
  4. Design the interface(s) (you may be doing two Views) using SketchFlow (take time to include the libraries for the 3rd party WPF Controls in your SketchFlow project and design with them)
    1. SketchFlow allows you to design the UI, which is commonly done in paint, but instead does this in XAML, and is actually the WPF code your application will use.
  5. SketchFlow allows you to deliver the design (or both Views if you did two) as a package to the customer.
    1. Deliver it immediately and get feedback.
    2. Make changes suggested by the customer if in scope.
  6. Take time to make the XAML in SketchFlow production ready.
  7. Deliver the XAML to the customer again, to buy of that the design changes are proper.
    1. Make changes suggested by the customer if in scope.

Step 4 – Determine the delivery or install method

  1. Determine the delivery method.
  2. Determine when to develop the delivery method.
    1. The easier the application is, the longer you can wait to determine the installer or delivery method.
    2. The more complex the install or delivery method, the sooner this should be started.

Step 5 – Develop the business logic

  1. Develop the application designed in step 2.
  2. Get the application working without UI or silently. Note: Start the next step, Develop the UI, as soon as enough code is available here.

Step 6 – Add Bindings to the UI

  1. Start the UI project by copying the XAML from the SketchFlow document to your Visual Studio or Expression Blend project.
  2. Determine a method for setting the DataContext without linking the View to any ViewModel or Model dlls.
  3. Create a project for the ViewModel code and develop it to interact with the business logic using Binding.
  4. Remember to develop two Views for every UI screen as this will help, though not guarantee, that the the MVVM model was correctly used.

Step 7 – Develop the View Model

  1. You should now have a backend code and a View, and now you start creating the View Model.
  2. This should be in a separate dll than the View or ViewModel.
  3. The ViewModel should never link to the View but can link to Model and Business libraries, though you may consider interface-based design and only link to an interface library.
  4. Make sure to use the properties that the View is binding to.

Step 8 – Consider a other platforms


Macintosh owns a significant market share.  Determine if this application needs to run on Macintosh as well. Sure, since we are running C# your options are limited to either rewriting in objective C and Coca, or using Mono with a MonoMac UI.  I recommend the latter.

Note: It is critical that the UI and business logic are separated to really make this successful.

  1. Completely ignore the WPF design and have Macintosh users users assist the design team in designing the new UI.  Macintosh’s have a different feel, and trying to convert the same UI is a mistake.
  2. Create the MonoMac UI project.
  3. Create a project similar to the ViewModel project in Windows, to link the UI to the business logic.


BLU (BSD/Linux/Unix) doesn’t exactly own a significant market share. However, it is still important to determine if this application needs to run on on BLU as well. Sure, since we are running C# your options are limited to either rewriting in C++, or using Mono with a GTK# or Forms UI.

  1. Completely ignore the WPF and Macintosh designs and have Linux users assist the design team in designing the new UI. Linux have a different feel, and trying to convert the same UI is a mistake.
  2. Create the GTK# project.
  3. Create a project similar to the ViewModel project in Windows, to link the UI to the business logic.
  4. GTK# doesn’t support binding, but still keep the UI separate from the business logic as much as possible.
  5. Also, don’t develop for a single open source flavor, but use standard code that compiles and any BSD/Linux/Unix platform.

Mobile Platforms

  1. Do you need to have this app on IOS or Android or Windows Phone?
  2. Completely ignore the WPF and Macintosh and Linux designs and have Android or IOS users assist the design team in designing the new UI. Mobile platforms have a different feel, and trying to convert the same UI is impossible as the screens are much smaller.

Step 9 – Develop the delivery method

Again, you may need to do this way sooner if the application is complex.

  1. Develop the install or delivery method.
  2. If you decided to deploy to Macintosh or BLU you may have to develop separate install or delivery methods for those platforms as well.
  3. Remember to have a plan and a test for your first patch even if you have to mock a sample patch before you release.
  4. Remember to have a plan and a test for upgrading your application even if you have to mock a sample upgrade version before you release.

Step 10 – Deliver the finished Products

  1. Once finished, deliver this product.
  2. If you decided to create a Macintosh or BLU version, deliver them when ready as well.  It is OK and maybe preferred to deliver these at different times.

I was the 200th person to like the FreeBSD Foundation Facebook page

I was the 200th person to like the FreeBSD Foundation Facebook page.

The FreeBSD Foundation helps collect donations and fund projects to improve FreeBSD.

If you have the ability to contribute, you should. I realized I hadn’t contributed since last year, so I went ahead and donate a meager sum this year.

The FreeBSD needs a lot more than 200 people liking it and a lot more people donating.

Updating the PC-BSD Ports Jail network settings when the system runs dhclient

I have been running the PB-BSD 8.2 and switching between work and home networks.

I have figured out that I have to run these commands when I want to switch over to use wireless:

sudo wpa_cli reassociate
sudo route flush
dhclient wlan0

When switching back to Ethernet, I have use these two commands:

sudo route flush
sudo dhclient em0

I thought I was done listing the commands that must be run, until I realized that the above commands didn’t change the /etc/resolv.conf in my Ports Jail.

Question: What network settings need updating in the Ports Jail.
Answer: The Ports Jail uses the systems IP Address and Default Route, so only the /etc/resolv.conf needs updated and it appears to be a copy of the system’s /etc/resolv.conf

So I just have to update /etc/resolv.conf and that is all.


Well, one solution is to run another command that just copies the system’s /etc/resolv.conf to the Port Jail.

# cp /etc/resolv.conf /usr/jails/portjail/etc/resolv.conf

But a better solution is to get dhclient to run this command for us. This can be done with the dhclient-exit-hooks.

Step 1 – Create the dhclient-exit-hooks file and make it executable

sudo touch /etc/dhclient-exit-hooks
chmod +x /etc/dhclient-exit-hooks

Step 2 – Enter the function into the /etc/dhclient-exit-hooks to run copy command when dhclient exists

cp /etc/resolv.conf /usr/jails/portjail/etc/resolv.conf

Now when you run dhclient, you will also get a new /etc/resolv.conf in your Ports Jail.

How I’ve been using the PC-BSD Ports Jail

So, when you install using ports, there is a lot of software you may not really want that gets installed. Are you familiar with the term build dependency.  This is software, usually a library or scripting language, that is required for a software to compile from source, but is not needed at run time.  When you always install from ports, your system will eventually have most or all the common build dependencies installed.  Really the only dependencies you need are run-time dependencies.  These dependencies make up the software that must be installed for the desired port to actually function.

Here is what I do:

  1. Install ports both in the jail and on my system pretty much at the same time with the same command, just in the different consoles.
    # portsnap fetch update
  2. Compile the port in the jail.  This will build and install everything in the jail, including the build dependencies and run time dependencies and of course the port itself.
    # cd /usr/ports/<group>/<port>
    # make install
  3. Sync the system’s ports tree with the jail’s ports tree using rsync.
    # rsync -av /usr/jails/portjail/usr/ports/ /usr/ports
  4. Install the port in the regular system.  This only installs the run time dependencies and the port itself.
    # cd /usr/ports/<group>/<port>
    # make reinstall

This seems to work, and I don’t get all the build dependencies installed. Plus the rsync command is pretty quick.

I wonder if this is how the PC-BSD team uses it too?


Installing the latest version of Mono on FreeBSD or How to install and use portshaker?

Mono is basically the .NET Framework on FreeBSD or other open source platforms. This allows development in C# on FreeBSD.  C# is an extremely popular language that is not slowing down.  It’s popularity stems from that fact that this language and its features allows for rapid development that is much faster than many other languages.

The version of Mono available in the ports tree is not the latest version available. Just like FreeBSD has a release version and a development version, Mono has a release version and a development version.  The development version is so much newer that it is hard not to recommend it over the release version.

Step 1 – Install the latest ports

This is already documented here:

How to install ports on FreeBSD?

Step 2 – Install portshaker and portshaker-config

The team at BSD# have a tool called portshaker that adds mono ports to the ports tree.  Install it as follows.

cd /usr/ports/ports-mgmt/portshaker-config
make BATCH=yes install

Note: Notice I didn’t just install portshaker, I installed portshaker-config which has portshaker as a dependency, so you get both installed with one command.

Step 3 – Configure portshaker

The example portshaker.conf.example is configured correctly for default configurations, so all we need to do is copy it.

# cp /usr/local/etc/portshaker.conf.example /usr/local/etc/portshaker.conf

Step 4 – Run portshaker

Yes, it is that easy.  Simply run portshaker.

# portshaker

Note: You may be prompted to merge a few files. I diffed and chose either install or continue each time.

Note: Running portshaker uses subversion to download so if you need to use an HTTP proxy, you have to configure subversion to use an HTTP proxy as it doesn’t use the FreeBSD HTTP_PROXY environment variable.

Your ports tree is now updated by portshaker.

Step 5 – Install mono

The mono port should now be updated to the latest version.

cd /usr/ports/lang/mono
make BATCH=yes install

Mono is now installed on your system.

There is an example of building a hello world app here:

C# (Mono) on FreeBSD

Getting Java to work in Firefox 3.6 in FreeBSD or PC-BSD 8.2

Firefox 3.6 no longer works with the Java versions in PBIs. Instead the OpenJDK6 must be installed. However, as of writing this document there is not a PBI for OpenJDK6, so we must install it from the ports jail.

  1. Install ports on your system as follows: How to install ports on FreeBSD?
  2. Open the command prompt.
  3. su to root.
    $ su
  4. As root, get the latest ports.# portsnap fetch extract
  5. Install openjdk6.Note: There is an openjdk7 but it didn’t appear to have a web option yet, so hold off until it has one, use openjdk6.
    cd /usr/ports/java/openjdk6
    make WITH_WEB=yes BATCH=yes install
  6. Run this link command to link the library for the java plugin to your plugins directory.
    # ln -s /usr/local/openjdk6/jre/lib/ ~/.mozilla/plugins/

Testing the Java plugin

You may want to verify that java is working in your Firefox install. You want to know two things:

  1. Is the plugin detected by Firefox?
  2. Does a java application work?
      1. Open Firefox. If Firefox is open already, close it, and re-open it.
      2. In the URL enter: about:pluginsYou should now see the IcedTea-Web Plugin (using IcedTea-Web 1.0.1).
      3. In Firefox, go to the following URL: 
    1. Here are steps to make those two verifications. 

      Note; This is pretty much exactly like the handbook states.

Opening konsole and a Ports Jail konsole can be confusing on PC-BSD

If I open Ports Jail, then a regular konsole, the regular konsole gets the Ports Jail icon.  I can’t really tell the konsole sessions apart.

The same things happens if I do it the other way around.  If I open a regular konsole, then Ports Jail, the Ports Jail gets the konsole icon. Again, I can’t really tell the konsole sessions apart.

This causes me some confusion.  Which konsole am I running?  I have to take a moment to verify or close them both.

Solution: Opening the Ports Jail with a different konsole profile

One solution is to have the Ports Jail konsole session use its own konsole profile that uses a custom konsole profile.

Here is how I configured that:

  1. I created a LavenderOnBlack color scheme, which is a copy of the GreenOnBlack with Lavender instead of Green. Normally I use the GreenOnBlack color scheme.~/kde4/share/apps/konsole/LavenderOnBlack.colorscheme
  2. Next I created a copy of the shell.profile named PortsJail.profile.

    [Cursor Options]
    RemoteTabTitleFormat=%h : %u
    [Terminal Features]
  3. I then edited the Ports Jail shortcut on the desktop to pass it the approprate TerminalOptions to use the PortsJail.profile. Here is the one line I changed.
    TerminalOptions=--profile /usr/home/jared/.kde4/share/apps/konsole/PortsJail.profile

Now whenever I open the ports Jail, I can easily tell it is the Ports Jail and not the regular konsole because it is using a LavenderOnBlack profile.

What is the FreeBSD plan?

I don’t know what the FreeBSD plan is. Unfortunately, I feel that if there is one, it is not a very well-rounded on. Maybe it only focuses on development and might not have a big focus on also important tasks like advertising and marketing, documentation, and acquiring new committers.  All of which is important because I am not the only that thinks that FreeBSD needs fresh Blood!

Here is a simple step by step plan to make the FreeBSD community bigger. They aren’t all my ideas, many have been mentioned by other people in the forums or elsewhere.

Advertising and Marketing Department

  1. Get one. Get an advertising team, however you have to do it.
    1. Maybe the FreeBSD foundation hire a part time advertising professional (or maybe iXSystems could let one of theirs donate some time) who gets as much help as possible from college students majoring in Advertising and Marketing as unpaid internships.
  2. Give them goals to 1) get more committers, 2) get more users, 3) Get more Enterprise and Small business exposure and usage.
  3. Get a list of companies that use FreeBSD and don’t ask them for donations, ask them to buy feature enhancements. They are more likely to pay more for an enhancement than they are willing to donate.
  4. Get a list of all BSD user’s group email. Start using them and encouraging them to hold meetings, improve the user’s groups, etc…
  5. Get a list of all college’s and their Computer Science staff members and make it standard practice that CS degrees can get internship credit for working on FreeBSD. Same for English Technical writing and FreeBSD Documentation, same for advertising and marketing and FreeBSD advocacy and marketing.

Documentation Department

  1. Make documentation contributions easy.
    1. Make the FreeBSD documentation pages wiki editable. Anyone can edit the page, like Wikipedia. Yes, it would be fine if a page could have an person or team who has to approve the change, because we have to let the localization teams know that a change was submitted.
    2. Make the man pages available as a wiki, and the man page updates are included in the next release.
  2. Make these training videos:
    1. Getting started with FreeBSD – Install and Usage.
    2. Getting started with FreeBSD – Documentation
    3. Getting Started with FreeBSD – User land development and debugging
    4. Getting Started with FreeBSD – Kernel Development and debugging
    5. Getting Started with FreeBSD – Contributing to the KDE on FreeBSD project.
    6. Getting Started with FreeBSD – Contributing to the FreeBSD GNOME project.
    7. Getting Started with FreeBSD – Remote debugging
    8. …continue as needed
  3. Get a community site up. Not just a forum site, but a community site.
    1. Write a link between IRC and the community site so a persons IRC posts are also on the community.
    2. Write a link between the mailing lists and the community so emails are on the community.
    3. Provide FreeBSD User’s groups free sites and mailing lists but encourage them to get $10 a month in contributions each year to sustain it.
  4. Support the Advertising and Marketing team.
  5. Implement Kanban as a process for managing your work.

Development Department

  1. Join the desktop world in a big way. FreeBSD is not just a server. It must have a solid desktop distribution. PC-BSD exists (though the name is not marketing friendly). Get a marketing friendly OS Name, and a marketing friendly logo, and create a desktop distro that has a chance at attracting new users. Let the Advertising an Marketing team determine the name and brand of the new desktop. (I don’t care if the distro is PC-BSD as long as it is re-branded.)
  2. Build a graphical newbie proof installer that can install the server or desktop. (I know, many of us have come to love the simplicity of sysinstall, but I still remember my first year with FreeBSD when I hated it.)
  3. Include Mono in the install of all desktop versions of FreeBSD. Lets face it, C# developers are everywhere and if the user land were C#, it would be much easier to get dev work done.
  4. Support the Advertising and Marketing teams by sponsoring internships, maybe at your Alma mater.
  5. Create a ready-to-dev on Virtual Machine.
  6. Support the documentation team by making docs “Getting Started” easier.
  7. Make the FreeBSD build easy to replicate in a graphical IDE. The new generation has few individuals who want to learn vi and gdb or otherwise work from the command line. They want to build and debug elsewhere.
    1. Get the FreeBSD projects building with a Graphical IDE. Lets leave the ability to build with make but add an a project file. I don’t care what graphical IDE is chosen, Eclipse, KDevelop, Code::Blocks, MonoDevelop, etc…Just pick one and make it happen.
    2. Have a master project file at the root of the build that will do everything, build the entire FreeBSD source, in debug or release.
  8. Update the ready-to-dev on Virtual Machine to be include the graphical IDE and be ready to build and debug.
  9. Maybe there is a reason to make a few different types of ready-to-dev virtual machines.
  10. Implement Kanban as a process for managing your work, I recommend a web site version for open source communities. Each committer can have a view of their work just for them.

Well, that is the plan that has formed in the back of my head the past ten years that I have been involved with FreeBSD. Unfortunately, most of the above is not happening. PC-BSD is helping with #1 and #2 of the development plan, which is great!

Click to read more ideas for improving FreeBSD.

Dual-booting Windows 7 and PC-BSD

Hey all,

I was going to write an article on this, but it was so easy, there is no need for one.

Windows 7 doesn’t know how to deal with PC-BSD, but PC-BSD knows how to deal with Windows 7.

So all I had to do was install Windows 7 first (I chose a 50 GB partition) and then I installed PC-BSD on the remaining space. I did click to install the PC-BSD boot manager as it is not selected by default, and now I can dual boot Windows 7 and PC-BSD.  Which is a must for a guy who’s job is writing C# on windows.

Project ideas for FreeBSD

There is a lot of work to do in this world, and there are plenty of open source projects. However, there are still plenty of projects that need help. There are still plenty of projects that haven’t even been started yet.

I just read this post and I am quite in agreement with it: FreeBSD needs fresh Blood!

Here are a list of projects ideas or projects that need contributors that could really help FreeBSD go to the next level.

Possible new projects

  • FreeBSD Mentoring Project – The primary goal is to get FreeBSD developers developing immediately and maybe have a VirtualBox VM that is ready to download and dev on immediately.
  • A Windows driver for FreeBSD’s UFS, maybe using the Installable File Systems (IFS) Kit
  • A Windows driver for ZFS, maybe using the Installable File Systems (IFS) Kit.
  • A GNOME based FreeBSD Desktop distribution (Note: PC-BSD and/or GhostBSD might fill these need in the future.)
  • Contributors to DesktopBSD.
  • A FreeBSD phone operating system to compete with Android, Windows Phone 7, etc… I think a clever name for phone OS based on FreeBSD would be Angel.
  • A new desktop that isn’t GNOME or KDE but is written using Mono (C#).
  • VirtualBox BootCamp for FreeBSD – Ability to boot to a VirtualBox image, similar to BootCamp on a MAC. So you can boot to a different OS, or while running FreeBSD you can load the OS as a virtual machine.

Projects that could use more Contributors

  • FreeBSD Advocacy and FreeBSD Marketing – We need actual advertising and marketing people here, not coders or techies.
  • FreeBSD ACPI – I would recommend a focus on improving ACPI support for laptops running FreeBSD.  The Sleep and hibernate ability are important.
  • Mono on FreeBSD or BSD#
  • Ports on FreeBSD – There are a lot of unmaintained ports, such as K-3d and you could adopt a port.
  • KDE on FreeBSD – The KDE support is in need of help.  The network manager hasn’t worked in years.
  • GNOME on FreeBSD – There is not an installable FreeBSD desktop distribution that focuses on GNOME.  GhostBSD, a live-CD, is based on GNOME.
  • GhostBSD – They could use some help being not just a live-CD but an installable distribution.

Business ideas based on FreeBSD

While free contributions from the community is nice, for FreeBSD to really thrive, it needs more full-time developers. There is not substitute for actual paid employees who spend their days working on FreeBSD.  The only way get those type of employees is to get some companies out there making money. For this reason, I would recommend that the FreeBSD Foundation looks at helping start new businesses based on FreeBSD.

  • BSD Appliances – Maintain appliances, both hardware and virtual appliances, for all the common server types. This is a hardware and support model, the software is of course free.
    • A complete suite of BSD appliances from Web Servers to Firewalls, to NAS, to backup, to networking, etc…I own the URL and thought about starting this project, but never really had the bandwidth.
    • Also, outsource appliance maintenance so other companies can have their proprietary appliance maintained by this company.  I know my company, LANDesk, has considered outsourcing our Management Gateway appliance. I heard a rumor KACE was too, though that rumor remains unverified.
  • BSD Business – A software company that makes a server and applications for common businesses. This is a hardware and support model, the software is of course free.
    • A Business Server (three version Small Business, Medium Business, Enterprise) that has everything a business needs. (Maybe this server is an appliance maintained by BSD Appliances 🙂
    • Common businesses means businesses that exist in every city, law offices, dental offices, eye-doctors, chiropractors, restaurants, hotels, mechanics, gas stations, etc… There are some applications that are ubiquitous to their fields. To use an example local to me, think of what Dentrix is to the dental field. I have always thought of an ultra-secure desktop for lawyers running an very secure version of FreeBSD.
  • Point of Sale system based on FreeBSD. This is a hardware and support model, the software is of course free. Why let Red Hat and CentOS have this who market.
  • Gaming on FreeBSD – A gaming console based on FreeBSD to compete with XBox, Playstation, etc…Gaming has an amazing power to drive improvement.
  • A support center where companies can get enterprise FreeBSD support, development, etc…
  • Animation on FreeBSD – A film studio that makes animated movies and runs everything on FreeBSD.
  • Feature4Hire – A web site that maintains a list of enhancement requests and people or companies can submit how much they are willing to pay for the feature. Then as soon as the dollar amount is worth it to someone in the world, they develop the feature and get paid, with something like 3% going to Feature4Hire. Even if $10 is attributed to a feature, some one in a 3rd world country might find some small dollar amounts worth it.  Ok, this site might be for all open source projects, but it could run on FreeBSD.

There are a lot more ideas out there and anybody can be a part of them.

GhostBSD 2.0 Released!

I recently posted about the GhostBSD 2.0 beta.

Review: GhostBSD 2.0 Beta 2 – A FreeBSD LiveCD

Well, the product is no longer beta as they just released GhostBSD 2.0.

If you didn’t take a look when I posted about the beta, take a moment to take a look now!

New Laptop Hard Drive!

I just got a new 250 GB 7200 RPM laptop hard drive for $45 bucks from NewEgg.

I plan on installing Windows 7 SP1, FreeBSD 8.2, and PC-BSD 8.2.

You know what would be interesting is to link /usr/home on FreeBSD 8.2 and the PC-BSD 8.2 OSs so that my /usr/home/jared is the same directory on both.

Asp.Net web services on FreeBSD and Apache using Mono

Asp.Net is cross platform using mono. Novell SUSE and Microsoft and others companies are dedicated to making .NET Framework a cross platform solution. Asp.Net web services are limited to running on windows, but can also run on other platforms, such as FreeBSD.

FreeBSD has ports for mono and mod_mono and can easily run web services build with Asp.Net. Here is a tutorial to make this happen.

Preparing a FreeBSD system for Asp.Net on Apache using Mono


A good place to start reading is the getting started page on the mono project’s web site.:

This has the resources you need for most things, however, the documentation is designed mostly for SUSE Linux, so be prepared for slight differences on FreeBSD.

Step 1 – Install Apache

Install Apache on FreeBSD as follows.

  1. Change to the ports directory for Apache and run make install.
    cd /usr/ports/www/apache22
    make install
  2. Configure Apache to load on start up.
    # echo ‘apache22_enable=”YES”‘ >> /etc/rc.conf
  3. Leave Apache stopped. We will start it later.

Step 2 – Install mod_mono

Installing mod_mono will also install mono and xsp. Install mod_mono as follows.

  1. Change to the ports directory for Apache and run make install.
    cd /usr/ports/mod_mono
    make install
  2. Because on FreeBSD these packages work a little differently, you don’t need to do some of the steps listed on the mono website because they are done for you. Here are some key paths and differences in the packages on FreeBSD that you should know about.
    • The mod_mono port installs a mod_mono.conf file to /usr/local/etc/apache22/Includes which is automatically includes in the httpd.conf, so you don’t have to add an include manually.
    • The xsp port adds sample ASP.NET web services to /usr/local/lib/xsp.
    • The apache root directory is /usr/local/www/apache22/data
  3. Here are the contents of the mod_mono.conf file. Notice that this Apache include file loads a couple modules, adds a bunch of types, and adds a few files as DirectoryIndex options.
    # mod_mono.conf
    # Achtung! This file may be overwritten
    # Use 'include mod_mono.conf' from other configuration file
    # to load mod_mono module.
    <IfModule !mod_mono.c>
        LoadModule mono_module /usr/local/libexec/apache22/
    <IfModule mod_headers.c>
        Header set X-Powered-By "Mono"
    AddType application/x-asp-net .aspx
    AddType application/x-asp-net .asmx
    AddType application/x-asp-net .ashx
    AddType application/x-asp-net .asax
    AddType application/x-asp-net .ascx
    AddType application/x-asp-net .soap
    AddType application/x-asp-net .rem
    AddType application/x-asp-net .axd
    AddType application/x-asp-net .cs
    AddType application/x-asp-net .vb
    AddType application/x-asp-net .master
    AddType application/x-asp-net .sitemap
    AddType application/x-asp-net .resources
    AddType application/x-asp-net .skin
    AddType application/x-asp-net .browser
    AddType application/x-asp-net .webinfo
    AddType application/x-asp-net .resx
    AddType application/x-asp-net .licx
    AddType application/x-asp-net .csproj
    AddType application/x-asp-net .vbproj
    AddType application/x-asp-net .config
    AddType application/x-asp-net .Config
    AddType application/x-asp-net .dll
    DirectoryIndex index.aspx
    DirectoryIndex Default.aspx
    DirectoryIndex default.aspx

Step 3 – Add the “test” web service to the Apache root directory

In /usr/local/lib/xsp, added by the mod_mono port, is a “test” folder that contains sample web services. Ther

  1. Copy /usr/local/lib/xsp/test to /usr/local/www/apache22/data.
    # cp -fR /usr/local/lib/xsp/test /usr/local/www/apache22/data/

Step 4 – Start Apache

  1. Start Apache with this command:
    # service apache22 start

You should now have Apache configured to run

Step 5 – Open the “test” folder in a browser

  1. Open your favorite browser on a workstation that has access to the server you just finished installing.
  2. Go to the URL of your server. For example, the url for my test server is this:
  3. Browse around and test the web services.

Step 6 – Install Libraries as needed

    1. Determine if you need additional libraries.

With the bare minimum installed, you can almost guarantee that a web service is going to require a library you do not have installed. In fact, clicking on the second link in the “test” site, code-render.aspx, shows us this error.

Server Error in '/test' Application


Description: HTTP 500. Error processing request.

Stack Trace:

System.DllNotFoundException: gdiplus.dll
  at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
  at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0

Version information: Mono Runtime Version: 2.6.7 (tarball Tue Mar 1 06:10:28 MST 2011); ASP.NET Version: 2.0.50727.1433

This library can be found and installed.

  1. Go to the directory for the port and run make install.
    cd /usr/ports/x11-toolkits/libgdiplus
    make BATCH=yes install

    This has some Xorg dependencies so compiling it could take a while. Notice the BATCH=yes parameter passed to make above. This will prevent any prompts and accept the defaults for every port this command compiles.

Released: FreeBSD 8.2-RELEASE and 7.4-RELEASE