buy
How to Run Perl Script

Overview

Running a Perl script on your domain's directory allows you to execute custom code and perform various tasks. This guide will walk you through the process of setting up and running a Perl script on your domain.

Procedure

If you want to execute the Perl script on your document root as "home/user/public_html" then you should follow these Steps.

  • Choose Web Server apache2 from Webuzo Admin Panel > Home > Apps > Default Apps 
  • Create a Index.cgi file at the "/home/user/public_html/" or "/home/user/public_html/cgi-bin/".
  • Add the following example into the index.cgi file as shown below.
#!/usr/bin/perl
print "Content-Type: text/plain\n\n";
print "Hello, World!\n";

NoteIn order for your Perl script file to function properly and serve on your domain, you must include the code `print "Content-Type: text/plain";` in it.

  • Add the ownership and permission for the path "/home/user/public_html/index.cgi", follo the given below command.
$ sudo chmod 0755 /home/user/public_html/index.cgi
$ sudo chown user:user /home/user/public_html/index.cgi
  • if you have uploaded your project not a single file such as index.cgi then add the ownership and permission recursively for the path "/home/user/public_html/index.cgi", follow the given below command.
$ sudo chown user:user -R /home/user/public_html/project
$ sudo chmod 0755 -R /home/user/public_html/project

Note: If cgi-bin directory is not exist on the path "/home/user/public_html/" then create it by following the given below command.

$ sudo chown user:user -R /home/user/public_html/cgi-bin
$ sudo chmod 0755 -R /home/user/public_html/cgi-bin
  • After this, check the domain and access as "https://domain".
  • Or else, you have created the index.cgi file on the path "/home/user/public_html/cgi-bin/" then you have to access as "https://domain/cgi-bin".

Hence, here the Perl script run successfully and served on your domain.

    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list