Tag Archives: CentOS 6.x

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.

Continue reading

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

Continue reading

CentOS PostgreSQL Installation Tutorial – (Centos 6.x)

CentOS PostgreSQL Installation tutorial

CentOS PostgreSQL

centos postgresql :

PostgreSQL is a powerful, open source object-relational database system.
In the following tutorial I’ll show how to install PostgreSQL on your CentOS box

 

CentOS PostgreSQL Installation

We can install PostgreSQL in (at-least) two ways:

  • Using YUM
  • Compile from source

 

Install from repository

yum install postgresql-server
this will install the package postgresql-server, also: postgresql and postgresql-libs.
centos postgresql

centos postgresql

Install from source

If you want to install the latest version of PostgreSQL you should compile from source. it’s recommended for advanced users and one may argue it’s recommended too for production.

Anyway, this article from DigitalOcean covers this area well (and more). If you want to compile using source you better move to that article. If you prefer or installed using repository (yum), continue…

 

PostgreSQL Service

if you’ll try to start PostgreSQL using the service command, you will see an error tells you must init the db first and create the db files in: /var/lib//pgsql/data

posgresqlerror

so,

to init on centos postgresql service use:

service postgresql initdb

posgreinit

This created a data folder in /var/lib/pgsql. You can’t run this command again without deleting first this folder (and all your data).

Also, when you called the initdb command above from RedHat’s init script configured permissions on the database. These configuration settings are in the pg_hba.conf file inside the data folder.

By default all permissions are ‘Ident’,

pgsql-ident

means the only user that can get in initially is user “postgres”, so if you’ll try ‘psql’ from root you’ll get error:

psql: FATAL: Ident authentication failed for user “root”

If you want to login and use postgres with other users than `postgres` you can change the permissions method in pg_hba.conf. change from ‘ident’ to ‘md5’ is recommended.

If you want to use phpPgAdmin (described later) you should change from ‘Ident’ to ‘md5’ or else it won’t login to your system.

 

Set port and Listen Addresses

If you need to change the default port (5432 by default) and Listen Addresses (localhost by default), you can set those vars inside the postgresql.conf inside /var/lib/pgsql/data folder.

#listen_addresses = 'localhost'
#port = 5432

 

Start service

and then, to start on centos postgresql service use:

service postgresql start

postgrestart

to make centos postgresql load on boot use the chkconfig command as follows:

chkconfig postgresql on

 

and That’s it!

 

What next?

 

Managing from Command line

login to postgres

As I mentioned, default setup has ident authentication means the only user that can get in initially is user “postgres”, so if you haven’t changed permissions scheme you should su to postgres before.

to start ‘psql’ as postgres:

# change user to postgres
su - postgres
# start psql manager
psql
# CTRL + D twice to exit both psql and su.

# You can also short the two commands into:
# su postgres -c psql

Add (or create) a user with permission to specific database?

Read this great tutorial.

 

PhpPgAdmin

PostgreSQL visual interface similar to phpMyAdmin? – in short, if you know phpMyAdmin and want phpPgAdmin, you need to add the EPEL repositories, Apache (yum install httpd) and then install using:

If your permissions scheme is currently ‘Ident’ you might need to change that to ‘md5’ as PhpPgAdmin requires it.

yum install phpPgAdmin

Then visit in your browser: http://localhost/phpPgAdmin

centos phppgadmin
centos phppgadmin

Remote connection

Edit /etc/httpd/conf.d/phpPgAdmin.conf if you want to allow access remotly and restart httpd (service httpd restart).

do you use pgsql, postgres, root, administrator as login or even user without password?
if you do, set the $conf[‘extra_login_security’] entry to false in your et/phpPgAdmin/config.inc.php.

 

Change default Postgres user password

If you really want to use the “postgres” role, make sure you set it up a password and $conf[‘extra_login_security’] is false.

use the command:

passwd postgres

to change the system user password and

ALTER USER Postgres WITH PASSWORD 'password';

That alters the password for within the database. To change the password inside Postgresql. there is also short code (inside psql):

\password

Which will ask from you a new password to set.

 

 

Cheers!

CentOS xrdp HowTo

Overview

xrdp is a free open-source remote desktop server for Linux.
Installing xrdp on CentOS might be a little tricky since CentOS repositories does not contain the xrdp package.
Even the EPEL repository (Extra Packages Enterprise Linux) only contains an old version of xrdp.
Continue reading

LuaJIT

CentOS LuaJIT Installation instructions

centos luajit installation instructions

centos luajit

centos luajit installation instructions – In the following tutorial I will show you how to install and use the LuaJIT Compiler on your CentOS box.

Before you continue you should already know what is Lua and JIT Compiler.

 

What is LuaJIT?

LuaJIT is a Just-In-Time Compiler (JIT) for the Lua programming language.

LuaJIT has been successfully used as a scripting middleware in games, appliances, network and graphics apps, numerical simulations, trading platforms and many other specialty applications. It scales from embedded devices, smartphones, desktops up to server farms. It combines high flexibility with high performance and an unmatched low memory footprint.

LuaJIT has been in continuous development since 2005. It’s widely considered to be one of the fastest dynamic language implementations. It has outperformed other dynamic languages on many cross-language benchmarks since its first release — often by a substantial margin.

LuaJIT is Copyright © 2005-2014 Mike Pall, released under the MIT open source license.

from LuaJIT website

 

Prerequisities

you need to install a package for GCC before compiling LuaJIT, you can do that by:

