How should we setup to execute CGI or Perl or PHP script through httpd?

Solution Unverified - Updated

Environment

  • Red Hat Enterprise Linux (RHEL)
  • 5.x

Issue

  • How should we setup to execute a CGI or Perl or PHP script through httpd?

Resolution

CGI
  1. Deploy the CGI script to /var/www/cgi-bin/ directory (or the ScriptAlias directory specified in httpd.conf).

  2. Change permissions to execute the script.

  3. Access http://your_domain/cgi-bin/your_cgi_script.

Perl
  1. Install a mod_perl package.
  2. Edit /etc/httpd/conf.d/perl.conf (drop hash signes to enable handler.)
    Alias /perl /var/www/perl
    <Directory /var/www/perl>
        SetHandler perl-script
        PerlResponseHandler ModPerl::Registry
        PerlOptions +ParseHeaders
        Options +ExecCGI
    </Directory>
    
  3. Deploy the Perl script to /var/www/perl/ directory.
  4. Change permissions to read the script.
  5. Access http://your_domain/perl/your_perl_script.
##### PHP
  1. Install a php package.

  2. Deploy the PHP script to /var/www/html/ directory with a .php extension.

  3. Change permissions to read the script.

  4. Access http://your_domain/your_php_script.

Root Cause

  • To execute scripts through httpd, Red Hat Enterprise Linux provides four modules: mod_cgi (httpd package), mod_perl, mod_php (php package) and mod_python.

Comments

See also:

Components
Category
Tags

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.