I’ve been using Vagrant for a several years now and love it. One of my few complaints was that each time I wanted to create a new machine I would need to edit my /etc/hosts file. Then I found the excellent Vagrant plugin named Landrush.

My hosts file went from this:

127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
192.168.10.2 project1
192.168.10.3 project2
192.168.10.4 project4
192.168.10.5 project5
192.168.10.6 project6
192.168.10.7 project7
192.168.10.8 project8
192.168.10.9 project9

To this:

127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost

How to Install Landrush

Installing and using Landrush is really easy.

Step 1: Install the plugin

vagrant plugin install Landrush

Step 2: Add the Landrush configuration to your Vagrantfile

config.vm.hostname = "project1.vagrant.dev" # if not set yet
config.landrush.enabled = true

There are more options you can add which can be found here.

If you don’t want to use the TLD of vagrant.dev you can change it but keep it mind it will override that TLD on your computer. If you set your box’s hostname to something.google.com and set landrush.tld = google.com your searches won’t work very well unless you use Bing…nevermind, your searches still won’t work very well.

Step 3: Start up your vagrant box

vagrant up

That’s it. Landrush does everything else for you.

Test your box, project1.vagrant.dev should be pointing to the IP address of your vagrant box.

Share

I use Vagrant boxes for almost all of my development work. I recently came across this simple yet incredibly time-saving Vagrant tip. I use NFS to share files between my host computer and Vagrant box. While Vagrant makes this quite trivial to do Vagrant does require elevated permissions to mount the NFS share which means I need to enter my password everytime a Vagrant box starts up. This isn’t a huge deal as I only restart my Vagrant boxes a few times a week but I frequently will start up a box then go do something else while it boots and when I return later I see my box sitting at the password prompt. By adding a few lines to my /etc/sudoers file I just type vagrant up and I’m done.

1. Open up terminal. (CMD+SPACE, type in terminal)

2. Type in:
sudo visudo

3. Enter your password.

4. Add these lines to the bottom of the file.
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE

In case you aren’t familiar with vim, press i to insert text, when done, press ESC, then : followed by wq then press enter.

Your done! Wait 5 minutes (because you just typed in your password like 30 seconds ago). Then type vagrant up from your project root and don’t enter your password.

Share

Recently I was installing Couchbase Server on CentOS 6

rpm --install http://packages.couchbase.com/releases/2.1.1/couchbase-server-community_x86_64_2.1.1.rpm

I received this dependency error:

error: Failed dependencies:
libcrypto.so.6()(64bit) is needed by couchbase-server-2.1.1-764.x86_64
libssl.so.6()(64bit) is needed by couchbase-server-2.1.1-764.x86_64

To fix just install this:

yum install openssl098e

[ad name=”Google Adsense 468×60″]

Share

  1. Download ElasticSearch
    wget http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.6.tar.gz
    
    
  2. Extract archive
    tar -xzf elasticsearch-0.20.6.tar.gz
  3. Move extracted folder to /opt/elasticsearch
    mv elasticsearch-0.20.6 /opt/elasticsearch

    [ad name=”Google Adsense 468×60″]

  4. Set permissions
    chown -R root:root /opt/elasticsearch
  5. Change to elasticsearch directory
    cd /opt/elasticsearch

    // //

  6. Install Web GUI plugin
    bin/plugin -install mobz/elasticsearch-head
  7. Install Couchbase Transport plugin
    bin/plugin -install transport-couchbase -url http://packages.couchbase.com.s3.amazonaws.com/releases/elastic-search-adapter/1.0.0/elasticsearch-transport-couchbase-1.0.0.zip
  8. Setup a username and password for Couchbase Replication to connect to your ElasticSearch server. Change “abc123” to your desired password.
    echo "couchbase.password: abc123" >> config/elasticsearch.yml
    
     echo "couchbase.username: admin" >> config/elasticsearch.yml
    
     
  9. Edit ElasticSearch configuration file and set the following parameters
    cluster.name: NameOfYourCluster
    
    network.host: local ip address of this node
    
    node.name: "name of this node"
    
    
  10. Download a script that will allow you to run ElasticSearch as a service
    curl -L http://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master | tar -xz
  11. We only need the one script so move it over
    mv *servicewrapper*/service bin/
  12. Cleanup
    rm -Rf *servicewrapper*
  13. Install ElasticSearch as service with the new script.
    bin/service/elasticsearch install
  14. Create a symbolic link
    ln -s `readlink -f bin/service/elasticsearch` /usr/local/bin/rcelasticsearch
  15. Start the service
    service elasticsearch start
  16. Make ElasticSearch start on boot
    chkconfig elasticsearch on
  17. Set the default template for Couchbase Transport
    curl -XPUT http://localhost:9200/_template/couchbase -d @plugins/transport-couchbase/couchbase_template.json
  18. That’s it. Your ElasticSearch server is now ready to be setup as a replication endpoint for Couchbase. For instructions on how to setup the replication on your Couchbase server visit: http://blog.couchbase.com/couchbase-and-full-text-search-couchbase-transport-elastic-search
Share

This past weekend I was trying to use the Zend Framework Twitter library. While the documentation made it look simple, it was missing a lot of steps and information. With the help of a lot of googling I came up with this:

[ad name=”Google Adsense 468×60″]

 
        $userToken = 'user_token';
        $userSecret = 'user_secret';
        
        $appConsumerKey = 'your_app_consumer_key';
        $appConsumerSecret = 'your_app_consumer_secret';
        
        // generate an Oauth token to pass to Zend_Service_Twitter
        $token = new Zend_Oauth_Token_Access();
        $token->setToken($userToken)
              ->setTokenSecret($userSecret);

        $options = array(
            'username'       => 'twitter_username',
            'accessToken'    => $token,
            'consumerKey'    => $appConsumerKey,
            'consumerSecret' => $appConsumerSecret
        );

        $twitter = new Zend_Service_Twitter($options);
        
        // verify user's credentials with Twitter
        var_export($twitter->account->verifyCredentials());
        
Share