yum install gcc

or better, install the development tools:

yum groupinstall “Development Tools”

 

centos luajit installation instructions

Check the LuaJIT download page to check if newer version available. The next insructions are for the latest stable version currently available – LuaJIT-2.0.2

cd /opt
wget http://luajit.org/download/LuaJIT-2.0.2.tar.gz
tar -zxvf LuaJIT-2.0.2.tar.gz
cd LuaJIT-2.0.2
make && make install
# or sudo make install if you are not 'root'

Option 2: using git

OPTIONALLY, you can install LuaJIT using GIT. choose this method only if you want to be updated with the latests patches and updates and your don’t care about the risk of bugs. (NOT FOR PRODUCTION) 

cd /opt
git clone http://luajit.org/git/luajit-2.0.git
cd luajit-2.0
make && make install 
# or sudo make install if you are not 'root'
centos luajit

centos luajit

Running LuaJIT

That’s it. you have luajit installed.

consider the file ‘test.lua’:

print ("Hello, world!")

You can run (interpret) the file using

luajit test.lua

Save bytecode to test.out

luajit -b test.lua test.out
luajit test.out

more information about running luajit here.

 

 

That’s it! you have centos luajit installed.

Cheers!.

VMWare Workstation start on boot CentOS

CentOS Gunicorn installation instructions for newbies

centos gunicorn installation instructions

centos gunicorn

centos gunicorn : In this simple tutorial I’ll explain how to install and run Gunicorn python server on your CentOS machine.

This tutorial is meant for Centos 6.4 and above but it should work on any CentOS 6.x release.

 

What is gunicorn?

From: Gunicorn – Python WSGI HTTP Server for UNIX:

Gunicorn ‘Green Unicorn’ is a Python WSGI HTTP Server for UNIX. It’s a pre-fork worker model ported from Ruby’s Unicorn project. The Gunicorn server is broadly compatible with various web frameworks, simply implemented, light on server resources, and fairly speedy.

 

Installation

Python

before you going to install the centos gunicorn server you need to insure you have the python interperter installed (it should be, as it’s installed by default on the latest CentOS releases). to check that you have python use the command:

python

command not found of course means you need to install python now.

 

Install python

first make sure your have python installed. Simple as:

yum install python

test python by typing: “python” and you should see something similar to:

python

(Ctrl+D to exit)

 

Gunicorn

Next we need to install gunicorn. for this we have (as always) several choices.

1) Using YUM. I personally don’t recommend it. I know some are happy to use the system packaging management wherever possible, but as for python I don’t think it’s the way to go.

To install gunicorn using yum:

yum install python-gunicorn

2) Using easy_install. using easy_install is a better choice for my taste to install python packages. this is how you install gunicorn using easy_install, but I recommend installing gunicorn using PIP as I will show next…

yum install python-setuptools
easy_install gunicorn

3) Using PIP: This is my RECOMMENDED way of installing gunicorn. to install PIP you actually need easy_install so the commands are:

yum install python-setuptools
easy_install pip
pip install gunicorn

Virtualenv

I can’t recommend enough to start working with virtualenv from beginning. At some point in the future, if you are going to consist with python coding, you are going to use the ‘pip update’ command to update some or all your libraries and then expect your python application to stop working.

Python libraries, as any open source library, have the freedom to sacrifice backward compatibility for new features, performance or redesign.

Virtualenv is a python virtual environment tool to ensure that your python applications will work as expected as long you don’t deliberately update some or all of the dependency libraries for that virtual environment specifically.

To install virtualenv (and virtualenvwrapper) and learn the basics read this tutorial. then create your virtual environment and install gunicorn to that environment.

# after you've install pip, virtualenv and virtualenvwrapper
mkproject myapp
workon myapp
pip install gunicorn

 

Running Gunicorn

Basic usage:

$ gunicorn [OPTIONS] APP_MODULE

so for the following myapp.py file:

# -*- coding: utf-8 -

def app(environ, start_response):
    data = 'Hello, World!\n'
    status = '200 OK'
    response_headers = [
        ('Content-type','text/plain'),
        ('Content-Length', str(len(data)))
    ]
    start_response(status, response_headers)
    return iter([data])

just run:

gunicorn -w 4 myapp:app
# Sample output
[INFO] Arbiter booted
[INFO] Listening at: http://127.0.0.1:8000
[INFO] Worker spawned (pid: 16801)
[INFO] Worker spawned (pid: 16802)
[INFO] Worker spawned (pid: 16803)
[INFO] Worker spawned (pid: 16804)
centos gunicorn

centos gunicorn

This command starts gunicorn with 4 workers on port 8000. feel free to experiment and customize the command with additional parameters.

There also command line for using Django <1.4 and Paster. read more here.

Read more about configuring Gunicorn and configuration files.

 

Deploying Gunicorn

on deployment, It’s strongly recommended to use Gunicorn behind a proxy server.

nginx

I personally prefer nginx but it’s not your only choice.

If you want to install nginx on your CentOS machine follow this installation instructions.
use this script (at github) to configure your nginx to pass request to the gunicorn process

 

Monitoring and Logging

Usally you’d want the gunicorn to be run in the background, load on boot and restart on errors. you want also the ability to monitor that process.

There are several tools for that.job, including: Supervisord, Gafferd, runit and many more…  choose what fits you best. here you have examples for monitoring gunicorn using those tools.

 

That it. enjoy playing with your centos gunicorn setup.