# Help needed setting up Ruby / Octopress



## Anoniem (Apr 20, 2013)

Hi guys,

Recently made the best choice of my life; switching from Ubuntu to FreeBSD. I'm having several Wordpress websites (+- 5) for personal use and intend to use another blogging platform: Octopress. I need some help setting Octopress up on my FreeBSD 9.1 server install. Anyone familiar with that? For me the whole portmanagement / portsystem is quite new and I think I forgot just some basic things. So don't laugh! 

Installed:


```
/usr/ports/editors/vim-lite/ && make install clean
/usr/ports/ports-mgmt/portmaster && make install clean
/usr/ports/devel/git & make install clean
pkg_add -r ruby
```
Then:


```
vim /usr/ports/Mk/bsd.ruby.mk changed 1.8 to 1.9
portmaster converters/ruby-iconv
portmaster /usr/ports/sysutils/rubygem-bundler
rehash

git clone git://github.com/imathis/octopress.git /usr/local/www/apache2/data/octopress
cd /usr/local/www/apache2/data/octopress
ruby --version
```
Showing 1.9.3 -> seems ok


```
gem install bundler
rehash
bundle install
rake install
```
-> seems ok

So went to Apache22 and defined:

(for example)


```
<VirtualHost *:80>
ServerAdmin [email]webmaster@dummy-host.example.com[/email]
DocumentRoot "/usr/local/www/apache22/data/octopress"
ServerName [url]http://www.website.nl[/url]

ServerAlias website.nl
<Directory /usr/local/www/apache22/data/octopress/>
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
</VirtualHost>
```
And restarted Apache.

Guess I just need some things to set up Ruby correctly? For any information about Octopress -> http://octopress.org/

Already asked the people behind it and looked all over the internet and found some Chinese website but guess it's not the only Ruby / Jekkyll platform on BSD. 

Help is much appreciated :e


----------



## ShelLuser (Apr 21, 2013)

Before continuing I'd like to point out that I'm still fairly new to FreeBSD myself. Not so much Unix-like environments in general, but even so.



			
				Anoniem said:
			
		

> For me the whole portmanagement / portsystem is quite new and I think I forgot just some basic things. So don't laugh!
> 
> Installed:
> 
> ...


Now, this doesn't make much sense to me. You compile trivial programs, but you when it comes to your whole hosting environment you resort to pre-compiled binaries? That makes me wonder how you installed Apache?

Best approach here would have been to compile both www/apache22 or www/apache24, then continue to set up lang/ruby19.

Considering how you're planning to use Ruby within Apache; it would make more sense in order to make sure those are kept "in sync" so to speak.



			
				Anoniem said:
			
		

> Then:
> 
> 
> ```
> ...


_*Whoah* there_!

You say that you're unfamiliar with the ports system yet still went on to change system files? That totally doesn't add up for me and frankly I think you're in for quite a bit of pain there since this can and will cause for major inconsistency in your system. Maybe not today but this is bound to happen in the near future.

Thing is; in order to maintain a sane system you'll need to update your ports from time to time. And ports is under version control using subversion. You can use portsnap for regular maintenance. Yet this also means that as soon as a change to bsd.ruby.mk is made you're pretty much screwed because then things _are_ going to break.

The right approach would have been to specify the Ruby version while building a port. That is what RUBY_VER is for. Or if you setup your own Ruby environment you could use RUBY to point the port to the full path of it.

For example something like: `make RUBY_VER=1.9 build`.



			
				Anoniem said:
			
		

> Guess I just need some things to set up Ruby correctly? For any information about Octopress -> http://octopress.org/
> 
> Already asked the people behind it and looked all over the internet and found some Chinese website but guess it's not the only Ruby / Jekkyll platform on BSD.


Setting up Ruby on FreeBSD is pretty easy, all you need is `make quicksearch name=ruby | less` from the /usr/ports directory and you'll soon come across stuff as lang/ruby18, lang/ruby19 and lang/ruby20. That is what you should use, especially in combination with www/apache22.

Can't comment on Octopress since I'm a Wordpress user myself. You also don't give us much to go on here; for example sharing what exactly went wrong.


----------



## Anoniem (Apr 21, 2013)

ShelLuser thanks! 

You have some good points here. The good thing is I build my server with Apache, MySQL and PHP from here: http://www.iceflatline.com/2011/11/how-to-install-apache-mysql-php-and-phpmyadmin-on-freebsd/ so I guess I've done the correct way?

Anyway; there was some Chinese site telling me I had to do it like this (with the precompiled one) so that was kind of stupid to listen to. How/what can I do best now? How can I easy deinstall this? Have run pkg_info and even saw 2 version installed, did: 
`# pkg_delete ruby-1.8.7.371,1`
`# pkg_delete ruby-1.9.3.392,1`

But now it says that Ruby is dependable on several packages (for version 1.8.7 about 50 dependencies and 1.9.3 only 1). Thought it would be best to get rid of ALL these things to start over the correct way. Did a portaudit and several dependencies are vulnerable (which I installed through the precompiled binary for 1.8.7) like Ruby_on_rails/Ruby_gem etc. so thats the best?


----------



## ShelLuser (Apr 21, 2013)

Anoniem said:
			
		

> You have some good points here. The good thing is I build my server with Apache, MySQL and PHP from here: http://www.iceflatline.com/2011/11/how-to-install-apache-mysql-php-and-phpmyadmin-on-freebsd/ so I guess I've done the correct way?


Absolutely, that's looking good so far.



			
				Anoniem said:
			
		

> Anyway; there was some Chinese site telling me I had to do it like this (with the precompiled one) so that was kind of stupid to listen to. How/what can I do best now?


