Interesting programming resources for learning (paid / free)

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
12,340
Reaction score
664
Bro can teach me how to build perl CGI app hosted in Apache Https? 😂

Perl:
use strict;
use warnings;

my $dt = localtime();

print "Content-Type: html\r\n\r\n";
print <<"ENDOFHTML";
<html>
  <head>
    <title>Welcome</title>
  </head>
  <body>
  Helloworld at $dt
  </body>
</html>
ENDOFHTML

Bash:
# find where the cgi-bin directory is normally is /usr/lib/cgi-bin
find / -name cgi-bin

#In your Apache configuration at /etc/apache2/, there is normally the following directive
ScriptAlias "/cgi-bin/" "/usr/lib/cgi-bin/"

Hence if you access http://your.web.server/cgi-bin/yourscript.pl, it will be accessing
/usr/bin/cgi-bin/yourscript.pl

Of course there are a couple more ways to have executable pick up by the CGI handler in Apache, this is the default and most widely configured by default.

Make sure your script has permission 0750 and owned by the process userid running your apache, normally is www-data
Bash:
chown www-data:www-data /usr/lib/cgi-bin/yourscript.pl
chmod 0750 /usr/lib/cgi-bin/yourscript.pl

Have fun.
:)
 
Last edited:

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
12,340
Reaction score
664
@Trader11 you are laughing because it is too simple for you ?

I really hope it is simple for you, because that is what is required of me to do when I'm a software developer in my first year working. It is an end-to-end knowledge from installing the Linux OS, installing the Apache HTTPd, to configure it, to coding in it, inclusive of webpage design to templatising into HTML/CSS/JS + server side scripting + database schema design with code and database optimisation.

I don't live in the IDE and I don't just survive above the IDE and browser as a software engineer.

:)
 
Last edited:

Trader11

Arch-Supremacy Member
Joined
Oct 14, 2018
Messages
12,071
Reaction score
3,135
@Trader11 you are laughing because it is too simple for you ?

I really hope it is simple for you, because that is what is required of me to do when I'm a software developer in my first year working. It is an end-to-end knowledge from installing the Linux OS, installing the Apache HTTPd, to configure it, to coding in it, inclusive of webpage design to templatising into HTML/CSS/JS + server side scripting + database schema design with code and database optimisation.

I don't live in the IDE and I don't just survive above the IDE and browser as a software engineer.

:)
Laughing because I am happy.

Surprise surprise I am working on a project recently where I need to modify an old perl app.
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
12,340
Reaction score
664
Laughing because I am happy.

Surprise surprise I am working on a project recently where I need to modify an old perl app.
Good for you. Anyone whom works in an Unix environment "MUST" know Perl, not just for web app.

In any case, this is the most basic way of working with Perl CGI.

A more modern way, without resorting to framework yet is to use CGI module found at https://metacpan.org/pod/CGI
Personally when it come to certain sized perl application, I don't use frameworks because I don't find the need to.

When it comes to producing the HTML using a template engine,
in earlier days, I use HTML::Template

With the segregation of frontend and backend, you can always create RESTful Perl API to facilitate your vibrant frontend technologies
like React, Angular, Vue, Next etc.

:)
 
Last edited:

Trader11

Arch-Supremacy Member
Joined
Oct 14, 2018
Messages
12,071
Reaction score
3,135
Good for you. Anyone whom works in an Unix environment "MUST" know Perl, not just for web app.

In any case, this is the most basic way of working with Perl CGI.

A more modern way, without resorting to framework yet is to use CGI module found at https://metacpan.org/pod/CGI
Personally when it come to certain sized perl application, I don't use frameworks because I don't find the need to.

When it comes to producing the HTML using a template engine,
in earlier days, I use HTML::Template

With the segregation of frontend and backend, you can always create RESTful Perl API to facilitate your vibrant frontend technologies
like React, Angular, Vue, Next etc.

:)
I used Nginx initially....but realised it's so troublesome because of the need of extra module....Apache seems more supportive for cgi
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
12,340
Reaction score
664
I used Nginx initially....but realised it's so troublesome because of the need of extra module....Apache seems more supportive for cgi

You can always create tiers by using both so that static contents are served using nginx, and having Apache HTTPd is a more heavy weight to serve dynamic contents. If you know perl well enough you can venture into modperl which is baked into Apache HTTPd which doesn’t require a perl interpreter started up for each request. It is still CGI because CGI is talking about interfaces, not how it is implemented.

:)
 
Last edited:
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ. Forum members and moderators are responsible for their own posts.

Please refer to our Terms of Service for more information.
Top