### configuring apache for python

http://httpd.apache.org/docs/1.3/howto/cgi.html

I did setup this in my mac/OSx, was not easy to find info on web, hence I am briefing out the flow:
1) uncomment "LoadModule cgi_module libexec/apache2/mod_cgi.so" ( for me it exists in httpd.conf )
2) edit virtual hosts file to look like this: ( for mac, it is in httpd-vhosts.conf )

AllowOverride All
Order allow,deny
Allow from all

NOTE: "/www" is where my project resides
"ExecCGI" is the option that has to be there
3) Below the directory closing, add this line: ( for mac, it is in httpd-vhosts.conf )

4) Restart apache: "sudo apachectl restart"

Now running your project should give "End of script output before headers" error in error log and 500 internal server error on web.

-> Fix for this (add the below lines on top of your index file, which is referred in first and foremost call) :
#!/usr/local/bin/python
print "Content-Type: text/html"
print
print "Hey! There? "

NOTE: Make sure you don't miss out "#!/usr/local/bin/python" as it tells apache using which environment this file is to be executed.

Other pointers are: You have to do similar stuff on the parallel lines for setting up perl or any other CGI scripts.

Also, This sets up the basic CGI mode for python; while there are some other mods are also available like "mod_python" or "fastCGI".

### Popular posts from this blog

Function TableOfContent(count As Integer)
'count is the no. of slides in ppt
Dim var As Integer
Dim i As Integer, scount As Integer
Dim strSel As String, strTitle As String, strb As String, strtemp As String, str As String
Dim arr() As String
Dim index As Integer, indexcount As Integer, slidecount As Integer
Dim summary As Slide
Dim para As Integer
Dim slideOrder() As Integer

ReDim slideOrder(count - 2)

'Collect all the IDs of the selected slides
For i = 1 To count - 2
slideOrder(i) = i + 2
Next

'Iterate over the slides in Index order
slidecount = UBound(slideOrder)
For scount = 1 To slidecount
If ActivePresentation.Slides(slideOrder(scount)).Shapes.HasTitle Then
'Build up the ToC Text
strTitle = ActivePresentation.Slides(slideOrder(scount)).Shapes("UseCase").TextFrame.TextRange.Text + ": "
str = ActivePresentation…

### How to do mass insert in redis

A basic and fairly easy way to do mass insert in redis:

Command to use: echo -e "$(cat redis_mass_insert.txt)" | redis-cli --pipe Content of file "redis_mass_insert.txt": *3\r\n$5\r\nlpush\r\n$5\r\nu:m:1\r\n$5\r\nvalu1\r\n*3\r\n$5\r\nlpush\r\n$5\r\nu:m:1\r\n$7\r\nmyvalue\r\n Result: All data transferred. Waiting for the last reply... ERR unknown command ' *2' ERR unknown command '$4'
ERR wrong number of arguments for 'echo' command
ERR unknown command '$20' ERR unknown command ' A�j d�Q;yT��ҡ �h>' NOTE: command line will show error but in actual the data is transferred and you can check it by entering in redis. Here's the snapshot of the whole procedure: To check how the command is responding: use hexdump -C Command: echo -n$'$3\r\nset\r\n$3\r\nkey\r\n$5\r\nvalue\r\n ' | hexdump -C whose output will be something like 00000000 24 33 0d 0a 73 65 74 0d 0a 24 33 0d 0a 6b 65 79 |$3..set..\$3..key|
00000010 0d 0a…

### redis server went away

It feels really awkward to see "redis: uncaught exception: Redis server went away" when it was working and suddenly this message bumps up. I faced the same situation while accessing php redis but I guess it's more generic one, more related to redis. So, here are possible solutions that I am able to find and highlighting the one which really did work for me.

1. /usr/sbin/setsebool httpd_can_network_connect=1

By default, SELinux does not allow Apache to make socket connections. So, enable the connection.

2. Try to stop the redis server and restart it again.
either of these two should work:
a) redis-cli
b) redis server

3. There might be issues with switch, try to use different switch.