Category Archives: Linux/Unix

configure apache

Apache Active Directory Authentication

Overview

This tutorial provides an example of Apache Active Directory Authentication using the Authz LDAP module.
Apache and SSL settings are not in the scope of this tutorial.
Continue reading

Basic SELinux Security Concepts

Overview

“SELinux is a security enhancement to Linux which allows users and administrators more control over access control.” (selinuxproject.org”
Continue reading

VMWare Workstation start on boot CentOS

FFMPEG CentOS 7 installation instructions

FFMPEG CentOS 7 installation instructions

Installation

  1. install the atrpms repository
  2. Install ffmpeg

 

install the atrpms repository

Add the GPG-Key using:

rpm –import http://packages.atrpms.net/RPM-GPG-KEY.atrpms

and then create a file name atrpms.repo inside /etc/yum.repos.d and fill it with:

[atrpms]
name=Fedora Core $releasever – $basearch – ATrpms
baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/stable
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1

FFMPEG CentOS 7 – Install ffmpeg

Now, run:

yum install ffmpeg

And you have ffmpeg installed on your CentOS 7.0 machine.

That’s it.

 

Development Specialist, Artist and Activist
Personal Website

Kafka CentOS Installation Instructions

Kafka CentOS Installation Instructions

If you’re here, you’re probably knows what `Kafka` is and what it should be used for.

If not, visit Apache Kafka page to learn more

Prerequisities

  • wget (yum install wget)
  • tar (yum install tar)

Installation

First thing, lets go over to Kafka Download page to download kafka into our machine:

# choose a directory to download kafka into. it could be really anywhere:
# /home, /var, /usr, /opt or even /tmp if you just wanna play with it.
cd /opt
wget http://apache.mivzakim.net/kafka/0.8.2.0/kafka_2.10-0.8.2.0.tgz
tar -zxvf kafka_2.10-0.8.2.0.tgz
rm kafka_2.10-0.8.2.0.tgz -y
cd kafka_2.10-0.8.2.0

Well.. and that’s preety it. you have Kafka CentOS installation on your machine. Now, lets play with it a little:

Start quick-and-dirty server

from Kafka QuickStart:

Kafka uses ZooKeeper so you need to first start a ZooKeeper server if you don’t already have one. You can use the convenience script packaged with kafka to get a quick-and-dirty single-node ZooKeeper instance.

so just run now at your console:

bin/zookeeper-server-start.sh config/zookeeper.properties

after, you’ll see the BEAUTIFUL output telling you everything is fine and zookeeper is running on 0.0.0.0:2181:

Kafka CentOS

Kafka CentOS

Now, we’re gonna be more dirtier and just for now, we’ll move the zookeeper server into background so we could start the kafka server. This can be done by pressing: CTRL+Z which outputs:

[1]+ Stopped bin/zookeeper-server-start.sh config/zookeeper.properties

Then run the command:

bg
> [1]+ bin/zookeeper-server-start.sh config/zookeeper.properties &

# you can check that zookeeper is running at background by use the jobs command:
jobs
> [1]+ Running bin/zookeeper-server-start.sh config/zookeeper.properties &

Now start the Kafka server:

bin/kafka-server-start.sh config/server.properties

And look as the PRETTY lines are printing and loading your Kafka server instance.

Kafka_loaded

 

FATAL Fatal error during KafkaServerStartable startup. Prepare to shutdown (kafka.server.KafkaServerStartable)

If you get this error, you need to add your hostname to /etc/hosts: 127.0.0.1 localhost myhostname

 

What’s now?

That’s it, you have Kafka CentOS installation! Go from STEP 3 in the quickstart to learn the basics of Kafka..

 

Good Luck!

Development Specialist, Artist and Activist
Personal Website
VMWare Workstation start on boot CentOS

EPEL CentOS 7 – Add Fedora EPEL repository

EPEL CentOS 7

EPEL CentOS 7 – In the next tutorial I will show you how to add the fedora EPEL repository to your CentOS 7 installation

.

Applicable to

  • Centos 7.x, but also to CentOS 6.x (and probably earlier)

 

Requirements

In order to install CentOS EPEL Repository you need:

  • root access
  • wget:
yum install wget -y

 

Installation

check here for latest version of epel-release-x-x.noarch.rpm

wget http://mirror.nonstop.co.il/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -Uvh epel-release-7-5.noarch.rpm
rm epel-release-7-5.noarch.rpm -f

or in short:

rpm -Uvh http://mirror.nonstop.co.il/epel/7/x86_64/e/epel-release-7-5.noarch.rpm

Verify

use:

yum repolist

to check that the repo installed correctly.

centos-epel-repolist

That’s it! You’ve added CentOS EPEL repository to your centos installation.

 

How to use?

yum --enablerepo=epel install [package]

for example:

yum --enablerepo=epel install zabbix

Note: The epel configuration file is located under /etc/yum.repos.d/epel.repo.

 

That’s it

Development Specialist, Artist and Activist
Personal Website
VMWare Workstation start on boot CentOS

CentOS Automatic Updates

CentOS Automatic Updates

CentOS Automatic Updates tutorial.

This tutorial apply to Centos 5.x, 6.x and 7.x.

 

CentOS 5.x

The yum package supplied with CentOS 5.0 includes scripts to perform full system updates every day. To activate automatic daily updates, enter this command:

su -c '/sbin/chkconfig --level 345 yum on; /sbin/service yum start'

At the prompt, enter the password for the root account.

There is no separate yum service that runs on your system. The command given above enables the control script /etc/rc.d/init.d/yum. This control script activates the script /etc/cron.daily/yum.cron, which causes the cron service to perform the system update automatically at 4am each day.

CentOS 6.x

To get started, install yum-cron:

yum -y install yum-cron

By default, it’s configured to download all of the available updates and apply them immediately after downloading. Reports will be emailed to the root user on the system. To change these settings, just open /etc/sysconfig/yum-cron in your favorite text editor and adjust wherever setting you need to change:

The important settings to mention are:

# Don't install, just check (valid: yes|no)
CHECK_ONLY=no

# Don't install, just check and download (valid: yes|no)
# Implies CHECK_ONLY=yes (gotta check first to see what to download)
DOWNLOAD_ONLY=no

# if MAILTO is set and the mail command is available, the mail command is used to deliver yum output
# by default MAILTO is unset, so crond mails the output by itself
# example: MAILTO=root
MAILTO=

# you may set DAYS_OF_WEEK to the days of the week you want to run
# default is every day
#DAYS_OF_WEEK="0123456"

If you want to exclude some packages only from the automatic update you can edit the file /etc/sysconfig/yum-cron and set the option YUM_PARAMETER with -x packagename, you have to repeat the -x for every package that you want to exclude, such as:

YUM_PARAMETER="-x kernel* -x php*"

The cron jobs from the yum-cron package are active immediately after installing the package and there’s no extra configuration necessary. The job will be run when your normal daily cron jobs are set to run.

chkconig yum-cron on
service yum-cron start

CentOS 7.x

Although CentOS 6.x Instructions will work for CentOS 7.0, you could upgrade the installation process to be completely CentOS 7.0 compatible:

yum install yum-cron
systemctl enable yum-cron.service
systemctl start yum-cron.service

.conf file (Configuration) located at: /etc/yum/yum-cron.conf AND /etc/yum/yum-cron-hourly.conf.

Note that in contrast to CentOS 6.x, by default yum-cron only download updates once a day and doesn’t apply them. change to:

apply_updates = yes

In /etc/yum/yum-cron.conf if you wish to. make note that you can now define hourly updates in the /etc/yum/yum-cron-hourly.conf file.

That’s it.

Development Specialist, Artist and Activist
Personal Website
VMWare Workstation start on boot CentOS

CentOS 7 VirtualBox Guest Additions Installation

CentOS 7 VirtualBox Guest Additions Installation Tutorial

In the following tutorial, I’ll demonstrate how to install Guest Additions on your VirtualBox hosted CentOS 7 Minimal machine.

Although this tutorial is intended for CentOS 7 minimal, it’s will probably also work on other CentOS releases.

Update your VirtualBox

VirtualBox 4.3.12 or later is required for support in CentOS 7.x, So if you’re using older version of VirtualBox – it’s time for you to upgrade.

Update and Reboot system

After successful installation of your new and shining CentOS box, CentOS-7-installation-VirtualBox

Important Before anything!, I’d advice you to update your CentOS & reboot:

yum update
reboot

After, also try to update your kernel and reboot:

yum update kernel
reboot

You will need to be the root user for the following routine or “su -”

Prerequisities

In order to compile the guest additions you have to install make, gcc, kernel-devel in order to Install VirtualBox Guest Additions installation script.

yum install gcc make kernel-devel

OR, I’ll recommend installing the entire “Developer tools” group which will help you to avoid a lot of trouble later:

yum groupinstall "Development tools"
yum install kernel-devel

Install VirtualBox Guest Additions

Mount your guest additions:

VirtuallBox-MountGuestAdditions

Type at command::

cd /mnt
mkdir cdrom && mount /dev/cdrom /mnt/cdrom
cd cdrom && ./VBoxLinuxAdditions.run

centos-7-guest-additions

If everything “OK” – You have Guest Additions properly installed on your Centos (Minimal) machine. now Reboot:

reboot

 

That’s it!

 

Development Specialist, Artist and Activist
Personal Website

CentOS Grails installation tutorial for newbs – CentOS 6.x

centos grails

centos grails installation tutorial for newbs. for CentOS 6.x (And probably for older/later)

 

Prerequisities

You have to install Groovy (which require JDK). If you don’t have Groovy (And JDK) installed follow those instructions.

  • Java SDK 1.4+ for Grails 1.0.x and 1.1.x
  • Java SDK 1.5+ for Grails 1.2 or greater (For this tutorial make sure you have JDK 1.5+ installed)

 

Install Grails

Option 1: Using GVM (Recommended)

If you’ve installed groovy using GVM, you can use the GVM to install grails too. use:

gvm install grails
centos grails

centos grails

Option 2: Manual Installation

We’d go by the official Grails manual:

The folder we’ll install Grails is: /usr/grails, but you can choose any other as you like.

Init Folder

cd /usr
mkdir grails
cd grails

Here we’ll put the grails files by version.

Visit the download page to get the latest version. as for now it’s 2.3.7

wget http://dist.springframework.org.s3.amazonaws.com/release/GRAILS/grails-2.3.7.zip
unzip grails-2.3.7.zip
rm grails-2.3.7.zip

Install wget & unzip if you don’t yet have them install by: yum install wget unzip

add the following to your ~/.bash_profile or ~/.bash_rc (or wherever you init your user environment):

# grails
export GRAILS_HOME=/usr/grails/grails-2.3.7
export PATH=$PATH:$GRAILS_HOME/bin

That’s it

Option 3: Using GIT

If you want to be updated with latest patches (and bugs) you can clone the git repo.

Prerequisities: you should have JDK installed, your JAVA_HOME set and GIT installed (yum install git).

For the 2.0.x and the ‘master’ branch:

cd /usr
git clone https://github.com/grails/grails-core
cd grails-core && ./gradlew install

and set your GRAILS_HOME in the ~/.bash_profile (or ~.bash_rc):

# grails
export GRAILS_HOME=/usr/grails-core
export PATH=$PATH:$GRAILS_HOME/bin

If you want to install older branch read here.

 

Testing grails

Type at command:

grails --version

You should get something like this output (depend on version)

grails-version

 

That’s It! you have centos grails installed.

Cheers!

Development Specialist, Artist and Activist
Personal Website

CentOS Groovy installation tutorial for newbs – CentOS 6.x

CentOS Groovy

CentOS Groovy installation instruction for newbs.

 

Prerequisities

JDK

To install Groovy you have to install the JDK. If you don’t have JDK installed yet follow those instructions by RaveMaker.

 

Groovy Installation

There are several mothods (as always) to install groovy into your CentOS box.

 

Option 1: GVM

The simplest is using the GVM, tool for managing parallel Versions of multiple Software Development Kits on most Unix based systems. It provides a convenient command line interface for installing, switching, removing and listing Candidates.

GVM is a powerful tool to install Candidates and switch between them (on current terminal, or by default). reading the full intro to GVM is recommended.

to install GVM use the command:

curl -s get.gvmtool.net | bash

This will quickly install GVM into your system

gvm-install

Run the following command as required or log again to the system, as GVM is adding this line to your ~/.bash_profile file:

source "/root/.gvm/bin/gvm-init.sh"

which should return nothing. now you are ready to install groovy by:

gvm install groovy
centos groovy install

centos groovy install

Notes:

  • This will installed groovy version 2.2.2. you can use GVM to install specific groovy version, or multiple versions (read the manual).
  • GVM will create the ~/.gvm directory with all the assets inside (~/.gvm/groovy/2.2.2).

that’s it.

 

Option 2: Manual Installation

It’s always recommended to manually install every peace of code to fully understand what going on there. Following the official installation guide,

Download binary

Download binary for groovy from the download page (check if there is newer version, or specific version you need other then 2.3.0-beta-2 shown here):

cd /usr
mkdir groovy
cd groovy
wget http://dl.bintray.com/groovy/maven/groovy-binary-2.3.0-beta-2.zip
unzip groovy-binary-2.3.0-beta-2.zip
rm groovy-binary-2.3.0-beta-2.zip

This will create a /usr/groovy/groovy-2.3.0-beta-2 folder with the files packed inside.

* If you don’t have wget installed use then ‘yum install wget’ command to install it.
* If you don’t have unzip installed use then ‘yum install unzip’ command to install it. 

TIP

Create a symlink to that folder named ‘latest’ which you can change later when you’ll update your groovy installation without the need to update the environment variables.

ln -s groovy-2.3.0-beta-2 ./latest

Set-up environment

Last thing you need is to:

  • set your GROOVY_HOME environment variable to the directory you unpacked the distribution
  • add GROOVY_HOME/bin to your PATH environment variable

Edit your ~/.bash_profile file and append the following lines:

# Groovy
export GROOVY_HOME=/usr/groovy/latest
export PATH=$PATH:$GROOVY_HOME/bin

or, if you didn’t created the latest symlink, use:

# Groovy
export GROOVY_HOME=/usr/groovy/groovy-2.3.0-beta-2
export PATH=$PATH:$GROOVY_HOME/bin

 

Test Groovy

groovy -e ‘println(“Hello, World!”)’

centos groovy

centos groovy

 

And that’s it! You have Groovy Installed.

Cheers!,

 

grails-logo    Do you need Grails framework for Groove? Read my walkthrough tutorial.

 

Development Specialist, Artist and Activist
Personal Website

CentOS golang Installation Instructions – for CentOS 6.x

CentOS golang

CentOS golang Installation Instructions – for CentOS 6.x.
In the following tutorial I’ll show how to install and run “Hello, world!” script with golang on CentOS 6.x

 

CentOS golang Installation Instructions – for CentOS 6.x

Install EPEL

If you haven’t install EPEL repository yet, you’ll need it now. follow those instructions.
If you want newer versions of golang you might want to try the hop5.in repository but I haven’t tried.

 

Install golang

Simple as:

yum install golang

you may want to install hg also, you’ll probably will need it later for the ‘go get’ command:

yum install hg

 

Hello, World!

create a file named ‘hello.go’ and fill it with:

package main
import "fmt"
func main() {
     fmt.Println("Hello, World!")
}

run the script using:

go run hello.go
centos-golang

centos-golang

You can first build to a binary executible with:

<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;width:555px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer">go build hello.go</div></td></tr></tbody></table></div>

and then run with:

<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;width:555px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer">./hello</div></td></tr></tbody></table></div>

 

$GOPATH

The ‘Hello, World!’ is a very basic example, but in real-world you may need to install packages and libraries for more complex applications.

The $GOPATH environment variable specifies the location of your workspace. It is likely the only environment variable you’ll need to set when developing Go code.

If your project for example is located at $HOME/go, you should create a variable like:

export GOPATH=$HOME/go

For convenience, add the workspace’s bin subdirectory to your path:

export PATH=$PATH:$GOPATH/bin

Now, your project environment variables are set and you can download packages with the simple command: (for example – the Google OAuth 2.0 library)

go get code.google.com/p/goauth2/oauth

 

What’s next

Web Applications using Go

  • Writing Web Applications tutorial.
  • Bones – A project template for Go webapps.
  • Gorilla web toolkit.
  • Revel – A high-productivity web framework for the Go language. Deploy Revel.
  • Martini – Classy web framework for Go.
  • sawsij – lightweight, open-source web framework for building high-performance, data-driven web applications.

Template Engines for Go

Web Applications in Production

 

 

That’s it!, Cheers!

Development Specialist, Artist and Activist
Personal Website

drbd not defined in your config (for this host) – FIX

drbd not defined in your config (for this host)

drbd not defined in your config (for this host) FIX.

 

Solution

the fix to your problem is in the .res file in /dev/drbd.d/ . check against ‘uname‘ command that the hostnames are correct.

drbd not defined in your config (for this host) - FIX

drbd not defined in your config (for this host) – FIX

 

 

that’s it.

Development Specialist, Artist and Activist
Personal Website

CentOS Clojure / Leiningen / Luminus / http-kit Installation and sample tutorial

CentOS Clojure

CentOS Clojure installation and sample tutorial.
In the following post I’ll show how to install and configure Clojure on you CentOS box with sample web server example.

Also,, weI’ll use leiningen for manage the Clojure app and http-kit for deployment.

 

CentOS Clojure Installation

First, Clojure requires only Java 1.5 or greater, if you don’t have the JDK installed yet on your CentOS box please follow this instructions by ItekBlog writer – Adam to install Oracle Java on your CentOS box.

Download Clojure

Before you continue, check the Downloads page to install the latest version.

To download Clojure use:

# if you don't have wget installed - use: yum install wget
# if you don't have unzip installed - use: yum install unzip
cd /opt
wget http://repo1.maven.org/maven2/org/clojure/clojure/1.5.1/clojure-1.5.1.zip
unzip clojure-1.5.1.zip
rm clojure-1.5.1.zip

to bring up a simple read-eval-print loop (REPL) use:

cd clojure-1.5.1
java -cp clojure-1.5.1.jar clojure.main

try:

user=> (+ 1 2 3)
6
user=> (javax.swing.JOptionPane/showMessageDialog nil "Hello World")

Try Clojure Online

  • TryClojure provides a brower-based Clojure REPL
  • Himera provides a browser-baed ClojureScript REPL

Community Resources

Community volunteers maintain Getting Started documentation for a number of different tools and approaches.

 

Leiningen

Leiningen is the easiest way to use Clojure. With a focus on project automation and declarative configuration, it gets out of your way and lets you focus on your code.

Installing Lieningen

to install Lieningen you need to download the lein script place it on your $PATH (eg. ~/bin) and set it to be executable:

cd ~/bin
wget https://raw.github.com/technomancy/leiningen/stable/bin/lein
chmod a+x ~/bin/lein

you can read the tutorial by running lein help tutorial.

The tutorial is the best place to start. It does not cover learning the language itself; good Clojure documentation can be found.

Running lein help faq will get you the FAQ. Documentation for each individual task is available via lein help $TASK. You can also see the sample project.clj file containing a reference of most project settings by running lein help sample.

 

Creating a Project

Creating a new project is easy:

cd ~/
lein new app my_first_app
cd my_first_app
find .

In this example we’re using the 

1
app

 template, which is intended for an application project rather than a library. Omitting the app argument will use the default template, which is suitable for libraries.

Directory Layout

The output of the find command is:

leiningen_find

Here you’ve got your project’s README.md file, .gitignore file for you all GIT users, a src/ directory containing the code, a test/ directory, and a project.clj file which describes your project to Leiningen. The src/my_stuff/core.clj file corresponds to the my-stuff.core namespace.

Running Code

let’s start our code running:

lein run

 

centos clojure

centos clojure

 

For extended information and documentation about Leiningen and the REPL Read here.

 

FAQ: Set LEIN_ROOT to disable this warning.

leiningen_error

 

If you want to run LEIN using root, you should add to your ~/.bash_profile :

export LEIN_ROOT="Something"

rem

ember to touch the file:

. ~/.bash_profile

 

Frameworks

Luminus

Luminus is a micro-framework based on a set of lightweight libraries. It aims to provide a robust, scalable, and easy to use platform. With Luminus you can focus on developing your app the way you want without any distractions.

create a new project:

    lein new luminus myapp
    cd myapp
    lein ring server

the app is now available at 

1
localhost:3000

luminus-welcome

 

Clojure Deployment

When you’re ready to deploy your app, you have many web servers such as: nginx, http-kitimmutant, tomcat, JBossPallet, GlassFish, Jetty, Netty, Grizzly, etc.

 

using nginx

You can use nginx-clojure to run your clojure project inside of nginx server.

In Clojure web server benchmarks, this server achieved the highest performance.

20140121-14-30

read this tutorial for more information about nginx/clojure implementation.

 

using Tomcat

To install Tomcat server follow those steps.

You need to package the application as a WAR archive, to do that run:

lein ring uberwar

then simply copy the resulting myapp-0.1.0-SNAPSHOT-standalone.war to the webapps folder on Tomcat, eg:

cp target/myapp-0.1.0-SNAPSHOT-standalone.war ~/tomcat/webapps/myapp.war

Your app will now be avaliable at the context /myapp when Tomcat starts. To deploy the app at root context, simply copy it to webapp as ROOT.war.

 

HTTP Kit – HTTP client/server for Clojure

HTTP Kit is a minimalistefficientRing-compatible HTTP client/server for Clojure. It uses a event-driven architecture to support highly concurrent a/synchronous web applications. Feature a unified API for WebSocket and HTTP long polling/streaming

<div class="codecolorer-container text railscasts" style="overflow:auto;white-space:nowrap;width:555px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer">          [http-kit "2.1.16"] ; Add to your project.clj.</div></td></tr></tbody></table></div>

Check this great example of a websockets app with Clojure and http-kit.

 

That’s It!

 

Cheers!,

Development Specialist, Artist and Activist
Personal Website