Toggling php versions in Apache

Posted on Monday 13 March 2006

I've been testing amfphp with PHP4 and PHP5 lately (PHP5 supports try..catch so the error handling is different), and got tired of switching between both manually, so I whipped up a little python script to toggle php versions:


import shutil;

f = file("C:\Program Files\Apache Group\Apache\conf\httpd.conf")
content = f.read()
php4 = False
if content.find("#LoadModule php4") != -1:
        php4 = True
        content = content.replace("#LoadModule php4", "LoadModule php4")
        content = content.replace("LoadModule php5", "#LoadModule php5")
        content = content.replace("#AddModule mod_php4.c", "AddModule mod_php4.c")
        content = content.replace("AddModule mod_php5.c", "#AddModule mod_php5.c")
else:
        content = content.replace("LoadModule php4", "#LoadModule php4")
        content = content.replace("#LoadModule php5", "LoadModule php5")
        content = content.replace("AddModule mod_php4.c", "#AddModule mod_php4.c")
        content = content.replace("#AddModule mod_php5.c", "AddModule mod_php5.c")
       
f.close()

f = file("C:\Program Files\Apache Group\Apache\conf\httpd.conf", "w")
f.write(content)

if php4:
        shutil.copy("C:\php4\php.ini", "C:\windows\php.ini")
else:
        shutil.copy("C:\php\php.ini", "C:\windows\php.ini")
 

I have php 5 installed in c:\php and php 4 installed in c:\php4 with their respective php.ini files. Hope it can be of some use.


WordPress database error: [Can't open file: 'wp_comments.MYD'. (errno: 145)]
SELECT * FROM wp_comments WHERE comment_post_ID = '191' AND comment_approved = '1' ORDER BY comment_date

No comments have been added to this post yet.

Leave a comment




Your e-mail address is never displayed. If you run into issues with SpamKarma blocking you, email me at $patrick->5etdemi(com)


RSS feed for comments on this post | TrackBack URI