How to generate dynamic content via mod_perl handler in Template::Toolkit? - perl

I was just trying to use Template::Toolkit perl module on my centos to generate dynamic web content. This tutorial, and the one given on cpan site, is made to bind mod_perl with Apache. I'm using nginx on my centos. i tried allot, but I'm less into server things, so failed each time. Can anyone help me to integrate mod_perl with nginx? Or is there any alternative for this?

mod_perl is an Apache module. It cannot be used with nginx.
To use Template::Toolkit with nginx, you will need to implement a web application some other way. Probably the most straightforward way of doing this will be to write it as a Plack application; this will allow it to be run as a HTTP or FastCGI server that nginx can proxy requests to.

Related

difference between perl dancer framework and apache2 http server

I am new to the programming world and started with Perl couple of days back. I tried developing a web application using Perl. Initially followed some tutorial and learned how to write simple CGI scripts using Perl and deployed it using Apache2 httpd server. After getting to know about the Perl Dancer it was much easier to develop a web application using the framework.As both serve the same purpose I want to know weather Dancer is a replacement to the Apache httpd server or dancer internally uses apache to start a server. As dancer is just a web application framework how internally it is managing to handle the server request and responses.
Can anybody post a link where I can read and get to know about how the webserver works?
Dancer has a PSGI interface.
PSGI is similar to CGI in that it allows a web server to communicate with the Perl application, but it is more efficient (it keeps the application running all the time so it doesn't need to load everything from scratch for each request) and has more features (e.g. the ability to use Plack middleware).
Dancer comes with a script to run a simple web server (which is not Apache) for development purposes.
It is expected that you'll use a more powerful web server (such as Apache HTTPD) in production.

Perl run PSGI on linux centos and apache shared hosting

I have a psgi test application on a linux centos with cpanel shared hosting. How can I call it under PSGI protocol
like:
http://domain.com/app.psgi
I mean how to enable .psgi to run under PSGI protocol. I want to be able to run any .psgi automatically under the PSGI protocol.
I know I can run it using the plackup command.
The problem is that the share hosting used Apache, in other words mod_perl, you need avaliable mod_perl, but this is not psgi.

nginx + perl setup guide for windows

I'm looking for a guide, tutorial or advices to just have an nginx webserver working on windows configured with localhost site which can run perl scripts.
I know how to do it with Apache so, please do not answer that. Already got an Apache 2.4 running aside with IIS, properly configured tu run perl-cgi scripts. I'm looking for the nginx solution.
Thanks
The historical answer is to setup a proxy to apache from the nginx side. I would personally prefer a solution based on FCGI

Example for several (fastcgi/uwsgi/scgi/proxy_pass) Mojolicious apps in the same nginx virtual host?

I have some Mojolicious-based apps which happily run under Apache2 with mod_cgi and mod_fastcgi.
The urls are for example:
http://example.org/oneapp/path/info?foo=bar
http://example.org/oneapp?foo=bar
http://example.org/secondapp/path/info?foo=bar
http://example.org/thirdapp/path/info?baz=heh
#etc...
I had relative success configuring the apps as subdomains using proxy_pass
but I would like to keep the old urls(just switch from apache2 to nginx).
I would like to keep the same urls but run the apps using nginx.
What should my configuration look like and how should I run the apps.
Thanks in advance!
Since you haven’t got an answer, I’ll give a correct, but entirely half-baked and code-free, solution. Check the Mojolicious::Guides::Cookbook for nginx and Plack deployment. Mix this with Plack::Builder for deploying multiple applications on the same server. I’d go with Starman as the server engine probably but that is up to you and your specific needs.
That’s basically it. Sorry I don’t have code for you but that should do exactly what you want once you get through each step; the docs are good and can be supplemented with blog posts from various Perl devs.
see also the Mount Plugin which allows you to add one mojolicious app within another

How can I host a mod_perl application on a shared RHEL server?

I want to host a mod_perl application on a shared RHEL server where I do not have access to a root account. mod_perl is available on the server as are all Perl modules required (my app runs fine with CGI).
Here are two problems I anticipate: Apache restarts would be required whenever I update my code the first time and subsequently on periodic updates. Second, I would have to use some <Perl> directives in .htaccess. I would be happy to hear experiences, gotchas, hints from others who might have done this successfully. Thank you!
This might not be useful in your case, but you can always run an
Apache instance in your home directory, and have the frontend proxy
incoming requests to that instance. That way, you have full control
over the configuration, Apache modules, Perl modules, and Perl itself.
It also uses system resources better (slow clients don't tie up the
heavy perl app, only the lean frontend instance), and is actually the generally
recommended way of deploying mod_perl applications.
Another option, and one that will involve less screwing around, would
be to get a $20/month VPS and use that. Then you can do whatever you
want, as you'll have full root access.
You can't do it without the ability to restart Apache httpd.
Perhaps the admin will give you sudo powers so you can do that at least.
Try Perl under FCGI instead.
You aren't gonna be able to use mod_perl without root on a shared hosting account. The "run my own instance" sounds okay, but you will need a way to start up apache if the server reboots.
FCGI is your best bet. That or get something where you can get root access to your own apache process. The added benefit of such an account would be you could install CPAN modules without going through the extra hassle of setting up a non-root library and messing with $PERL5LIB.