Category Archives: Linux/Unix

G-WAN

CentOS G-WAN server installation instructions

CentOS G-WAN Server

CentOS G-WAN server

G-WAN is a web server with scripts in Asm, C, C++, C#, D, Go, Java, Javascript, Lua, Objective-C, Perl, PHP, Python, Ruby and Scala.

G-WAN better uses CPU Cores
to make the Internet of Things
fly thousand times higher !

Leverage legacy servers and
low-consumption CPUs to
do more with less!

G-WAN works best on Linux distributions like Debian or CentOS, both of which offer ‘Desktop’ and ‘Server’ flavors.

 

CentOS G-WAN server installation instructions

CentOS G-WAN installation instructions

 

Installation

choose a location for your installation. for demonstration purposes we’ll install G-WAN to /opt

cd /opt
wget http://gwan.com/archives/gwan_linux64-bit.tar.bz2
tar -xjf gwan_linux64-bit.tar.bz2; cd gwan_linux64-bit
sudo ./gwan
centos g-wan

centos g-wan

use the 32bit version instead (http://gwan.com/archives/gwan_linux32-bit.tar.bz2) if you need.

Test

Then, type http://localhost:8080/ in your browser

centos g-wan

centos g-wan server default homepage

and play with the/gwan/.../csp samples.

 

Programming Languages

If you want to install more Programming Languages read the FAQ – Setup of Programming Languages

To install all 15 languages using the bash script donated by generous user on many Linux distributions (Debian, LinuxMint, CentOS, Fedora, RedHat, Manjaro, Arch Linux and Bridge) use:

cd /opt
wget http://www.as2.com/linux/tools/G-WAN_full-install.tar.bz2
tar -xjf G-WAN_full-install.tar.bz2
./G-WAN_full-install

The installation menu is available in English, German, French and Spanish!

 

Service mode

To start G-WAN as a service (make it start automatically at boot time) use this instructions

with one exception for CentOS in the manual:

instead of:

sudo update-rc.d gwan defaults 95 5

use:

sudo chkconfig gwan on

and you don’t need to restart.

 

What’s next?

check the API and Frequently Asked Questions.

Stackoverflow lists many more examples and will let you search for replies to common questions.

 

And that’s it. you have G-WAN server.

iptables examples on CentOS

Overview

“iptables is a user space application program that allows a system administrator to configure the tables provided by the Linux kernel firewall (implemented as different Netfilter modules) and the chains and rules it stores.
Different kernel modules and programs are currently used for different protocols; iptables applies to IPv4, ip6tables to IPv6, arptables to ARP, and ebtables to Ethernet frames.”

In this tutorial I will give a few essential examples of how to use iptables on CentOS
Continue reading

VMWare Workstation start on boot CentOS

SSL handshake failed: SSL error: Key usage violation in certificate has been detected CentOS

SSL handshake failed: SSL error: Key usage violation in certificate has been detected CentOS

Overview

SSL handshake failed: SSL error: Key usage violation in certificate has been detected.

SSL handshake failed: SSL error: Key usage violation in certificate has been detected CentOS.

SSL handshake failed: SSL error: Key usage violation in certificate has been detected CentOS.

 

Fix

You may experience the issue if both of the following conditions are met:

  • VisualSVN Server has a self-signed certificate applied and
  • Subversion client is built against the GnuTLS library.

GnuTLS library is an open-source alternative to OpenSSL. Most Subversion clients for Windows are built against OpenSSL and are not affected by this issue. While some Subversion packages (available mostly on Linux-based operating systems – The subversion that comes with EL 6 is linked against GnuTLS which is a change from older releases which linked against OpenSSL) are built against GnuTLS and are affected.

The server is using an SSL cert was created with the ‘key usage’ extension, and the client is using the gnutls SSL library which doesn’t understand the extension. The solution is either to have the client use the openssl library or to have the server use a cert that doesn’t use the ‘key usage’ extension.

It’s recommended to fix the issue on your server side, but you can workaround it from the client side too.

 

Fix (Server side)

Here is what visualsvn.com say:

It’s not recommended to use a self-signed certificate in a production environment. We advise to use a certificate issued by your domain or a third-party certificate authority instead of a self-signed one.

If you have to use a self-signed certificate please follow the instruction to generate a cerificate without specifying ‘Key Usage’ extension:

Add the following registry value to the Windows registry:

for 32-bit system:

[HKEY_LOCAL_MACHINE\SOFTWARE\VisualSVN\VisualSVN Server]
“CreateGnuTLSCompatibleCertificate”=dword:00000001

for 64-bit system:

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\VisualSVN\ VisualSVN Server]
“CreateGnuTLSCompatibleCertificate”=dword:00000001

