Perl run PSGI on linux centos and apache shared hosting - perl

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.

Related

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

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.

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.

Deploying Sinatra app .rb

I know this is probably a stupid question. But I created a .rb file with Sinatra framework and I am not sure how to "deploy" it. When I posted the file on the server I just get a simple text file that reads back my code. It works great when I run it with Sinatra.
Thanks in advance!
It looks like your web server (Apache?) is just serving you with your Ruby script (that is a text, ASCII file) instead of running it (that is: instead of passing it through the Ruby interpreter).
Hence:
Is the Ruby interpreter installed on your server?
Is your web server configured to run Ruby scripts (files terminating with ".rb")
through the Ruby interpreter?
And, is Sinatra itself installed on your web server?
Anyway, Ruby applications (Rails, Sinatra, Padrino) are usually deployed to a server using GIT. Have a look at Heroku and Engine Yard.
Also, there are tools specifically designed to help the developer in deploying Ruby applications. Have a look at Capistrano or Vlad and/or Google for "how to deploy a sinatra application".
For Sinatra/Rails/etc, most people use a Webserver (ie Apache, Nginx, etc) AND an Application Server (Thin, Passenger, Unicorn). For a simple app these can live on the same host. The webserver manages the incoming traffic and the application server executes the ruby code and passes results to the webserver.
When you execute ruby app.rb to run your Sinatra application, you're actually loading up WEBrick which is an application server. Since your development machine is local, you can access it directly at localhost:3000 or some similar address.
Look into tutorial on setting up your webserver with Thin, it's one of the easier ones to work with. When/if you outgrow it, then look into Unicorn.

What web service on lighttpd

I have to do web service + web page on openwrt device. From web page I can send communications to a program which is running on the device, so I need to build web service and I don't know which to chose for lighttpd web server, I don't know if Soap Lite is compatible with openwrt+lighttpd.
Soap Lite is a "collection of Perl modules" for perl. You can use the cgi extension on lighttpd to use perl. So yes, it would work with lighttpd. The question is if your router has enough processing power to support lighttpd + cgi.

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.