Yeah, let's blame the Chinese, they're spamming most of our servers anway 

Ok, the first thing I'd recommend you do is to install Subversion and use it to fix the inconsistency in your Ports collection, like so:

`/usr/ports # cd devel/subversion`
`/usr/ports/devel/subversion # make install clean`


And when that finishes do this:

`/usr/ports # svn revert Mk/*`

So just to avoid any confusion here: from within the /usr/ports directory you go to /usr/ports/devel/subversion, install the program, and then back to /usr/ports to perform the command I listed directly above.

This will take care of your modifications in /usr/ports/Mk; like the name suggests it will revert all your modifications back to the way it was.

So now it seems you have two versions of Ruby installed, that is indeed one of the problems you can get when resorting to pre-compiled binaries since you have no control over their dependencies. With compiling Ports yourself this changes since you'll be able to point whatever you're setting up to use the right versions.

Anyway, the next thing I suggest you do is to compile Ruby. My personal pick would be 1.8 but of course you're free to pick whatever you want. Then simply build it. It is possible that this will also take care of the dependency of those other software packages, but without knowing what those were there is of course no way for me to tell if this is so.



			
				Anoniem said:
			
		

> But now it says that Ruby is dependable on several packages (for version 1.8.7 about 50 dependencies and 1.9.3 only 1). Thought it would be best to get rid of ALL these things to start over the correct way.


Well, this a bit of the beauty of FreeBSD and the Ports collection. In my opinion of course, but these dependencies aren't carved out in stone. There is a very realistic chance that as soon as you setup lang/ruby18 this will also satisfy the dependency of other packages.

After that I assume that you could use portmaster to check the dependency of lang/ruby18 or some of the other "top level" ports to check for unsatisfied dependencies. However, that is an assumption on my part right now since I'm still quite inexperienced with portmaster myself at the time of writing.

Finally, hate to be 'that' guy but even so I do suggest taking another look at the FreeBSD handbook on how to use the Ports collection. It will definitely help you avoid some of the nastiness you experienced above.

Hope this can help.


----------



## Anoniem (Apr 21, 2013)

Thanks ShelLuser, I'm going to try the things above - and read a little bit more about it before giving a reply about above. After that I'm going to try what did not work - maybe it will make a little bit more sense about my possible issue is (because I haven't mentioned yet WHAT is going wrong ).


----------



## Anoniem (Apr 28, 2013)

Back on track now - deinstalled all the OLD packages, cleaned up everything and reinstalled everything like it should. Googled a lot and it seems to be not that hard but I'm  missing something. Looks like Apache doesn't handle Ruby. I've got a test domain from someone: getsafe.nl, when having configured everything I will just see the root of my Octopress install. Do I need to set up anything else? Help is much appreciated - again I already asked the developers of Octopress but they're not familiar with FreeBSD. There are plenty of tutorials to get it working on a (local) MacOSX installation.


----------



## wblock@ (May 27, 2013)

What does "doesn't handle Ruby" mean?  Almost certainly you need to configure Apache.


----------



## Anoniem (May 28, 2013)

That's what my problem kind of is, nothing handles Ruby on Apache so I need to config AND have more modules I suppose.
But I don't know what to use, do I need a rails + passenger combination to have my Octopress (Jekyll/Ruby site) running? 
Or something with FastCGI? Or any other things? First time working with Ruby on FreeBSD, had it working on MacOSX before.


----------



## kpa (May 29, 2013)

You'll have to install www/rubygem-passenger with the Apache module enabled. Be aware that the Passenger module for Apache is tricky to get working on FreeBSD because it makes assumptions about the environment used, mainly it assumes that there is a /bin/bash shell as any Linux distribution would have. I had to do `ln -s /usr/local/bin/bash /bin/bash` on my system to get the Passenger module for Apache working.

See the instructions at http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_a_rack_based_ruby_application_including_rails_gt_3.


----------



## Anoniem (May 29, 2013)

Thanks, I will try to do this and will let you know whether it works- or not.


----------



## kpa (May 29, 2013)

Please don't PM me, I don't work here. (I think someone else used that phrase too  ) Could you post the details of the problem on this thread so others who might be able to help can have their input as well, thank you.


----------



## Anoniem (May 30, 2013)

The PM wasn't meant to be something as for a contributor from FreeBSD forum, just wanted to send it because it was a large list of (installed) ports/packages which wanted to show.

Anyway, I installed the apache module but can't get it working.

```
root@BOX1:/root # which ruby
/usr/local/bin/ruby
```

And put this in httpd.conf:

```
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9/gems/passenger-3.0.19
PassengerRuby /usr/local/bin/ruby19
```

So hereby the list of installed packages:

http://pastebin.com/p01ctjkK

Any forgotten things? 

My virtual host:


```
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/usr/local/www/apache22/data/Octopress/"
    ServerName http://www.xxxxx.nl
    ServerAlias xxxxx.nl
    RailsEnv "Octopress"
   <Directory /usr/local/www/apache22/data/Octopress/>
   AllowOverride All
   Order Deny,Allow
   Allow from all
   </Directory>
</VirtualHost>
```


----------



## kpa (May 30, 2013)

The reason I wanted you to post the details here is that I'm too in the process of learning Ruby On Rails and the related stuff, I don't know everything about it. There might be others on this forum who have more experience with Ruby On Rails and can offer their help.

First of all, check the /var/log/http-errors.log log for errors related to Passenger.


----------



## Anoniem (May 30, 2013)

Ah, sorry. Thanks for replying anyway! 
There's nothing specific in the Error log.


----------

