forum.vmspython.org Forum Index forum.vmspython.org
Forum system
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Django w/ Apache on VMS using Flup

 
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS
View previous topic :: View next topic  
Author Message
RonPeters



Joined: 18 Sep 2008
Posts: 9

PostPosted: Fri Nov 04, 2011 11:36 pm    Post subject: Django w/ Apache on VMS using Flup Reply with quote

Hi JFP!

Thanks for all the work you have contributed with the Python 2.7.2 release for OpenVMS!

I was wondering if it would be possible for you to include FLUP into your baseline. It's easy enough to install manually but integrating it into your baseline would make it almost effortless in getting Django to work with Apache using FastCGI https://sites.google.com/a/johndapps.com/www/fastcgionopenvms

Getting Django to work with FastCGI would only take the editing of 2 lines in django_root:[django.django.utils]daemonize.py
line 4 if os.name == 'NOposix':
line 41 os.chdir('/where/your/django/appis')


Thanks again!
/ARon
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 633

PostPosted: Sat Nov 05, 2011 9:32 am    Post subject: Reply with quote

Hello,

Thanks for the feedback, I agree that to be able to use Django with FastCGI would be interesting for those who can't deploy WASD.

I have, clone the mercurial repository of flup-server.

Do I have to, just, include in the flup tree into the VMS baseline without any patch and it work ?

If yes I will include it, if not can you provide the necessary patches ?


Regards,

JF
Back to top
View user's profile Send private message Send e-mail Visit poster's website
RonPeters



Joined: 18 Sep 2008
Posts: 9

PostPosted: Sat Nov 05, 2011 8:17 pm    Post subject: Reply with quote

Hi Jfp,

There are no Patches that are needed for Flup to work. It can be included as-is.

Thanks!,

/ARon
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 633

PostPosted: Mon Nov 07, 2011 12:19 pm    Post subject: Reply with quote

I have added flup and put online update of the kits and LD images.

Does it mean that you have try Django on OpenVMS using Apache?

I'm very interesting with any feedback.

JF
Back to top
View user's profile Send private message Send e-mail Visit poster's website
RonPeters



Joined: 18 Sep 2008
Posts: 9

PostPosted: Tue Nov 08, 2011 10:41 pm    Post subject: Reply with quote

I've d/l and tested your latest Python LD disk and Django works great with FastCGI through Apache. You can probably use it as well with WASD.

As mentioned before you do need to modify django_root:[django.django.utils]daemonize.py so it doesn't use os.fork() but that is only 2 small changes.

Code:

line 4 if os.name == 'NOposix':     
line 41 os.chdir('./')    # Any Directory   ./  will work fine.  Just needs to fake a dir


Then I have created a small com file that is run as a Detached Process to run the Django_FastCgi instance.

Code:

create django_root:[vms]django_fastcgi.com
$ @python_vms:setup
$ STOP DJANGO_FCGI
$ SET PROC/NAME="DJANGO_FCGI"
$ python /your/django/app/manage.py runfcgi method=threaded deamonize=false host=127.0.0.1 port=8008


Code:

RUN/DETACH/input=django_root:[vms]django_fastcgi.com/OUTPUT=apache$common:[logs]django_fcgi.log SYS$SYSTEM:LOGINOUT


Modify httpd.conf to Load mod_fastcgi.exe and create Re-rewrite rule for Django

Code:

LoadModule fastcgi_module           modules/mod_fastcgi.exe       

FastCGIExternalServer   /apache$root/htdocs/django.fcgi -host 127.0.0.1:8008

<VirtualHost *:80>
    ServerName django.server.com
    DocumentRoot /apache$root/htdocs
    RewriteEngine On
    RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^/(.*)$  /django.fcgi/$1 [QSA,L]
    ErrorLog logs/djagno-error_log
    CustomLog logs/django-access_log common   

</VirtualHost>



Restart Apache and everything should work Smile Every time a change is made to Django .py files you do need to "restart" the django_fastgi process. For that I just created an SYMBOL
Code:

touch == "RUN/DETACH/input=django_root:[vms]django_fastcgi.com/OUTPUT=apache$common:[logs]django_fcgi.log SYS$SYSTEM:LOGINOUT"



I have found using FastCGI for Django to be faster and more reliable then using mod_wsgi on Apache for VMS. I was able to compile mod_wsgi successfully after modifying some source code using Vouters instructions as a guide however found it to be slow for Django. Of course it could have just been that hacks I had to make to get it to work.

FastCGI looks like a good way to go if you "have" to use Apache on VMS.

br /ARon
Back to top
View user's profile Send private message
jfp



Joined: 12 Jul 2004
Posts: 633

PostPosted: Tue Nov 15, 2011 10:53 am    Post subject: Reply with quote

Many thanks for this great feedback.

Will be very useful for anyone wanted to use Django with Apache.

JF
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group