Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Sunday, September 21, 2008

Installing Ruby on Rails on Ubuntu 8.04

I've been exploring web app frameworks lately in hopes of starting work on a new site. I first looked at some PHP implementations, namely CodeIgniter and CakePHP. I mostly looked at those thanks to all the cheap and easy hosting available for PHP. I also thought some about a Java framework like Spring or Struts but I mostly write Java these days so I wanted to branch out. What I finally decided on was Ruby on Rails. I have dabbled with Rails a little in the past and have started working on a few real projects recently that are also using Rails so I will be learning it anyway.

So far all my development in Rails has been on Windows. Rails is rather Mac centric and I am a little unsure of the Linux support. I know that the one other project I am working on is deployed on Ubuntu 8.04 server so surely I can develop on it too.

First thing is first. Install ruby:

$ sudo apt-get install ruby
And then ruby doc:
$ sudo apt-get install rdoc
(If you don't install ruby doc, you are going to get an error later when installing ruby gems.)

Now you could at this point install rails and ruby gems using apt-get or synaptic but you don't want to. Rails is currently at version 2.1.1 and ruby gems is version 1.2.0 but the Ubuntu repositories only have versions 2.0.2 and 1.1.1 respectively. If Ubuntu backports had newer versions we would be set but I don't see rails in the mix. Having a package manager built into the OS is not something that Windows and Mac have available to them natively so ruby has gems as a package manager. Unfortunately this can conflict with the OS package manager so that is why we aren't going to install ruby gems or rails with apt-get.

So now you want to download ruby gems here. Extract it (anywhere), fire up a terminal, change to the directory you just extracted and run:
$ sudo ruby setup.rb
If you happen to get the error message: ./lib/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- rdoc/rdoc (LoadError) then you skipped over my point to install ruby doc above. Go back and install that and you will be caught up again.

After a minute or so you will have ruby gems installed. To install rails run:
$ sudo /usr/bin/gem1.8 install rails
After a few minutes more, you are ready to start developing with rails. You may also want to consider using Eclipse and Aptana.


Also, if after this when trying to fire up WEBrick you get the error: /usr/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/initializer.rb:229:in `require_frameworks': no such file to load -- openssl (RuntimeError) You will need to install libopenssl-ruby:
$ sudo apt-get install libopenssl-ruby
You may need to install mysql too even if you are only accessing a remote database so keep that in mind too.

Wednesday, February 20, 2008

The program 'XYZ' is currently not installed. You can install it by typing:

I am not sure who to thank but a big thanks to who or whatever implemented the code to tell me when something I want to run is not installed and how to install it!

I am working on a website for my uncle and I needed to get a development environment up and running. It is going to be a simple and mostly brochureware site so I just wanted PHP and Apache. I went to check to see what version of php was installed and got this:

The program 'php' is currently not installed. You can install it by typing:
sudo apt-get install php5-cli


Now that is some user friendliness. I had already installed some of the PHP packages from Synaptic (since they were not listed under Add/Remove Programs) but apparently I missed some things.

Now we shall see how well Smarty works. I've not worked with PHP in a long time and the last time I did I had my own hacked template code. Good times.