Friday, March 13, 2015

[CentOS][Ruby]How to Change the default Sinatra listening port 4567 to a user define port in ruby applications?

Recently I have come a cross a situation where I wanted to up 3 different ruby web applications at once on the CentOS server which uses the Sinatra. When I was trying to run the first application by running the ./application1.rb, I was able to access the service in the 4567 port. While it was running I tried the second application by running ./application2.rb command. Then it gave the error regarding the port is already in used. 

So that is acceptable. Because we all know the same port can not listen to two different applications at the same time. And according to my requirement I needed to run different ruby applications at the same time. So my target was to separately define different ports to each. So that I can use them without any interruptions. So how I achieved that?? I searched the web for the required details. 
The very first thing I wanted to find out was, where these default configuration details come from. So I got the result. 

The default Sinatra configuration details are put in the base.rb file. Once I checked that I have found out that the default port was set as 4567 as shown in the following figure.


So I have checked the application1.rb file and added a new line to change the default port to a port I preferred as follows.
"set:port, 4568"
That is to overwrite the default ruby listening port by introducing custom port number. And I checked the output by running the application1.rb file. Yay !! :D. It was running with the port I have defined. So I added different ports to other files as well. And now all the services are up and running in the ports I wanted. :) Hope this will help for someone else too !!! :)


Cheers!
"do good and good will come to you!"'

Tuesday, March 10, 2015

[CentOS]How to overcome the issue of remotely access Python application running using the Flask?

Well. This is regarding an issue once you may get when you try to run a python program which uses the framework flask. :D 

Do you know about Flask??

Flask is a micro-framework for web development using python

You can read more from here: http://flask.pocoo.org/docs/0.10/

And my problem was accessing the service up and running using flask. Actually the application was up and running in the http:0.0.0.0:5000/. 

But I was unable to access it using the server ip. That is, I was unable to access it remotely. So I have surfed the web for a solution. After trying out different methods I was able to resolved my problem. And it was a simple change to the code. Just changed the call for the run method as follows. 

app.run(host='0.0.0.0')

And it worked as expected. !! So hope this will help some one else too!! :)


Cheers!
"do good and good will come to you!!"

Wednesday, March 4, 2015

[CentOS]Installing Ruby on CentOS

This time it is installing Ruby on CentOS :D. Yes. I did it. And I want to share the steps I have followed with you all !! :) :)

wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz
tar xzvf ruby-1.9.3-p0.tar.gz
cd ruby-1.9.3-p0
 ./configure
 make install

Done !! And I tried to run a ruby script and it gave the error related to permission to the file.
So I have changed the permission for that file as folows,

chmod +x hello.rb

Cheers!
"do good and good will come to you!"

Tuesday, March 3, 2015

[CentOS]Installing mysql-server

Lets talk about how to install mysql-server on CentOS. I wanted to install it and following describes the steps I have followed. 

sudo yum install mysql-server

But it gave an error :(

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again

I didn't give up. I have checked the reasons for why I was getting that particulate error and found out that, it was because outdated certificate. So I used the command for upgrading the certificate. 

sudo yum upgrade ca-certificates --disablerepo=epel

And tried the previous command for installing again and it worked. :) I checked it by starting the mysql service like this.

sudo service mysqld start


Cheers!
"do good and good will come to you!"

[CentOS]Starting Apache server gives error -"Could not reliably determine the server's fully qualified domain name"

Did you ever come a cross a situation of getting this error??
I got :) Actually I have installed Apache on a CentOS server and I wanted to start it. So I used the following command on a Putty, i.e the SSH Client I have used to connect to the server. 

cmd -> sudo service httpd restart

output ->
Stopping httpd:                                 [  OK  ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 10.157.1.134 for ServerName
                                                           [  OK  ]

So I was unable to start the Apache server. So I checked why I got this error. And I again tired for the command httpd, to check whether the server can identify the service,

cmd -> httpd

output -> httpd: Could not reliably determine the server's fully qualified domain name, using
10.157.1.134 for ServerName
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

According to the error message I got, it pointed out the error, that is, it can not determine the domain name. So I have checked the Apache httpd.conf  file. 

cmd -> vim /etc/httpd/conf/httpd.conf

And checking through it, I have found out that there was actually no qualified server name under the section #ServerName . So I have added the server name i wanted and it was like this. 

previous -> #ServerName www.example.com:80
new -> ServerName 10.157.1.134:80

And I have tried the Apache restart command again and it  worked as expected. :) 

cmd -> /etc/init.d/httpd restart

output -> 
Stopping httpd:                                          [  OK  ]
Starting httpd:                                            [  OK  ]


Hope this will help some one else too !! :)


cheers!
"do good and good wi come to you!"




Monday, March 2, 2015

[CentOS] It is Yummy !! All about "yum" Command :D

Yes. It is new to me. It is all about the yum command. I wanted to post it here because this yum command helped me a lot recently. So that is why I am here to share my knowledge with you. You may have used it too. It is an important command for users who are working on Linux based platforms such as RHEL , CentOS.

"yum" is abbreviated from the "Yellowdog Updater, Modified". It is an open source command line package management utility for Linux operating systems using the RPM Package Manager. yum works with software repositories. And those repositories can be accessed locally or over a network connection.

1) How to use yum command for install packages?

yum [options] [command] [package ...]

eg: yum install -y nodejs

This yum install command can be used  to install the latest version of a package while ensuring that all dependencies are satisfied.

2) How to use yum command for upgrade packages?
sudo yum upgrade ca-certificates --disablerepo=epel          


You can read more on here:

Reference:

Cheers!
"do good and good will come to you!!"

[CentOs]How to find out information about the Kernal

As Software Engineers, you may come across situations of working on different Operating Systems. When you get a task of installing different software to a newly setup operating system, which is not the operating system you used to work on, you have to learn new things. So I had, and it was with CentOS, So I am here to share the things I have learnt from playing with CentOS with you. :)

What is CentOS?
Do you know about this OS? This was the first time I worked with CentOS. The name is abbreviated from "Community Enterprise Operating System". And it is a community-supported Linux distribution for enterprise class. Simply it is kind of a compatible version of Read Hat Enterprise Linux(RHEL). 

The very first thing I wanted to do was to know about the OS. Since it was a separate server, I had to use SSH client Putty for logged to the server. Then I wanted to check the information of the installed OS. And what I have found out and checked it out as follows.

1) How to find the kernel name ? 
(-s)
cmd# uname -s
Linux

2) How to find the Network node hostname ?
(-n)
cmd# uname -n
abc-vm

3) How to find the kernel release ?
(-r)
cmd# uname -r
2.6.32-220.el6.x86_64

4) How to find the kernel version ?
(-v)
cmd# uname -v
1 SMP Tue Dec 6 19:48:22 GMT 2011

5) How ti find the machine hardware name ?
(-m)
cmd# uname -m
x86_64

6) How to find the processor type ?
(-p)
cmd# uname -p
x86_64

7) How ti find the hardware platform?
 (-i)
cmd# uname -i
x86_64

8) How ti find the operating system ?
(-o)
cmd# uname -o
GNU/Linux

Hope this will help some one else too !! :)


Cheers
"do good and good will come to you!"