wasil.org Abandon the search for Truth; settle for a good fantasy

15Jan/144

Sublime Text 3 perfect PHP development set-up

No Gravatar

This is follow-up arti­cle to Sub­lime Text 2 per­fect PHP devel­op­ment set-up. I decided to write this updated ver­sion, because from some time now Sub­lime Text 3 is out there. Maybe it is still offi­cially beta, but works pretty sta­ble and I’m using it for few months now.

This list is almost the same as in pre­vi­ous arti­cle — most of plu­g­ins I used with ST2 have been updated in order to work with ST3 and I stopped using few of them, so they are out. I’m kinda lazy, so some of descrip­tions are copy-pasted from pre­vi­ous article ;)

Any­way, here is the list:

  1. Pack­age Con­trol (https://sublime.wbond.net)
    Thanks to this lit­tle piece of soft­ware all other plu­g­ins are eas­ily installed.
  2. Sub­lime­CodeIn­tel (https://github.com/Kronuz/SublimeCodeIntel)
    This is pack­age I use all the time. Its job is to pro­vide hints related to func­tion, object, vari­able etc. names. It also hints what meth­ods and para­me­ters are avail­able in objects/classes. It’s based on Komodo CodeIn­tel and some­times it has some prob­lems work­ing at all. But most of the time it rocks :)
  3. Sub­limeLin­ter (https://github.com/SublimeLinter/SublimeLinter)
    This pack­age does full-time job for me — it con­stantly watches what I write and instantly lets me know if some­thing is not OK, for exam­ple I for­get semi-colon or brackets.
  4. Side­BarEn­hance­ments (https://sublime.wbond.net/packages/SideBarEnhancements)
    Pro­vides great new options when right-clicking on side­bar ele­ments (files/folders). Very convenient.
  5. VCS Gut­ter (https://sublime.wbond.net/packages/VCS%20Gutter)
    Lately I don’t imag­ine work­ing with­out this one. Every day I use Git and Mer­cu­r­ial and this plu­g­ins gives me real-time infor­ma­tion about what was changed (or added/removed) in cur­rent file using sym­bols in left-hand edit win­dow gutter.
  6. SFTP, paid (http://wbond.net/sublime_packages/sftp)
    Great pack­age enabling very com­fort­able use of SFTP, FTP and FTPS. It sup­ports remote fold­ers brows­ing, edit­ing and syn­chro­niza­tion between local and remote files. Also reg­u­lar upload, down­load pn save or file open.
  7. Tor­toise (on Win­dows only) (http://wbond.net/sublime_packages/tortoise)
    I use it as a com­ple­men­tary pack­age to Side­Bar­Git if I’m work­ing in Win­dows envi­ron­ment. It doesn’t have so many fea­tures but those what it pro­vide are very help­full and intuitive.If you like Tor­toise Git but you are work­ing on Linux you might want to check out Rab­bitVCS. It isn’t inte­grated with ST2, but it pro­vides com­fort­able right-mouse-click Git GUI.
  8. sublime-github (https://github.com/bgreenlee/sublime-github)
    Every devel­oper should use code snip­pets of some kind. I use Gist pro­vided by GitHub and this pack­age enables me to use them instantly (save/paste).
  9. Tag (https://github.com/SublimeText/Tag)
    It is fine plu­gin, but now ST3 sup­ports tag match­ing, so I don’t need it any more.
  10. Php­Doc (https://sublime.wbond.net/packages/PhpDoc)
    Great plu­gin aid­ing writ­ing doc­u­men­ta­tion docblocks for PHPDocumentor.
  11. Phpcs (http://soulbroken.co.uk/code/sublimephpcs)
    This pack­age adds sup­port for PHP_CodeSniffer to ST2. It checks if you code is writ­ten accord­ing to one of the stan­dards. Just pick one: Zend, PEAR.. and more :) Check out PHP_CodeSniffer web­site for con­fig­u­ra­tion details.
  12. Trail­ing­Spaces (https://github.com/SublimeText/TrailingSpaces)
    Small hor­ror of every code — empty spaces at lines ends, at the end of file. Espe­cially trou­ble­some if you are work­ing on the code with other devel­op­ers, who might use dif­fer­ent editors/IDEs which might inter­pret them (empty spaces) differently.
  13. Brack­etHigh­lighter (https://github.com/facelessuser/BracketHighlighter)
    Same sit­u­a­tion as with Tag plu­gin. In my every­day cod­ing ST3 bracket high­light­ing capa­bil­i­ties of ST3 are good enough. It is still great plu­gin though.
  14. Sub­lime Func­tion Name Dis­play (https://github.com/akrabat/SublimeFunctionNameDisplay)
    Dis­plays in bot­tom bar name of a func­tion (or method) in which our cur­sor is placed. Sim­ple and helpful.
  15. Ter­mi­nal (http://wbond.net/sublime_packages/terminal)
    Using Git or maybe some PEAR pack­ages you might need to switch to con­sole from time to time and do some magic. Maybe use Zend Tool or “bake” some­thing ;) It’s just what this plu­gin is for.
  16. Xde­bug Client (https://sublime.wbond.net/packages/Xdebug%20Client)
    Lately my favorite Xde­bug client for ST3. Works great and allows to use all of Xde­bug debug­ging capabilities.

Few sup­port­ing pack­ages. I con­sider them optional, but they come in handy:

  1. LineEnd­ings (https://sublime.wbond.net/packages/LineEndings)
    Nice to have plu­gin if you are work­ing with other devel­op­ers using Win­dows and Unix/Linux machines. It takes care of dif­fer­ent (invis­i­ble) line end­ing char­ac­ters in those systems.
  2. Sass (https://sublime.wbond.net/packages/Sass)
    This one comes in handy when work­ing with Sass files. Syn­tax high­light­ing and so on.
  3. Plain­Tasks (https://github.com/aziz/PlainTasks) added thanks to Virion’s com­ment
    Great tool for every­one who like to have their tasks orga­nized, flex­i­ble with many great features.
  4. Sub­limerge (http://www.sublimerge.com/added thanks to Virion’s com­ment
    Diff tool on steroids. Ideal for every­one who has to do a lot with merg­ing, espe­cially use­ful when it comes to large files.

That’s it for now. I might come back and some­thing later, but this is my set-up and works great for me.

If you know any plu­gin worth men­tion­ing, then let me know — I’ll be glad to add it to my list. Any suggestions? :)

2Aug/124

Sublime Text 2 perfect PHP development set-up

No Gravatar

Update: There is also avail­able plu­g­ins list for Sub­lime Text 3, check it out here

Lately, I’ve become a huge fun of Sub­lime Text 2, which in my hum­ble opin­ion (OK, not only mine, take a look in here) is best text editor/IDE I’ve ever used.

I called it IDE (Inte­grated Devel­op­ment Envi­ron­ment) which isn’t really true yet, but it’s get­ting awfully close to become one.

Sub­lime Text 2 is great on its own, but it really starts to kick ass with help of addons called ‘pack­ages’. You can look for them on Inter­net or browse on wbond web­site.

OK, but get­ting to the point: I use ST2 for some time now for PHP devel­op­ment and I tried almost all pack­ages I came across which are even slightly related to my job. In order to get most of them (except one or two) you’ll need wbond’s Sub­lime Pack­age Con­trol. Ok, really you CAN install all of them man­u­ally, but what’s the point of re-inventing the wheel? I’ll stick with the easy way if you don’t mind ;)

And here is my list, enjoy and maybe throw a sug­ges­tion or two if you know some­thing I don’t know ;)

  1. Sub­lime­CodeIn­tel (https://github.com/Kronuz/SublimeCodeIntel)
    This is pack­age I use all the time. It’s job is to pro­vide hints related to func­tion, object, vari­able etc. names. It also hints what meth­ods and para­me­ters are avail­able in objects/classes. It’s based on Komodo CodeIn­tel and some­times it has some prob­lems work­ing at all. But most of the time it rocks :)
  2. Sub­limeLin­ter (https://github.com/SublimeLinter/SublimeLinter)
    This pack­age does full-time job for me — it con­stantly watches what I write and instantly lets me know if some­thing is not OK, for exam­ple I for­get semi-colon or brackets.
  3. SFTP, paid (http://wbond.net/sublime_packages/sftp)
    Great pack­age enabling very com­fort­able use of SFTP, FTP and FTPS. It sup­ports remote fold­ers brows­ing, edit­ing and syn­chro­niza­tion between local and remote files. Also reg­u­lar upload, down­load pn save or file open.
  4. Side­Bar­Git (https://github.com/SublimeText/SideBarGit)
    I use Git on daily basis and hav­ing an easy and com­fort­able GUI is essen­tial. This is what this pack­age does — it pro­vides set of most often used func­tions and inte­grates it with ST2 via right-click menu.
  5. Tor­toise (on Win­dows only) (http://wbond.net/sublime_packages/tortoise)
    I use it as a com­ple­men­tary pack­age to Side­Bar­Git if I’m work­ing in Win­dows envi­ron­ment. It doesn’t have so many fea­tures but those what it pro­vide are very help­full and intu­itive.
    If you like Tor­toise Git but you are work­ing on Linux you might want to check out Rab­bitVCS. It isn’t inte­grated with ST2, but it pro­vides com­fort­able right-mouse-click Git GUI.
  6. sublime-github (https://github.com/bgreenlee/sublime-github)
    Every devel­oper should use code snip­pets of some kind. I use Gist pro­vided by GitHub and this pack­age enables me to use them instantly (save/paste).
  7. Tag (https://github.com/SublimeText/Tag)
    Great pack­age, which sim­ply takes care of all tag-matching related issues. Love it :)
  8. DocBlockr (https://github.com/spadgos/sublime-jsdocs)
    Nobody likes it, at least nobody I know, but as a devel­oper you have to main­tain solid code doc­u­men­ta­tion. This is where this pack­age helps — it pre­pares DocBlock com­ments for classes, params, meth­ods etc. Speeds up things.
  9. Phpcs (http://soulbroken.co.uk/code/sublimephpcs)
    This pack­age adds sup­port for PHP_CodeSniffer to ST2. It checks if you code is writ­ten accord­ing to one of the stan­dards. Just pick one: Zend, PEAR.. and more :) Check out PHP_CodeSniffer web­site for con­fig­u­ra­tion details.
  10. Trail­ing­Spaces (https://github.com/SublimeText/TrailingSpaces)
    Small hor­ror of every code — empty spaces at lines ends, at the end of file. Espe­cially trou­ble­some if you are work­ing on the code with other devel­op­ers, who might use dif­fer­ent editors/IDEs which might inter­pret them (empty spaces) differently.
  11. Brack­etHigh­lighter (https://github.com/facelessuser/BracketHighlighter)
    One of my favorites: clearly high­lights match­ing brack­ets, quotes etc. Just makes every­day life eas­ier when look­ing at code with mul­ti­ple brackets-in-brackets constructions.
  12. Detect­Syn­tax (https://github.com/phillipkoebbe/DetectSyntax)
    Detects syn­tax of opened file. ST2 doesn’t always get it right and this pack­ages helps.
  13. Encod­ingHelper (https://github.com/SublimeText/EncodingHelper)
    Detects and dis­plays file encod­ing and sticks to it. Help­ful in shared devel­op­ment envi­ron­ment if some­one uses for exam­ple IDE with default win­dows encod­ing instead of UTF-8.
  14. Sub­lime Func­tion Name Dis­play (https://github.com/akrabat/SublimeFunctionNameDisplay)
    Dis­plays in bot­tom bar name of a func­tion (or method) in which our cur­sor is placed. Sim­ple and helpful.
  15. Ter­mi­nal (http://wbond.net/sublime_packages/terminal)
    Using Git or maybe some PEAR pack­ages you might need to switch to con­sole from time to time and do some magic. Maybe use Zend Tool or “bake” some­thing ;) It’s just what this plu­gin is for.
  16. Xde­bug (https://github.com/Kindari/SublimeXdebug)
    Last but not least — power of Xde­bug in ST2. It brings Xde­bug capa­bil­i­ties to ST2 and enables debug­ging as most of “big” IDEs can do.

Few pack­ages I use but don’t con­sider essential:

  1. Color High­lighter (https://github.com/Monnoroch/ColorHighlighter)
    When you move your cur­sor on color def­i­n­i­tion (hex, for exam­ple) it high­lights text with this color. help­ful when writ­ing CSS.
  2. Col­or­Picker (https://github.com/weslly/ColorPicker)
    Graph­i­cal color picker. Doesn’t really need expla­na­tion, doesn’t it?
  3. Pre­fixr (http://wbond.net/sublime_packages/prefixr)
    This one is nice and I would prob­a­bly make more use of it if I were devel­op­ing more CSS :)
  4. All Auto­com­plete (https://github.com/iamnoah/Autocomplete-All)
    Enhances ST2 abil­ity to auto­com­plete by increas­ing scope to all opened files, not only one we are cur­rently in.
  5. ApacheConf.tmbundle (https://github.com/colinta/ApacheConf.tmLanguage)
    Lan­guage def­i­n­i­tions for Apache conf and .htac­cess files.
  6. Zend-Framework.tmbundle (https://github.com/ybits/Zend-Framework.tmbundle)
    Code snip­pets for devel­op­ing in Zend Frame­work. Although I do use ZF I never started to make use of these snip­pets, at least not of their full potential.
  7. Addi­tional PHP Snip­pets (https://github.com/stuartherbert/sublime-phpsnippets)
    Same here as with Zend Frame­work snip­pets. I might some day start to use more of them.

There are also pack­ages for Word­Press, Zen­Cod­ing or one mov­ing Semi­Colon out of brack­ets and many more, but I’m doing all right with­out them.

20Dec/1147

GitLab installation on Fedora 16 (with gitolite)

No Gravatar
This is updated ver­sion of my tuto­r­ial for Git­Lab 2.1. Old ver­sion can be found here

Git­Lab is a won­der­ful piece of soft­ware made by these guys and I’d like to try and install it on Fedora 16 sys­tem, as it is most recent Fedora OS at the time I am writ­nig this. I will base my tuto­r­ial on on found here by Déja. Also on my way to suc­cess­ful install I’ve stum­bled upon this descrip­tion, so I might have gain some expe­ri­ence from it too.

Git­Lab is Ruby on Rails appli­ca­tion and it takes some expe­ri­ence to get it all work­ing because of many, many, many depen­den­cies and pack­ages it needs. It’s noth­ing like sim­ple PHP on Apache instal­la­tion. But it works and it’s worth it, I assure you :)

Let’s begin! (by the way: I per­form all as root user — again: test environment)

small edit: For peo­ple who only want this to work and not nec­es­sar­ily wish to know how and why, I have pre­pared easy instal­la­tion scripts in here
another EDIT: Git­Lab is under heavy devel­op­ment and now it’s sta­ble ver­sion is 2.1. This means that my guide might be not entirely accu­rate. Please be cau­tious. I’ll update it soon.
  1. First of all: I am work­ing on vir­tual machine with brand new and fresh Fedora 16 installed. Min­i­mal instal­la­tion, just to make sure noth­ing messes with Git­Lab. Con­sider this a test environment.
  2. Once you have your OS ready, update it with yum update and also install some pack­ages you will need on the way:
    yum install make openssh-clients gcc libxml2 libxml2-devel \
    libxslt libxslt-devel python-devel
  3. Check what ver­sion of ruby is avail­able via yum. Git­Lab needs at least ver­sion 1.9.2
    yum info ruby

    on mine it says that the only avail­able ver­sion for me is 1.8.7.357 so I have to get it some­where else.

  4. Using RVM to install Ruby.
    EDIT: I have switched to ruby 1.9.3p0 — it works and starts a lot faster, you can use it instead of 1.9.2-p290 in this guide.

    I will use RVM, which stands for Ruby Ver­sion Man­ager — bril­liant tool, which you can use to install and man­age your Ruby with ease. Let’s check it out, shall we? (you can install Ruby any way you want — I’ll just do this RVM way)

    Notice use of –with-openssl switch — with­out that pas­sen­ger will com­plain about Ruby OpenSSL sup­port and won’t com­pile in next step.

    sudo bash -s stable < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
    
    source /etc/profile.d/rvm.sh
    
    rvm install ruby-1.9.2-p290 --with-openssl
    
    rvm use ruby-1.9.2-p290 --default
    

    Done. Just like that we have oper­a­tional Ruby 1.9.2-p290. No RPMs, no going back in time.. nice, huh? :)

  5. Good. Small (nice) sur­prise: our RPM installed ruby gems for us, so now we only have to get rails gem.
    first, just to make sure every­thing is up to date, execute:
    rvm all do gem update --system

    now install rails with:

    rvm all do gem install rails
  6. Now we will install apache2 as a web­server and Pas­sen­ger for ruby apps deploy­ment. I know that most Git­Lab tuto­ri­als use nginx but I really like apache ;)
    yum install -y httpd
    rvm all do gem install passenger

    as I men­tioned: I use apache, so I will need pas­sen­ger mod­ule for it:
    first some required packages:

    yum install -y gcc-c++ curl-devel openssl-devel zlib-devel \
    httpd-devel apr-devel apr-util-devel

    an then use

    passenger-install-apache2-module

    in order to install it.it gives you 2 infor­ma­tion on how to pro­ceed with apache configuration:

    • add fol­low­ing lines to /etc/httpd/conf/httpd.conf (at the very end):
      LoadModule passenger_module /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
      PassengerRoot /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.11
      PassengerRuby /usr/bin/ruby
      
    • and then cre­ate file named default.conf (or gitlab.conf, or some­thing other you like) in /etc/httpd/conf.d/ con­tain­ing these lines (remem­ber to change to fit your environment):
      <VirtualHost *:80>
      ServerName www.yourhost.com
      DocumentRoot /somewhere/public
      <Directory /somewhere/public>
      AllowOverride all
      Options -MultiViews
      </Directory>
      </VirtualHost>
      

      (don’t worry, we’ll come back to this one later)

  7. Now it is time for gito­lite. I won’t use gito­sis because it is not actively devel­oped any more and I found that new Git­Lab works bet­ter with gitolite.install it with
    yum install -y gitolite

    now, wasn’t that quick? :)

  8. Now we will need to cre­ate new gito­lite server con­fig­u­ra­tion and in order to do that we have to gen­er­ate SSH key-pair. But first things first.
    To get us started we will cre­ate git user with

    adduser -r -m --shell /bin/bash \
     --comment 'git version control' git
    mkdir /home/git/.ssh
    chown git:git -R /home/git/.ssh
    

    Now we have to cre­ate SSH keys pair for him:

    ssh-keygen -q -o -N '' -t rsa -f /home/git/.ssh/id_rsa

    To ini­tial­ize Gito­lite we need to first edit it’s default con­fig­u­ra­tion file and change default per­mis­sions and then ini­tial­ize it by using git user:

    sed -i 's/0077/0007/g' /usr/share/gitolite/conf/example.gitolite.rc
    
    su - git -c "gl-setup -q /home/git/.ssh/id_rsa.pub"

    as men­tioned here

  9. Just to make sure that git user has all nec­es­sary access rights to his own home direc­tory after we have added SSH keys for him:
    chown git:git -R /home/git/
  10. OK, time for next require­ments: python Pip, I will go with method from orig­i­nal post and NOT use yum for that.
    curl http://python-distribute.org/distribute_setup.py | python
    

    and then

    easy_install pip
    
  11. Data­base. We need it. We have it already — it was installed on the way as a depen­dency. Just to make sure check if you have SQLite at list ver­sion 3.6 with:
    yum info sqlite

    I have 3.7.7.1. All we need is SQLite devel­op­ment pack­age, get it with:

    yum install -y sqlite-devel
  12. And now the main event! GitLabHQ!

    I like install web apps in /var/www so we will go there and git clone GitLab:

    cd /var/www
    
    git clone git://github.com/gitlabhq/gitlabhq.git
    
    cd gitlabhq/
    

    we need to use pip to install some python dependencies:

    pip install pygments

    and bundler gem so it can later on do most of the work for us:

    rvm all do gem install bundler

    you will need one more depen­dency for bun­dle install

    yum install -y libicu-devel

    finally (remem­ber to be in Git­Lab direc­tory):

    bundle install

    (go get your­self a cof­fee or other treat — it takes a while)

  13. Redis instal­la­tion. More about Redis here
    yum install -y redis

    and start it with:

    service redis start
    
  14. Prepar­ing con­fig files.copy data­base and git­lab con­fig files from exam­ple to work­ing copies:
    cp config/gitlab.yml.example config/gitlab.yml
    cp config/database.yml.example config/database.yml
  15. DB setup:
    And now data­base setup and import:
    RAILS_ENV=production rake db:setup
    RAILS_ENV=production rake db:seed_fu
    

    TIP: if you get errors here, check if you don’t have 2 ver­sions of rake installed (I had some­how): 0.8.7 and 0.9.2. If you do, remove older with:

    gem uninstall rake

    and choose appro­pri­ate ver­sion. If you still have prob­lems try:

    gem install rake

    -> don’t know why, but if it installs again same ver­sion of rake, it works.

  16. Apache vir­tual host con­fig­u­ra­tion should look some­thing like this (I told you, we will get back to that):file: /etc/httpd/conf.d/gitlab.conf
    <VirtualHost *:80>
    ServerName www.yourhost.com
    DocumentRoot /var/www/gitlabhq/public
    <Directory /var/www/gitlabhq/public>
    AllowOverride all
    Options -MultiViews
    </Directory>
    </VirtualHost>
    
  17. enable apache user, co you can su into this account:
    usermod -s /bin/bash -d /var/www/ apache

    pre­pare SSH key for him (actu­ally use one cre­ated for git user)

    mkdir /var/www/.ssh
    
    cp -f /home/git/.ssh/id_rsa /var/www/.ssh/ && chown apache:apache /var/www/.ssh/id_rsa && chmod 600 /var/www/.ssh/id_rsa
    

    add local­host to apache user known_hosts with:

    ssh-keyscan localhost >> /var/www/.ssh/known_hosts

    also give him per­mis­sions to his own home direc­tory with:

    chown -R apache:apache /var/www/

     

  18. add apache user to git group with:
    usermod -a -G git apache
  19. check if repos­i­to­ries direc­tory has cor­rect per­mis­sions, it should be 770. You can set it with
    chmod 770 /home/git/repositories/
  20. dou­ble check your fire­wall (for exam­ple ipt­a­bles) if it allows con­nec­tions on port 80 to your server.
  21. impor­tant: Apache won’t be able o start with SELinux set to “enforc­ing”. Please set it to permissive.
  22. start apache server with:
    service httpd start
  23. Now it all should work. Fin­gers crossed.. go to http://www.yourhost.com
  24. Now you should be able to log in using these cre­den­tials:

    user: admin@local.host
    pass: 5iveL!fe

    and you’re in :)

It wasn’t so hard, wasn’t it? ;)

Trou­bleshoot­ing:

  1. I get error 500 when I enter par­tic­u­lar project and try to get into it’s “Admin” sec­tion. Don’t know how to fix it yet.To fix it, check if repos­i­to­ries direc­tory has cor­rect per­mis­sions, it should be 770. You can set it with
    chmod 770 /home/git/repositories

    also set this:

    chmod 770 /home/git
  2. If Pas­sen­ger insists, that we don’t have or he can’t see grit library (gem actu­ally, as far as I know) even though we have it.

    https://github.com/gitlabhq/grit.git (at mas­ter) is not checked out. Please run ‘bun­dle install‘ (Bundler::GitError)

    Only res­o­lu­tion to this prob­lem I have found is to (as root) change /usr/local/rvm/gems/ruby-1.9.3-p0/gems own­er­ship to apache user with:

    chown apache:root -R /usr/local/rvm/gems/ruby-1.9.3-p0/gems

    I know that is not great res­o­lu­tion but it worked for me. If you’ll hap­pen to know bet­ter way — please let me know, so I can update this tuto­r­ial and my knowl­edge of course ;)

    Edit

    I found another solu­tion (instead of chang­ing per­mis­sions): after first

    bundle install

    edit Gem­file and in lines con­tain­ing “git:” remove every­thing after first comma, for example:

    gem "grit", :git => "https://github.com/gitlabhq/grit.git"

    should be

    gem "grit"

    and so on.

    then do again

    bundle install

    and now pas­sen­ger shouldn’t com­plain any more.

19Aug/111

(archive) GitLab installation on Fedora 16 (with gitolite)

No Gravatar
This is old ver­sion of my tuto­r­ial. Most recent ver­sion can be found here

Git­Lab is a won­der­ful piece of soft­ware made by these guys and I’d like to try and install it on Fedora 16 sys­tem, as it is most recent Fedora OS at the time I am writ­nig this. I will base my tuto­r­ial on on found here by Déja. Also on my way to suc­cess­ful install I’ve stum­bled upon this descrip­tion, so I might have gain some expe­ri­ence from it too.

Git­Lab is Ruby on Rails appli­ca­tion and it takes some expe­ri­ence to get it all work­ing because of many, many, many depen­den­cies and pack­ages it needs. It’s noth­ing like sim­ple PHP on Apache instal­la­tion. But it works and it’s worth it, I assure you :)

Let’s begin! (by the way: I per­form all as root user — again: test environment)

small edit: For peo­ple who only want this to work and not nec­es­sar­ily wish to know how and why, I have pre­pared easy instal­la­tion scripts in here
  1. First of all: I am work­ing on vir­tual machine with brand new and fresh Fedora 16 installed. Min­i­mal instal­la­tion, just to make sure noth­ing messes with Git­Lab. Con­sider this a test environment.
  2. Once you have your OS ready, update it with yum update and also install some pack­ages you will need on the way:
    yum install make openssh-clients gcc libxml2 libxml2-devel \ 
    libxslt libxslt-devel python-devel
  3. Check what ver­sion of ruby is avail­able via yum. Git­Lab needs at least ver­sion 1.9.2
    yum info ruby

    on mine it says that the only avail­able ver­sion for me is 1.8.7.35 so I have to get it some­where else.

  4. Method #1.
    I will do as it says here. I have tried it before and it works flaw­lessly. With one or two catches of course ;)Men­tioned catches and tips:

    • you need wget, if you don’t have it already use
      yum install -y wget
    • other needed pack­ages (plus few depen­den­cies) can be obtained by typing:
      yum install -y readline-devel ncurses-devel gdbm-devel \ 
      glibc-devel tcl-devel openssl-devel db4-devel byacc
    • if you are using vir­tual machine, like me, you can first make a snap­shot of it, then build ruby RPM pack­age, copy it to you host machine (or net­work share or what­ever place out­side vir­tual machine) and then go back in time to you snap­shot. Voila! Clean sys­tem ready for fur­ther installing Git­Lab. All you need to do is install ear­lier cre­ated ruby RPM. Any­way this is what I’m gonna do today. Keep it clean.
    • last step — your RPM will end up some­where in ~/rpmbuilds/RPMS direc­tory. It will reside in folder named after your sys­tem archi­tec­ture, in my case: i386

    And here is how:

    yum install -y rpm-build rpmdevtools
    rpmdev-setuptree
    cd ~/rpmbuild/SOURCES
    wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz
    cd ~/rpmbuild/SPECS
    curl https://raw.github.com/imeyer/ruby-1.9.2-rpm/master/ruby19.spec > ruby19.spec
    rpmbuild -bb ruby19.spec
    rpm -Uvh ~/rpmbuild/RPMS/x86_64/ruby-1.9.2p290-2.ruby-1.9.2p290-2.i386.rpm
    

    I took my VM about 4 min­utes to com­pile and pre­pare RPM. Not so bad.
    Now I go back in time in my VM and install newly cre­ated RPM with

    rpm -Uvh ruby-1.9.2p290-2.fc16.i386.rpm
  5. Method #2. ( I pre­fer this one so far)
    EDIT: I have switched to ruby 1.9.3p0 — it works and starts a lot faster, you can use it instead of 1.9.2-p290 in this guide.

    I will use RVM, which stands for Ruby Ver­sion Man­ager — bril­liant tool, which you can use to install and man­age your Ruby with ease. Let’s check it out, shall we?

    sudo bash -s stable < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
    
    source /etc/profile.d/rvm.sh
    
    rvm install ruby-1.9.2-p290
    
    rvm use ruby-1.9.2-p290 --default
    

    Done. Just like that we have oper­a­tional Ruby 1.9.2-p290. No RPMs, bo going back in time.. nice, huh? :)

  6. Good. Small (nice) sur­prise: our RPM installed ruby gems for us, so now we only have to get rails gem.
    first, just to make sure every­thing is up to date, execute:
    gem update --system

    now install rails with:

    gem install rails
  7. Now we will install apache2 as a web­server and Pas­sen­ger for ruby apps deploy­ment. I know that most Git­Lab tuto­ri­als use nginx but I really like apache ;)
    yum install -y httpd
    gem install passenger

    as I men­tioned: I use apache, so I will need pas­sen­ger mod­ule for it:
    first some required packages:

    yum install gcc-c++ curl-devel openssl-devel zlib-devel \ 
    httpd-devel apr-devel apr-util-devel

    an then use

    passenger-install-apache2-module

    in order to install it.it gives you 2 infor­ma­tion on how to pro­ceed with apache configuration:

    • add fol­low­ing lines to /etc/httpd/conf/httpd.conf (at the very end):
      LoadModule passenger_module /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
      PassengerRoot /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.11
      PassengerRuby /usr/bin/ruby
      
    • and then cre­ate file named default.conf (or gitlab.conf, or some­thing other you fancy) in /etc/httpd/conf.d/ con­tain­ing these lines (remem­ber to change to fit your environment):
      <VirtualHost *:80>
      ServerName www.yourhost.com
      DocumentRoot /somewhere/public
      <Directory /somewhere/public>
      AllowOverride all
      Options -MultiViews
      </Directory>
      </VirtualHost>
      

      (don’t worry, we’ll come back to this one later)

  8. Now it is time for gito­lite. I won’t use gito­sis because it is not actively devel­oped any more and I found that new Git­Lab works bet­ter with gitolite.install it with
    yum install -y gitolite

    now, wasn’t that quick? :)

  9. Now we will need to cre­ate new gito­lite server con­fig­u­ra­tion and in order to do that we have to gen­er­ate SSH key-pair. But first things first.
    To get us started su into gito­lite user with

    su - gitolite

    now try to log into local­host via SSH -> it’s small thing which will make our life eas­ier in the future.

    ssh localhost

    Just make it add local­host to list of known host — no need to actu­ally authen­ti­cate. SSH cre­ated for us ~/.ssh direc­tory. That’s nice.SSH key gen­er­a­tion is as easy as:

    ssh-keygen -t rsa

    use default path for sav­ing key-pair (/var/lib/gitolite/.ssh/id_rsa) and no para­phrase. Test envi­ron­ment. Just a reminder.as for ini­tial­iza­tion of gito­lite repository:

    gl-setup .ssh/id_rsa.pub

    next hit ENTER and edit will open, change value of

    $REPO_UMASK to 0007

    as men­tioned hereLook like we are done here. Exit gito­lite user shell and return to being almighty root himself ;)

  10. OK, time for next require­ments: python Pip, I will go with method from orig­i­nal post and NOT use yum for that.
    curl http://python-distribute.org/distribute_setup.py | python
    

    and then

    easy_install pip
    
  11. Data­base. We need it. We have it already — it was installed on the way as a depen­dency. Just to make sure check if you have SQLite at list ver­sion 3.6 with:
    yum info sqlite

    I have 3.7.7.1. All we need is SQLite devel­op­ment pack­age, get it with:

    yum install sqlite-devel
  12. And now the main event! GitLabHQ!

    I like install web apps in /var/www so we will go there and git clone GitLab:

    cd /var/www
    
    git clone git://github.com/gitlabhq/gitlabhq.git
    
    cd gitlabhq/
    

    we need to use pip to install some python dependencies:

    pip install pygments

    and bundler gem so it can later on do most of the work for us:

    gem install bundler

    finally (remem­ber to be in Git­Lab direc­tory):

    bundle install

    (go get your­self a cof­fee or other treat — it takes w while)

  13. DB setup:
    EDIT: For Git­Lab ver­sion 2.1 install Redis — with­out it rake will fail.:
    yum install redis libicu-devel
    service redis start
    

    And now data­base setup and import:

    RAILS_ENV=production rake db:setup
    RAILS_ENV=production rake db:seed_fu
    

    TIP: if you get errors here, check if you don’t have 2 ver­sions of rake installed (I had some­how): 0.8.7 and 0.9.2. If you do, remove older with:

    gem uninstall rake

    and choose appro­pri­ate ver­sion. If you still have prob­lems try:

    gem install rake

    -> don’t know why, but if it installs again same ver­sion of rake, it works.

  14. Apache vir­tual host con­fig­u­ra­tion should look some­thing like this (I told you, we will get back to that):file: /etc/httpd/conf.d/gitlab.conf
    <VirtualHost *:80>
    ServerName www.yourhost.com
    DocumentRoot /var/www/gitlabhq/public
    <Directory /var/www/gitlabhq/public>
    AllowOverride all
    Options -MultiViews
    </Directory>
    </VirtualHost>
    
  15. set cor­rect set­tings in /var/www/gitlabhq/config/gitlab.yml

    in my case:# Git Host­ing configuration

    git_host:
    system: gitolite
    admin_uri: gitolite@localhost:gitolite-admin
    base_path: /var/lib/gitolite/repositories/
    host: localhost
    git_user: gitolite
    # port: 22
    
  16. enable apache user, co you can su into this account:
    usermod -s /bin/bash -d /var/www/ apache

    also give him per­mis­sions to his own home direc­tory with:

    chown -R apache:apache /var/www/

    (I know this kinda over­rides last chown command…)

  17. do:
    su - apache && ssh localhost

    (same thing as in step 8. with know_hosts file. )
    exit apache’s shell and as root copy id_rsa pri­vate key from /var/lib/gitolite/.ssh/ to /var/www/.ssh/ and make apache it’s owner with:

    cp -f /var/lib/gitolite/.ssh/id_rsa /var/www/.ssh/ \
    && chown apache:apache /var/www/.ssh/id_rsa \
    && chmod 600 /var/www/.ssh/id_rsa
  18. add apache user to gito­lite group with:
    usermod -a -G gitolite apache
  19. check if repos­i­to­ries direc­tory has cor­rect per­mis­sions, it should be 770. You can set it with
    chmod 770 /var/lib/gitolite/repositories/
  20. dou­ble check your fire­wall (for exam­ple ipt­a­bles) if it allows con­nec­tions on port 80 to your server.
  21. start apache server with:
    service httpd start
  22. Now it all should work. Fin­gers crossed.. go to http://www.yourhost.com
  23. Now you should be able to log in using these cre­den­tials:

    user: admin@local.host
    pass: 5iveL!fe

    and you’re in :)

It wasn’t so hard, wasn’t it? ;)

Trou­bleshoot­ing:

  1. I get error 500 when I enter par­tic­u­lar project and try to get into it’s “Admin” sec­tion. Don’t know how to fix it yet.To fix it, check if repos­i­to­ries direc­tory has cor­rect per­mis­sions, it should be 770. You can set it with
    chmod 770 /var/lib/gitolite/repositories/
  2. If Pas­sen­ger insists, that we don’t have or he can’t see grit library (gem actu­ally, as far as I know) even though we have it.

    https://github.com/gitlabhq/grit.git (at mas­ter) is not checked out. Please run ‘bun­dle install‘ (Bundler::GitError)

    I didn’t have gem grit installed, do:

    gem install grit
    

    also it won’t hurt to update all gems with:

    gem update

    Only res­o­lu­tion to this prob­lem I have found is to run bun­dle again as a user who runs apache server: apache.Su into apache account with

    su - apache

    and try:

    gem install grit

    you’ll get error:

    You don't have write permissions into the /usr/lib/ruby/gems/1.9.1 directory.

    As root change it’s own­er­ship to apache user with:

    chown apache:root -R /usr/lib/ruby/gems

    I know that is not great res­o­lu­tion but it worked for me. If you’ll hap­pen to know bet­ter way — please let me know, so I can update this tuto­r­ial and my knowl­edge of course ;)

    Edit

    I found another solu­tion (instead of chang­ing per­mis­sions): after first

    bundle install

    edit Gem­file and in lines con­tain­ing “git:” remove every­thing after first comma, for example:

    gem "grit", :git => "https://github.com/gitlabhq/grit.git"

    should be

    gem "grit"

    then do again

    bundle install

    and now pas­sen­ger shouldn’t com­plain any more.

Tagged as: , 1 Comment
   
Return to Top ▲Return to Top ▲