I have a Perl Dancer web app which I would like to run on an apache server (on centos 6).
I put at the webapp's rootdir a sym link (index.html) to the public/dispatch.cgi script which uses the Pluck::Runner module.
The problem is when loading the page, it can't find a needed files (such as the sqlite file), in fact the routing is messed up since it looks for routing at $appname/index.pl/blabla... instead of $appname/blabla...
I think some kind of apache directive or rule is needed here but I don't these well enough.
I hope some one could help me solving this issue.
Thanks in advanced.
Roy.
It would help if you would provide your apache (vhost) configuration.
You should read the section 'Running as a cgi-script (or fast-cgi)' of Dancer deployment, because that document presents a lot differnt ways to deploy your Dancer application.
I like to use starman behind Apache as proxy. In the Perl Advent Calender 2010 you find a description how to do that.
Starman is fast for the dynamic part and apache perfect for static files and routing.
Related
For years I have been using the following at the top of my scripts:
use lib '/var/www/vhosts/example.com/demo.example.com/cgi-bin/library';
That works fine when the lib is within the same domain space as the calling script.
However, I want to call in from a centralised library so I will have just one place to set db credentials.
So, if I adjust that line to call in from another account on the same server, it cannot find the library.
use lib '/var/www/vhosts/example2.com/demo.example2.com/cgi-bin/library';
Running on plesk, if that may make a difference. Used to run on cPanel and I had no issue.
I would appreciate a pointer, having already read some docs and I am confused.
Only someone with access to the configuration of your web server can answer this for sure, but I'd guess that each of your vhosts is running as a different user and the users can only read files from their own web space.
This approach won't work. If you want to to have a centralised module library then either install the modules that you want in the system module library (i.e. where cpan will install them by default) or create your own new centralised library somewhere that isn't under one of the vhost directories (perhaps under /opt).
However, it's worth noting that best practices for deployment of applications are moving in completely the opposite direction. It's generally considered a good idea for each application to have its own set of dependencies installed in its own module library. Using a cpanfile to record the exact versions of the dependencies that you're using makes this simple.
the title perty much says it all. running;
windows 7 on x86 mother board, with apache 2.2.25 and perl 5.16.
I can't seem to find aggrenment on witch mod_perl to use. AND,
from the docs i've seen the problem will be getting it and
configuring. pointers of detailed instructions will be best.
and i see another problem coming before i get there and i've looked around.
how to get windows 7 iis permission to run .cgi and .pl script.
what i've read start will, run inetmgr.exe.. when i try to run inetmgr.exe the system
tell me 'can't find', are the docs wrong, my windows admin file broken ???
please respond to grumpyoldphuker#gmail.com.
You don't need Apache and mod_perl if you just need to run CGI scripts under IIS on Windows. Perl will be able to do that by itself, as long as you have IIS configured to run CGI scripts correctly.
Otherwise, you might want to take a look at http://plackperl.org/ instead, for the "modern" way to run Perl-based web applications. You can likely use IIS as a front-end proxy in front of your Plack server process.
I want to run a Perl script online, but I don't know how.
In PHP you need to start with <?php, so do you have to start with something like that in Perl?
And does Apache automatically recognize Perl? Or do I have to upload Perl and let it point to it using #!/path/to/perl?
Can I use print() to display HTML?
In PHP you need to start with <?php, so do you have to start with something like that in Perl?
There are frameworks (such as Mason) which work like that, but it is more typical to have a standard Perl program which outputs the page.
And does Apache automatically recognize Perl?
Apache doesn't automatically recognise any kind of server side programming.
Or do I have to upload Perl and let it point to it using #!/path/to/perl?
You would need to have Perl installed on the server. You would generally start a script that way (but not necessarily, e.g. if you were using mod_perl), but would have to configure the server to recognise it as an executable and run it (just as you have to configure the server to recognise files ending with .php as scripts to run with PHP).
Can I use print() to display HTML?
Yes.
You should probably start by looking at the question Web Programming For The Non-Web Programmer (in Perl).
Must you use Apache? If not here is an alternative to consider.
I have found that the built-in servers and templating engine in the Mojolicious framework work very naturally for inline Perl within HTML. The tags are of the form <%== but work the same way. Also it has good documentation and examples to get you going.
Edit: It seems that there are ways to use Apache with Mojolicious too, see http://search.cpan.org/perldoc?Mojolicious::Guides::Cookbook, though the built-in servers have worked well for me, with FAR less (ie no) configuration.
Apache HTTP doesn't automatically understand Perl or PHP for that matter. For PHP to work, you have to have the Apache httpd module called something like mod_php.so or libphp5.so installed. However, since many websites use PHP in this manner, this Apache httpd module is normally installed.
Just as you need mod_php in order to use PHP in Apache's httpd web server, you need to do is make sure your web server is using mod_perl if you want to use Perl in a similar manner.
You'll need to build and install mod_perl which can be tricky -- especially if you don't control the machine the server is on.
The other way to use Perl is to use what's known as CGI-Perl. This is much easier to setup, but it is also much more dangerous since it can lead to someone being able to run unauthorized programs on your Apache httpd server.
In this case, you need to set up a CGI-BIN directory, and configure Apache httpd. This is fairly simple. Once you do that, you put all of your Perl scripts into the _CGI_BIN_ directory. In this case, your Perl scripts will have to handle all of the communication between your web server and the web client and handle all displays. Fortunately, it's not too difficult in perl since Perl gives you the basic modules to do this.
I've written a web cgi application in perl and before I start to distribute it to clients, I'd like to provide an option for future updates.
I would like to know what are the standard approaches for that using free Linux tools.
It is OK for the server to be stopped during updating.
Thank you,
Spasski
If you have separated code from configuration and data, then the easiest way is to tar/zip the new files and unpack them onto the existing installation. If you need to update the data files, then you could include a script that makes the necessary changes.
Take a look at th bugzilla upgrade guide. I've used this process many times without a hitch.
http://www.bugzilla.org/docs/tip/en/html/upgrade.html
I am working with a hosting provider who has installed mod_python for me. I followed the install instructions locally and included it in httpd.conf but they have opted to put it in conf.d/python.conf.
Is there any difference/benefit to doing it either way?
No, all the files are parsed at run time, you can include as many as you want. They've just opted to seperate out the configuration for easier management.