Showing posts with label Octopress. Show all posts
Showing posts with label Octopress. Show all posts

Wednesday, January 7, 2015

How to Install Octopress on Ubuntu Linux 12.10 (Quantal Quetzal)

So, you’ve discovered Octopress and want to set it up, welcome to the club! Octopress is an awesome system, I love it.
Today’s tutorial is going to show you how to set it up in Ubuntu Linux. The idea being if you’re using Ubuntu for development you can build and generate your pages on your dev machine, and push them to your site. Let’s get started.
I’m using Ubuntu 12.10 Quantal Quetzal in this demo, but it should be relatively the same for most Ubuntu versions.

Step 1: Install Some Dependencies

First you need to install Git, and rbenv. You should already have Ruby installed but if not it will come up as a dependency.
1
$ sudo apt-get install build-essential git rbenv
Rbenv is a program that allows you to switch between versions. Start it up by typing:
1
$ rbenv init
If you want it to start automatically, add this line to your ~/.bashrc file
1
eval "$(rbenv init -)"
Now you can install Ruby:
1
2
3
$ rbenv install 1.9.3-p194
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
You may also need to install Ruby Build (different from Ruby Builder) to get this working:
1
2
3
4
5
$ mkdir -p ~/.rbenv/plugins
$ cd ~/.rbenv/plugins
$ git clone git://github.com/sstephenson/ruby-build.git
$ cd /ruby-build
$ ./install.sh

Step 2: Get Octopress

Now that you have your dependencies installed, you will want to clone Octopress into a folder.
1
2
3
$ mkdir octopress
$ git clone git://github.com/imathis/octopress.git octopress
$ cd octopress
This gives you a fresh version of Octopress right from Github.

Step 3: Install Octopress

Now that your depencies are met and you’re ready to go, you install it just as it shows on the Octopress site:
1
2
3
4
$ cd ~/octopress
$ sudo gem install bundler
$ rbenv rehash    # If you use rbenv, rehash to be able to run the bundle command
$ bundle install
Build a test post, just to be sure there are no errors:
1
2
$ rake new_post["hello world!"]
$ rake generate
And that’s it! Getting up and running in Ubuntu Linux is pretty simple if you follow the steps exactly. I will also be posting a tutorial on here for installing in Windows, including Windows 8, very soon.
Enjoy it, and if you have any questions leave them in the comments!

How to Install Octopress in Windows

Do you want to install Octopress on Windows? I tried it recently and found it to be a bit of a pain , but I documented it and decided to publish it. Funny thing, I write about a lot of Windows/.Net stuff on here, but I write all these articles on a Linux box. It’s certainly more convenient to do it that way, but if you really must run it in Windows, here’s your guide.

Why am I writing this?

I Googled this issue and found some instructions, but they aren’t complete. There are things missing even from the Octopress site so I decided to create a barebones Windows 7 virtual machine and install Octopress as if I weren’t a developer who already had all this stuff installed. I consider this to be a complete installation guide because it shows ALL the steps needed.

Getting Started

You should be fairly familiar with the command prompt, you’re going to need it. To find it, click on the Start button, and in the search box type “cmd” and the console will come up. You’ll also need to use Windows PowerShell as well, I’ll show you how to get to it when we need it.

Install Git

You will need Git to download some of the stuff you’ll need, so go here:
Install it with the default features.

Install Yari

Yari is a great tool for managing your Ruby environment and is reccommended for using Octopress in Windows. Run the following commands in your command prompt window:
cd %USERPROFILE%
git clone git://github.com/scottmuc/yari.git .yari
This will download Yari into your user profile. Now we need to set the path.
WARNING - Do not set the path in the manner that’s described in the Yari instructions. This will overwrite your path, which is undesirable.

How to safely set up your path

Click on Start Button and then right click on Computer and select properties:
"How to install Octopress in Windows"
Click “Advanced system settings”
"How to install Octopress in Windows"
Click “Environment Variables”
"How to install Octopress in Windows"
In this window select the “Path” section and click on edit.
"How to install Octopress in Windows"
This will bring up a dialog with your current path. This is what we’ll change:
"How to install Octopress in Windows"
Warning do not erase this information! We want to add the following to the end of this path:
;%USERPROFILE%\.yari\bin;C:\Python27
The semicolon is not a typo, this separates the path from the previous one. If there is already a semicolon at the end that’s fine.
Click OK 3 times or until all the windows close.
Close your command prompt window and reopen it.

Install thru Windows PowerShell

There is another alternative and it doesn’t hurt to run this as well.
To open a PowerShell, click the Start button and select
Start -> All Programs -> Accessories -> Windows PowerShell (folder) -> Windows PowerShell
Copy the following text and paste it in:
(new-object Net.Webclient).DownloadString("https://github.com/scottmuc/yari/raw/master/installer.ps1") | iex
Now go back to your command prompt window (black background) and type in
yari 1.9.2 
The first time you run this it will take a while. This installs and sets up your Ruby environment.
You may see something like this:
"How to install Octopress in Windows"
This is because you need to install Ruby as an admin. To do that you’ll need to run PowerShell as Administrator. When selecting the PowerShell icon
Start -> All Programs -> Accessories -> Windows PowerShell (folder) -> Windows PowerShell
You need to right click the icon and select properties:
"How to install Octopress in Windows"
Select “run as Administrator” then run the following command
cd %USERPROFILE%
and then paste the following:
(new-object Net.Webclient).DownloadString("https://github.com/scottmuc/yari/raw/master/installer.ps1") | iex
Now, run Yari again:
yari 1.9.2 
This will successfully install it.
Now type in
ruby -v
and you should see something like this:
"How to install Octopress in Windows"
Now you have Ruby set up and the battle’s almost over!

Install Octopress

Now we will follow the same instructions as on the Octopress site to install it:
Go to the folder you want to install Octopress in and type the following:
git clone git://github.com/imathis/octopress.git octopress
after this downloads, run the following:
Gem install bundler
bundle install
Now it’s setup, and you have to install the default theme:
rake install
And it’s ready to go! but there a few more steps.

Install Python

Go to Python.org and get the version most appropriate for your machine. Install Python with the defaults and have it install to C:\Python27
Note that even though the 64 bit release says AMD 64 you can still install it with a 64 bit Intel chip as well.

Try it out

Now that you have everything set up, try it out. You want to edit the _config.yml file to adjust settings for your site.
Create a new post:
rake new_post["Hello World! I did it!"]
and then edit the resulting file that’s created in the _posts folder. Save it.
rake generate
Check your public folder and you should see new files there! You’re up and running!

Summary

I hope this has helped you install Octopress in Windows. As I said there are a few tutorials on the net for doing this, but they are incomplete or inaccurate. I hope this post is thorough enough that you get a good understanding of the process and get it set up.
I usually generate this site in Linux, because it’s easier, faster and my Linux machine is connected to automated backups. But you can use this in Windows if you choose and it works pretty well. If you have any questions or comments, leave them below!