Start VisualSVN Server Manager.
Go to Action | Properties | Certificate.
Click Change certificate… and follow the wizard instructions to generate a new self-signed certificate.

The certificate will be generated without the ‘Key Usage’ extension and will be compatible both with GnuTLS and OpenSSL.

 

Fix (Client side)

The options for client side fix are:

 

That’s it.

VMWare Workstation start on boot CentOS

VMWare Workstation start on boot CentOS

vmware workstation start on boot centos

If you are like me, using VMWare workstation on Linux (CentOS 6.4), and you want to start your virtual machines on boot, I have the answer.

Prerequisities

  • CentOS 6.x. – although the vmrun command may be working in other distributions too.
  • VMWare Workstation 4.0+

 

 VMWare Workstation start on boot CentOS

VMWare Workstation start on boot CentOS

 

The Solution

Edit rc.local

add to the end of the following file:

/etc/rc.d/rc.local

the following:

vmrun -T ws start /path/to/machine.vmx nogui

create new line for each machine you want to start on boot.

 

that’s it! that how you run vmware workstation start on boot centos

 

That’s it.

Django CentOS 6.4 installation instructions for noobs.

Django Centos 6.4 installation instructions for noobs.

So you want to build your first django centos 6.4 based web site? This is quite easy to install and configure. I’ll cover how to install Python/Django on your centos.

Django Centos

Prerequisite

  • CentOS 6.4 (For the matter of fact, this tutuorial is good for all the CentOS 6.x series)
  • Apache (httpd)

 

What is Python?

Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Its syntax is said to be clear and expressive.” from Wikipedia.

Visit http://www.python.org/

 

What is Django?

“Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.” from https://www.djangoproject.com/

Installing Python

Prerequisites

you may need the EPEL repositories for Centos.

1
2
3
4
cd /opt/
wget http://mirrors.nl.eu.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6-8.noarch.rpm
rm epel-release-6-8.noarch.rpm -f
cd /opt/
wget http://mirrors.nl.eu.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6-8.noarch.rpm
rm epel-release-6-8.noarch.rpm -f

 

Installation Process

Simple as:

1
yum install python
yum install python

test python by typing: “python” and you should see something similar to: (CTRL+D to exit)

At the time of writing (September 30 2013), the version of python@EPEL is 2.6.6

Django works with any Python version from 2.6.5 to 2.7. It also features experimental support for versions 3.2 and 3.3. All these versions of Python include a lightweight database called SQLite so you won’t need to set up a database just yet unless you need other SQL

 

Installing SQL

Django works with several DB engines. for simplicity, Install SQLite:

yum install sqlite

If you need other SQL Server else then SQLite,  you can follow:
MySQL/MongoDB/CouchDB on RHEL/Centos 6.3
If you don’t need SQL and you installed Python 2.5 or later, you can skip this step for now.

 

 

 

 

Installing Django

You can install using EPEL repositories any yum (like in the old article I wrote), but I recommend to use the easy_install method from the python-setuptools package, which I’ll show next:

1
2
yum install python-setuptools
easy_install django
yum install python-setuptools
easy_install django

 

Testing Django

Test Django by typing python on your command and then:

1
2
import django
print django.get_version()
import django
print django.get_version()

python-django-1.5.4

As you can see, the RPM version is version 1.5.4, while the current release in the EPEL version is 1.3.1. Internationalization: in template code is not available in 1.3.1 for example but only from Django 1.4

 

 

Creating Project

From the command, cd into a directory where you’d like to store your app, then run the following command:

1
2
django-admin.py startproject mysite
cd mysite
django-admin.py startproject mysite
cd mysite

 Note: if you are installing Django using EPEL repos, the command will be django-admin and not django-admin.py.

Starting Server

1
python manage.py runserver
python manage.py runserver

You’ve started the Django development server, a lightweight Web server – easier to startwithout having to deal with configuring a production server — such as Apache — until you’re ready for production.

Browse to http://127.0.0.1:8000/ with your Web browser. You’ll see a “Welcome to Django” page. It worked!

To change port:

1
python manage.py runserver 8080
python manage.py runserver 8080

If you need to start the server to answer not only locally, use:

1
python manage.py runserver 0.0.0.0:8000
python manage.py runserver 0.0.0.0:8000

 

