2012-01-23

Getting LAN IP address of local computer

Using Python to get the LAN IP address of the local computer:

If we use:

import socket
socket.gethostbyname('localhost')

we will get '127.0.0.1' which may not be what we want due to the presence of the hosts file.

We could use:

import socket
socket.gethostbyname(os.environ['COMPUTERNAME'])

we will get something like '192.168.0.xxx' which is more likely what we want.

The above code fragment works in Windows XP, may need adjustment in getting the host name in other OS.


2012-01-19

Install Apache 2.2 in Fedora 15

I would like to install Apache (2.2) in Fedora 15, and found this post useful.  In short, these are the steps:
  1. sudo yum install httpd
  2. sudo chkconfig httpd on (run on startup)
  3. /etc/init.d/httpd start (start service now)
  4. netstat -tulpn | grep :80 (verify)
The netstat flags are:

-t tcp
-u udp
-l listening
-p program
-n numeric

And the Apache config file is here:

/etc/httpd/conf/httpd.conf