DEV Community 👩‍💻👨‍💻

Kailash Sankar
Kailash Sankar

Posted on

Setup perl catalyst server on a shared host

NOTE: originally posted on 31 Aug 2014 more

A guide to setup perl catalyst framework app on Godaddy shared hosting account.

Catalyst framework

Setting up catalyst on the host server was quite harder than I thought it would be. The problem was that I couldn't find any tutorial specific to setting up the server in shared host like Godaddy hosting. This is what worked for me, there might be other ways to do it as well.

Before we start the setup details, I'll add in some info about my hosting plan and domain,

  • The .in domain was Rs 199 per year when I bought it
  • I chose the most basic linux hosting plan - 30gb, Cpanel, perl support and one mysql database

Now to setup catalyst!

  • Install the required modules through the Cpanel interface
  • tarball your project , copy to server and extract inside public_html
  • Create a .htaccess file in your myapp/script folder and add the following lines and save.
    Options +ExecCGI
    AddType application/x-httpd-fcgi .fcgi
    SetHandler fcgid-script
Enter fullscreen mode Exit fullscreen mode
  • Create an alias with name 'script' from public_html folder to point to your myapp/script folder
  • Open the main .htaccess file inside public_html and add the below lines and save ( replace myapp with your app name).
    Options +ExecCGI
    AddHandler fastcgi-script .fcgi

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/?script/myapp_fastcgi.fcgi
    RewriteRule ^(.*)$ script/myapp_fastcgi.fcgi/$1 [PT,L]
Enter fullscreen mode Exit fullscreen mode
  • Rename your file to myapp_fastcgi.fcgi, open the file and change the perl path to #!/usr/bin/perlml. This is the perl path on go daddy server. To confirm you can go to the install perl modules section, this path will be listed there.
  • The final step is to give 755 permission to the .fcgi file. You can do this either from the Cpanel file manager or from terminal. Now head to your address and check!
  • In case you are facing errors, run the test server and check, if there are any missing dependencies you will see an error otherwise the test server will run. Don't leave the test server running as a process. You can use the to install missing dependencies if any. I had to manually install a few in my case.
  • There is a way to test if apache is processing fcgi; for this, first comment out the below lines in the main .htacces file (the one inside public_html)
    #RewriteEngine On
    #RewriteCond %{REQUEST_URI} !^/?script/kdev_fastcgi.fcgi
    #RewriteRule ^(.*)$ script/Myapp_fastcgi.fcgi/$1 [PT,L]
Enter fullscreen mode Exit fullscreen mode

Now go to your myapp/script folder and create a new file helloworld.fcgi and add the below lines:

    use cPanelUserConfig;

    use lib qw(
    use FCGI;
    use Socket qw( :crlf ); # server agnostic line endings in $CRLF

    my $counter = 0;
    my $request = FCGI::Request();
    while ( $request->Accept() >= 0) {

            "Content-Type: text/plain",
            "Hello World, in Perl FastCGI!",
            "I am process $$.",
            "I have served $counter request(s).",
Enter fullscreen mode Exit fullscreen mode

Now browse to that path from your address eg: . Hopefully you should see the output, if you do then your server is handling .fcgi, otherwise there is a problem with either the permissions or the handler.
Let me know if this works for you, if you are still facing issues or if you have any suggestions please add a comment.

Latest comments (0)

🌚 Browsing with dark mode makes you a better developer by a factor of exactly 40.

It's a scientific fact.