Remember: Apache loads Django environment when starting and keep running it even when source is changed! I suggest you to use Django ‘runserver’ (which automatically restarts on source code changes) in development sessions, unless you need some Apache-specific features.

 

Configure more…

Config Database

Edit mysite/settings.py. It’s a normal Python module with module-level variables representing Django settings.

Help here.

 

Django using Apache

To run your Django application inside apache – use either mod_python or mod_wsgi, Support for mod_python will be deprecated in a future release of Django. If you are configuring a new deployment, you are strongly encouraged to consider using mod_wsgi or any of the other supported backends.

 

OPTION A: Install mod_python (NOT recommended)

For this to work, you must have apache installed and configured.

1
yum install mod_python
yum install mod_python

python using mod_python

you need to configure you apache/VirtualHost to:

    AddHandler mod_python .py
    PythonHandler mod_python.publisher | .py
    AddHandler mod_python .psp .psp_
    PythonHandler mod_python.psp | .psp .psp_
    PythonDebug On</pre>
[/code]

 
<h3>Testing mod_python</h3>
Create a '<em>test.py'</em> file in your apache server. put inside:
[code lang="py"]<% req.write("Hello World!") %>[/code]

and browse to www.your.server/test.py and you should see the "Hello World!" there.
<h3>Django using mod_python</h3>
Edit your <tt>httpd.conf</tt> file:

[code lang="apache"]
<pre><Location "/mysite/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE mysite.settings
    PythonOption django.root /mysite
    PythonDebug On
</Location>

read more…

 

 

Option B: Install mod_wsgi (RECOMMENDED)

Deploying Django with Apache and mod_wsgi is the recommended way to get Django into production.

1
yum install mod_wsgi
yum install mod_wsgi

 

to use mod_wsgi, create an apache folder inside your project and create a django.wsgi file:

import os, sys
sys.path.append('/var/www/django')
sys.path.append('/var/www/django/mysite')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

 

and configure your apache with:

<VirtualHost *:80>

ServerName www.example.com
ServerAlias www.example.com
WSGIScriptAlias / /var/www/django/mysite/apache/django.wsgi

# Alias /robots.txt /var/www/django/mysite/static/robots.txt
# Alias /favicon.ico /var/www/django/mysite/static/favicon.ico
Alias /static/admin/ /usr/lib/python2.6/site-packages/django/contrib/admin/media/
Alias /static/ /var/www/django/mysite/static/
Alias /media/ /var/www/django/mysite/media/

<Directory /var/www/django/mysite>
Order allow,deny
Allow from all
</Directory>

<Directory /var/www/django/mysite/media>
Order deny,allow
Allow from all
</Directory>

<Directory /var/www/django/mysite/static>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>

 

read more on: multiple django sites with apache & mod_wsgi

 

 

That’s it!

 

You’ve Python / Django installed on your Centos 6.4 and a new project template waiting for you to work on.

 

Continue reading…

* this article is an edited version of an older article.

Setup BIND DNS Server on CentOS 7

VMware Tools CentOS 6.x easy installation guide.

VMware Tools CentOS 6.x easy installation guide.

Prerequisities

if you have installed new setup of centos or you haven’t installed yet, you need make, gcc, kernel-devel..

Continue reading

VMWare Workstation start on boot CentOS

CentOS RPMForge Installation Instructions (for Centos 6.x)

CentOS RPMForge Installation Instructions (for Centos 6.x)

Overview

If you want to add the RPMForge repo to your CentOS, use the following instructions

 

Downloading RPMForge repo

cd /tmp
# for 32 bit:
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm
# for 64 bit:
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

Note: Visit here to see if newer version exist.

Installing RPMForge

rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt

# for 32 bit:
rpm -i rpmforge-release-0.5.3-1.el6.rf.i686.rpm
# for 64 bit:
rpm -i rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

yum clean all

Open Extra Repo

If you want, you can enable the extra repo using:

cd /etc/yum.repos.d

edit using vi/vom/mc rpmforge.repo:
change the enabled flag to enabled=1 in the section [rpmforge-extras].

 

Update all

yum update

 

That’s it!

VMWare Workstation start on boot CentOS

Update Git CentOS – to version 1.7.11+ (on CentOS 6.x)

Update Git Centos – to version 1.7.11+ (on CentOS 6.x)

Overview

If you want to update your Git to newer version then on CentOS repository, use the following instructions

 

Downloading RPMForge repo

cd /tmp
# for 32 bit:
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm
# for 64 bit:
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

Note: Visit here to see if newer version exist.

Installing RPMForge

rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt
# for 32 bit:
rpm -i rpmforge-release-0.5.3-1.el6.rf.i686.rpm
# for 64 bit:
rpm -i rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

Open Extra Repo

yum clean all

cd /etc/yum.repos.d

edit using vi/vom/mc rpmforge.repo:
change the enabled flag to enabled=1 in the section [rpmforge-extras].

 

Update Git

yum update git

yum provides git will help you see all versions available.

git –version

Will show you have the new release installed. (1.7.11.3 for me)

 

That’s it!

Copy SSH public key to another server instructions

copy ssh public key

Prerequisities

You need to have a public key. If you haven’t generated keys before use:

ssh-keygen -t rsa

copy ssh public key is very simple. there are some ways to achieve this:

Using ssh-copy-id (recommended)

ssh-copy-id user@host

with this very simple command you can copy your public key to any user@host combination

Using scp

scp .ssh/id_rsa.pub user@host2:.ssh/authorized_keys

cd ~/ before.

The different is that scp will create a new file called authorized_keys while ssh-copy-id will add to id.

Python vs PyPy installation and comparison (on Centos 6.x)

Python vs PyPy

in this article: Python vs PyPy I’ll explain how-to install both compilers (Python (CPython) and PyPy) on CentOS and the difference between them.

Requirements for examples:

  • Centos 6.x

 

Overview

The Download section of the Python official website (python.org) include list of several Alternative Implementations for python complier. some of them for Linux, some for Windows (.NET) and others.

I am going to review the default Python compiler vs PyPy on my CentOS 6.x machine.

 

python-logo

Python (nicknamed CPython)

Installation

yum install python

From Official website:

Python is a programming language that lets you work more quickly and integrate your systems more effectively. You can learn to use Python and see almost immediate gains in productivity and lower maintenance costs.

Python (nicknamed CPython) is the default Python Compiler you get with you installing Python.

Example

Create a file named ‘example.py‘ and fill it with:

print 'Hello, world!'

and type on bash:

python example.py

Note: you can also insert the following line as the first line in your .py file and then chmod +x this file to execute it as script:

#!/usr/lib/env python
print “Hello, world!”

and then on bash:

chmod +x example.py

and you can run the script (code) using:

./example.py

 

 

pypy-logo

PyPy

fast python implementation with a JIT compiler (generate native code on the fly) written in RPython and currently translated partly to C.
Arguments against PyPy compiled in Python are everywhere, but when C compiler gcc is implemented in C, is there any reason for the Python compiler to not be written in Python?

From Wikipedia:

PyPy is a Python interpreter and just-in-time compiler. PyPy focuses on speed, efficiency and compatibility with the original CPython interpreter.[1]

PyPy started out as a Python interpreter written in the Python language itself. Current PyPy versions are translated from RPython to C code and compiled. The PyPy JIT compiler is capable of turning Python code into machine code at run time.

 

Mission

The mission of PyPy is:

We aim to provide:

  • a common translation and support framework for producing implementations of dynamic languages, emphasizing a clean separation between language specification and implementation aspects. We call this the RPython toolchain.
  • a compliant, flexible and fast implementation of the Python Language which uses the above toolchain to enable new advanced high-level features without having to encode the low-level details. We call this PyPy.

By separating concerns in this way, our implementation of Python – and other dynamic languages – is able to automatically generate a Just-in-Time compiler for any dynamic language. It also allows a mix-and-match approach to implementation decisions, including many that have historically been outside of a user’s control, such as target platform, memory and threading models, garbage collection strategies, and optimizations applied, including whether or not to have a JIT in the first place.

 

How can it possibly beat CPython?

Manual memory management (which is what CPython does with its counting) can be slower than automatic management in some cases.

Limitations in the implementation of the CPython interpreter preclude certain optimisations that PyPy can do (eg. fine grained locks).

The JIT. Being able to on the fly confirm the type of an object can save you the need to do multiple pointer dereferences to finally arrive at the method you want to call.

 

Installation

yum install pypy

 

Using PyPy

To use pypy instead of your default CPython compiler you need to run your .py file with the pypy compiler.

to use pypy compiler you type at bash:

and type on bash:

pypy myapp.py

 

Summary

Python compiler (CPython) is the default and probably the safe choice so most python applications and modules will work; where PyPy can break some.

You should play with them both. Install them both on your CentOS and test / benchmark your applications using both compilers.

PyPy can rebust your web applcations (or any other code).

For example, Django app can be run on top of PyPy, with drawbacks.

 

Read more…