NS30   .bizland.us

Perl/CGI Setup on an Ubuntu server with Virtualmin

  1. Login as user or root at https://DOMAIN.TLD:10000 or https://SUB.DOMAIN.TLD:10000
  2. Go to or select your domain in the left column under Virtualmin tab
    1. Web Configuration
    2. -> Website Options
      1. CGI script execution mode -> FCGIwrap server
      2. Redirect all requests to SSL site -> yes (optional)
  3.  
    1. Web Configuration
    2. -> Configure SSL Website
    3. Under 'Virtual Server Options,' click Directory '/home/USERNAME/public_html' under 'Per Directory Options'
    4. click 'Document Options'
    5.  
      1. Set the following options after clicking 'Selected below'
        1. Execute CGI programs -> Yes
        2. Follow symbolic links -> Yes
        3. Server-side includes and execs -> Yes
        4. Server-side includes -> Yes
        5. Generate directory indexes -> No
        6. Generate Multiviews -> No
        7. Follow symbolic links if owners match -> Yes
      2. Click Save
  4.  
    1. Go / Return to MIME types
    2. Under 'content handlers,'
      1. Select cgi-script for 'Handler'
      2. type .cgi for 'Extensions'
    3. Click Save
  5.  
    1. Click 'Apply Configuration' on the top right corner
  6.  
    1. Test/Refresh your CGI script/page/URL
    2.  
      1. Login to your server via SSH
      2. Run cpan install CPAN DateTime Cpanel::JSON::XS CryptX EV IO::Socket::Socks IO::Socket::SSL Net::DNS::Native Role::Tiny Future::AsyncAwait Mojolicious
    3. Save the following lines in a file, e.g., index.cgi
    4.  
      1. #!/usr/bin/perl
      2. use Mojolicious::Lite -signatures;
      3. get '/' => sub ($c) { $c->render('default'); };
      4. app->start;
      5. 1;
      6. __DATA__
      7. @@ layouts/default.html.ep
      8. <!doctype html>
      9. <html lang="en">
      10.    <head>
      11.       <meta charset="utf8">
      12.       <title><%= title %> - Perl Mojolicious App</title>
      13.       <meta name="url" content="https://ns30.bizland.us/index.cgi">
      14.       <meta name="description" content="<%= app->config->{thisapp}->{description} %>">
      15.       <meta name="keywords" content="<%= app->config->{thisapp}->{keywords} %>">
      16.       <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
      17.       <meta name="theme-color" content="#B12A34">
      18.       <meta name="Robots" content="INDEX,FOLLOW">
      19.       <meta name="Rating" content="General">
      20.       <link rel="icon" href="favicon.ico">
      21.       <link rel="apple-touch-icon" href="/favicon.ico">
      22.       <link rel="manifest" href="//ns30.bizland.us/assets/manifest.json">
      23.       <link rel="stylesheet" href="//ns30.bizland.us/assets/default.css">
      24. </head>
      25. <body>
      26.    <%= content %>
      27.  
      28. <footer class="container-fluid">
      29.    <div class="rights" id="rights">
      30.    © <a href="//ns30.bizland.us" title="All rights reserved by " BizLand Hosting " - www.BizLand.us">ns30.bizland.us</a>
      31.    <span id="what-is-my-ip-address"></span>
      32.    </div>
      33.    <div class="ads" id="ads"></div>
      34. </footer>
      35.  
      36. <script defer src="/assets/node_modules/jquery/dist/jquery.min.js"></script>
      37. <script defer src="/assets/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
      38. <script>
      39.    // register service worker
      40.    if ('serviceWorker' in navigator) {
      41.    window.addEventListener('load', () => {
      42.    navigator.serviceWorker.register("/assets/service-worker.js")
      43.    .then((reg) => {
      44.    console.log('Service worker "ns30.bizland.us" registered', reg);
      45.    });
      46.    });
      47.    }
      48. </script>
      49. <script defer src="/index.cgi/what-is-my-ip-address?_format=js"></script>
      50.   
      51. </body>
      52. </html>
      53.  
      54.  
      55. @@ default.html.ep
      56. % layout 'default';
      57. % title 'Home';
      58.  
      59. <article>
      60.       <h2>Hello World<h2>
      61.       Your IP is <%= $ENV{REMOTE_ADDR} %>
      62. </article>
      63.  
      64.  
    5. Set file permission to '0755' (execute mode)
    6.  
      1. Click File Manager under Virtualmin
      2. Go to public_html
      3. Check mark the file 'index.cgi'
      4. Go to 'Tools' -> 'File Permissions'
      5. Owner: Read Write Execute
      6. Group: Read Execute
      7. Others: Read Execute
      8. Click Change
      9. or, type 0755 in the text box for 'Mode' and click Change
      10. or run 'cd public_html' and 'chmod +x index.cgi' when logged into your server via ssh as user/root
    7. open your file in a browser: https://Domain.tld/index.cgi
    8. It should just say 'Hello World' and show your IP on the browser