Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
litespeed_wiki:other-ext-apps:apache-mod-perl-equivalent [2019/04/24 20:21]
Lisa Clarke [lscgid: execve() No such file error] Copyediting
litespeed_wiki:other-ext-apps:apache-mod-perl-equivalent [2020/08/29 14:56]
Lisa Clarke Copyediting
Line 1: Line 1:
-===== How to Run a Perl Script on LSWS=====+====== How to Run a Perl Script on LSWS ======
  
-LiteSpeed comes with a persistent Perl CGI daemon which can run Perl CGI scripts without modification,​ just like mod_perl in Apache.+LiteSpeed ​Web Server ​comes with a persistent Perl CGI daemon which can run Perl CGI scripts without modification,​ just like mod_perl in Apache.
  
-==== For a Control Panel Environment ==== +===== For a Control Panel Environment ​===== 
-If you configure LSWS to run Perl under a control panel environment,​ such as cPanel, you need to configure it as a Fast CGI application,​ and then add a script handler for "​pl"​ or whatever ​suffixes ​used for Perl scripts. The Perl CGI daemon is located at + 
 +==== Set up a Perl FastCGI External App and Script Handler ​==== 
 +If you configure LSWS to run Perl under a control panel environment,​ such as cPanel, you need to configure it as a Fast CGI application,​ and then add a script handler for "​pl" ​(or whatever ​suffix is used for Perl scripts). The Perl CGI daemon is located at ''/​usr/​local/​lsws/​fcgi-bin/​lsperld.fpl''​
  
-  /​usr/​local/​lsws/​fcgi-bin/​lsperld.fpl 
 {{ :​litespeed_wiki:​other-ext-apps:​lsperld-ext-app.png?​600 |}} {{ :​litespeed_wiki:​other-ext-apps:​lsperld-ext-app.png?​600 |}}
  
 {{ :​litespeed_wiki:​other-ext-apps:​lsperld-ext-app-handler.png?​600 |}} {{ :​litespeed_wiki:​other-ext-apps:​lsperld-ext-app-handler.png?​600 |}}
 +<​code>​
 +    <​extProcessor>​
 +      <​type>​fcgi</​type>​
 +      <​name>​PerlFastCGI</​name>​
 +      <​address>​uds://​tmp/​lshttpd/​perl.sock</​address>​
 +      <​maxConns>​35</​maxConns>​
 +      <​env>​FCGI_PERL_MAX_REQ=1000</​env>​
 +      <​env>​LSAPI_CHILDREN=35</​env>​
 +      <​initTimeout>​60</​initTimeout>​
 +      <​retryTimeout>​0</​retryTimeout>​
 +      <​persistConn>​1</​persistConn>​
 +      <​pcKeepAliveTimeout>​30</​pcKeepAliveTimeout>​
 +      <​respBuffer>​0</​respBuffer>​
 +      <​autoStart>​1</​autoStart>​
 +      <​path>/​usr/​local/​lsws/​fcgi-bin/​lsperld.fpl</​path>​
 +      <​backlog>​100</​backlog>​
 +      <​instances>​1</​instances>​
 +      <​memSoftLimit>​2074M</​memSoftLimit>​
 +      <​memHardLimit>​2074M</​memHardLimit>​
 +      <​procSoftLimit>​400</​procSoftLimit>​
 +      <​procHardLimit>​500</​procHardLimit>​
 +    </​extProcessor>​
 +</​code>​
 +<​code>​
 +   <​scriptHandler>​
 +      <​suffix>​pl</​suffix>​
 +      <​type>​fcgi</​type>​
 +      <​handler>​PerlFastCGI</​handler>​
 +    </​scriptHandler>​
 +</​code>​
  
 Restart LiteSpeed Web Server. Restart LiteSpeed Web Server.
 +==== Testing on cPanel ====
 +For a Perl or CGI script to run in a control panel environment,​ normally you should place the script in a designated directory such as ''/​cgi-bin/'',​ otherwise it may not work.
 +
 +You can create a simple test script hello.pl under /cgi-bin/
 +<​code>​
 +  #​!/​usr/​bin/​perl
 +  use strict;
 +  use warnings;
 +  print "​Content-type:​ text/​html\n\n";​
 +  print("​Hello World\n"​);​
 +</​code>​
 +
 +You can also run perl from the command line to verify the error: ​
 +<​code>​
 +  perl -w hello.pl
 +</​code>​
 +
 +Visit ''​https://​yourdomain.com/​cgi-bin/​hello.pl''​ from the browser to see if it works.
 +
 +If it works from the command line but doesn'​t work from the browser, most likely this is caused by an "​x"​ permission issue. Perl or the CGI script will need to allow everyone "​x"​ permission, like so:
 +<​code> ​
 +  chmod 755 hello.pl
 +</​code>​
 +
 +Perl script errors are beyond our support scope and you are encouraged to google for solutions. You can check [https://​docs.cpanel.net/​knowledge-base/​general-systems-administration/​troubleshooting-guide-for-perl-and-cgi-scripts/​|cPanel'​s documentation] to troubelshoot similar CGI/Perl issues on cPanel.  ​
  
-==== For LSWS Native Configuration ====+===== For LSWS Native Configuration ===== 
 +==== Perl FastCGI for LSWS Native Configuration ====
 For LSWS native configuration,​ you also need to set up the Fast CGI application and add a script handler for "​pl"​. For LSWS native configuration,​ you also need to set up the Fast CGI application and add a script handler for "​pl"​.
  
Line 57: Line 114:
   print "</​body></​html>";​   print "</​body></​html>";​
  
-You should see something similar to the following when visting ''​<nowiki>​http://​yourdomain.com/​test.pl</​nowiki>''​+You should see something similar to the following when visting ''​nowiki>​http://​yourdomain.com/​test.pl</​nowiki>''​
  
 <​code>​ <​code>​
Line 92: Line 149:
 ===== Troubleshooting ===== ===== Troubleshooting =====
  
-==== Installation ​error ====+==== Installation ​Error on LSWS Native ​====
 Without the ''​perl-CPAN''​ package installed, installation may run into the following error: Without the ''​perl-CPAN''​ package installed, installation may run into the following error:
   Can't locate CPAN.pm in @INC (@INC contains: /​usr/​local/​lib64/​perl5 /​usr/​local/​share/​perl5 /​usr/​lib64/​perl5/​vendor_perl /​usr/​share/​perl5/​vendor_perl /​usr/​lib64/​perl5 /​usr/​share/​perl5 .).   Can't locate CPAN.pm in @INC (@INC contains: /​usr/​local/​lib64/​perl5 /​usr/​local/​share/​perl5 /​usr/​lib64/​perl5/​vendor_perl /​usr/​share/​perl5/​vendor_perl /​usr/​lib64/​perl5 /​usr/​share/​perl5 .).
  • Admin
  • Last modified: 2023/03/25 14:06
  • by Lisa Clarke