I cant seem to even fix this issue, I've tried so many things and nothing will work...
I'm basically doing this for a friend of mine, I've setup apache properly in his ubuntu server but whenever I try to access the register file in usr/lib/cgi-bin, it keeps giving me a 500 internal server error.
This is the site configuration file(000-default.conf)
<VirtualHost *:80>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
This is the register file:
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use Method::Signatures;
use Digest::MD5 qw(md5_hex);
use Drivers::MySQL;
use feature qw(say);
print header();
my %arrConfig = (
dbHost => '127.0.0.1',
dbName => 'Luna',
dbUser => 'root',
dbPass => 'password123'
);
my $objHtml = CGI->new;
my $objMysql = MySQL->new;
$objMysql->createMysql($arrConfig{dbHost}, $arrConfig{dbName}, $arrConfig{dbUser}, $arrConfig{dbPass});
if ($objHtml->param) {
parseResults(\%arrConfig, $objMysql, $objHtml);
} else {
displayPage(\%arrConfig, $objHtml);
}
method parseResults(\%arrConfig, $objMysql, $objHtml) {
my $strName = $objHtml->param('username');
my $strPass = $objHtml->param('password');
my $strPassTwo = $objHtml->param('passwordtwo');
my $intColour = $objHtml->param('colour');
my $strIP = $objHtml->remote_host;
my $intNameCount = $objMysql->countRows("SELECT `username` FROM users WHERE `username` = '$strName'");
my $intIPCount = $objMysql->countRows("SELECT `ipAddr` FROM users WHERE `ipAddr` = '$strIP'");
if ($intIPCount > 2) {
error('You Can Only Own Two Accounts Per IP Address');
} elsif (!$strName && !$strPass && !$strPassTwo && !$intColour) {
error('You Did Not Complete All The Fields! Please Try Again');
} elsif ($strName !~ /^[a-zA-Z0-9]+$/) {
error('Username Is Invalid');
} elsif ($strName > 12 && $strName < 3) {
error('Username Contains Too Many Or Less Characters');
} elsif ($intNameCount > 0) {
error('Username Already Exists');
} elsif (length($strPass) > 20 && length($strPass) <= 5) {
error('Password Contains Too Many Or Less Characters');
} elsif ($strPass ne $strPassTwo) {
error('Password Does Not Match');
} elsif ($strPass !~ /^(?=.{5,10}$)(?=.*?[A-Z])(?=.*?\d)(?=.*[##*=])(?!.*\s+)/) {
error('Password Requires One Uppercase, Lowercase, Integer And Special Character');
} elsif (!int($intColour) && $intColour > 15 && $intColour < 0) {
error('Invalid Colour');
}
my $strHash = md5_hex($strPass);
my $intID = $objMysql->insertData('users', ['nickname', 'username', 'password', 'colour', 'active', 'ipAddr', 'stamps'], [$strName, $strName, $strHash, $intColour, 1, $strIP, '31|7|33|8|32|35|34|36|290|358|448']);
$objMysql->insertData('igloos', ['ID', 'username'], [$intID, $strName]);
$objMysql->insertData('postcards', ['recepient', 'mailerName', 'mailerID', 'notes', 'postcardType', 'timestamp'], [$intID, 'Luna', 0, 'Welcome To Luna!', 125, time]);
say $objHtml->h1('You have successfully registered');
say $objHtml->p($objHtml->u('Your account details:'));
say 'Username: ' . $objHtml->b($strName);
say 'Password: ' . $objHtml->b($strPass);
say 'ID: ' . $objHtml->b($intID);
}
method displayPage(\%arrConfig, $objHtml) {
say $objHtml->start_html(-title => 'Luna', -bgcolor => 'white');
say $objHtml->start_center;
say $objHtml->start_form(-name => 'main', -method => 'POST');
say $objHtml->start_table;
my %arrColours = (
1 => 'Blue',
2 => 'Green',
3 => 'Pink',
4 => 'Black',
5 => 'Red',
6 => 'Orange',
7 => 'Yellow',
8 => 'Dark Purple',
9 => 'Brown',
10 => 'Peach',
11 => 'Dark Green',
12 => 'Light Blue',
13 => 'Light Green',
14 => 'Gray',
15 => 'Aqua'
);
say $objHtml->Tr($objHtml->td('Username:'), $objHtml->td($objHtml->textfield(-placeholder => 'Enter your name', -type => 'text', -name => 'username', -maxlength => 12)));
say $objHtml->Tr($objHtml->td('Password:'), $objHtml->td($objHtml->textfield(-placeholder => 'Enter your password', -type => 'password', -name => 'password', -maxlength => 20)));
say $objHtml->Tr($objHtml->td('Repeat Password:'), $objHtml->td($objHtml->textfield(-placeholder => 'Enter your password again', -type => 'password', -name => 'passwordtwo', -maxlength => 20)));
say $objHtml->Tr($objHtml->td('Colour:'), $objHtml->td($objHtml->popup_menu(-name => 'colour', -values => [sort keys %arrColours], -labels => \%arrColours)));
say $objHtml->Tr($objHtml->td($objHtml->submit(-value => 'Submit')));
say $objHtml->end_table;
say $objHtml->end_form;
say $objHtml->end_center;
say $objHtml->end_html;
}
method error($strError) {
my $strBoldError = $objHtml->b($strError);
my $strErrorStatement = $objHtml->p($strBoldError);
say $strErrorStatement;
exit;
}
I've changed the file permission to 755 and checked the syntax and its all fine.
Is there something I'm not seeing? All the error log says is "End of script output before headers".
Error log:
Error log as per request:
[Thu Dec 24 02:56:38.929902 2015] [mpm_event:notice] [pid 15417:tid 140140605220736] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Thu Dec 24 02:56:38.929965 2015] [core:notice] [pid 15417:tid 140140605220736] AH00094: Command line: '/usr/sbin/apache2'
[Thu Dec 24 02:59:21.946307 2015] [mpm_event:notice] [pid 15417:tid 140140605220736] AH00491: caught SIGTERM, shutting down
[Thu Dec 24 02:59:22.986351 2015] [mpm_event:notice] [pid 15569:tid 139751035283328] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Thu Dec 24 02:59:22.986419 2015] [core:notice] [pid 15569:tid 139751035283328] AH00094: Command line: '/usr/sbin/apache2'
[Thu Dec 24 03:06:59.763950 2015] [cgid:error] [pid 15574:tid 139750820263680] [client 106.208.29.16:26368] AH01265: attempt to invoke directory as script: /usr/lib/cgi-bin/
[Thu Dec 24 03:43:57.494621 2015] [mpm_event:notice] [pid 15569:tid 139751035283328] AH00491: caught SIGTERM, shutting down
[Thu Dec 24 03:43:58.542633 2015] [mpm_event:notice] [pid 18173:tid 140578810890112] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Thu Dec 24 03:43:58.542713 2015] [core:notice] [pid 18173:tid 140578810890112] AH00094: Command line: '/usr/sbin/apache2'
[Thu Dec 24 03:44:24.357114 2015] [cgid:error] [pid 18177:tid 140578633279232] [client 106.208.31.1:1569] AH01264: script not found or unable to stat: /var/www/cgi-bin/egister
[Thu Dec 24 03:44:43.672738 2015] [cgid:error] [pid 18235:tid 140578810890112] (13)Permission denied: AH01241: exec of '/var/www/cgi-bin/register/index.pl' failed
[Thu Dec 24 03:44:43.672938 2015] [cgid:error] [pid 18177:tid 140578599708416] [client 106.208.31.1:1591] End of script output before headers: index.pl
Can't locate Drivers/MySQL.pm in #INC (you may need to install the Drivers::MySQL module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /var/www/cgi-bin/register/index.pl line 11.
BEGIN failed--compilation aborted at /var/www/cgi-bin/register/index.pl line 11.
[Thu Dec 24 03:46:39.938441 2015] [cgid:error] [pid 18177:tid 140578507388672] [client 106.208.31.1:1635] End of script output before headers: index.pl
Can't locate Drivers/MySQL.pm in #INC (you may need to install the Drivers::MySQL module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /var/www/cgi-bin/register/index.pl line 11.
BEGIN failed--compilation aborted at /var/www/cgi-bin/register/index.pl line 11.
[Thu Dec 24 03:46:44.769191 2015] [cgid:error] [pid 18178:tid 140578448639744] [client 106.208.31.1:1645] End of script output before headers: index.pl
Can't locate Data/Alias.pm in #INC (you may need to install the Data::Alias module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/share/perl/5.18.2/Method/Signatures.pm line 980.
Compilation failed in require at /var/www/cgi-bin/register/index.pl line 11.
BEGIN failed--compilation aborted at /var/www/cgi-bin/register/index.pl line 11.
[Thu Dec 24 03:54:02.681970 2015] [cgid:error] [pid 18178:tid 140578557744896] [client 106.208.31.1:1836] End of script output before headers: index.pl
Can't locate Data/Alias.pm in #INC (you may need to install the Data::Alias module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/share/perl/5.18.2/Method/Signatures.pm line 980.
Compilation failed in require at /var/www/cgi-bin/register/index.pl line 11.
BEGIN failed--compilation aborted at /var/www/cgi-bin/register/index.pl line 11.
[Thu Dec 24 03:54:13.856406 2015] [cgid:error] [pid 18177:tid 140578574530304] [client 106.208.31.1:1856] End of script output before headers: index.pl
[Thu Dec 24 03:59:20.898641 2015] [cgid:error] [pid 18178:tid 140578566137600] [client 106.208.31.1:1984] AH01264: script not found or unable to stat: /var/www/cgi-bin/register/register.pl
[Thu Dec 24 04:00:38.302010 2015] [cgid:error] [pid 19584:tid 140578810890112] (13)Permission denied: AH01241: exec of '/var/www/cgi-bin/register/register.pl' failed
[Thu Dec 24 04:00:38.302221 2015] [cgid:error] [pid 18178:tid 140578507388672] [client 106.208.31.1:2004] End of script output before headers: register.pl
[Thu Dec 24 04:01:01.468669 2015] [cgid:error] [pid 19585:tid 140578810890112] (13)Permission denied: AH01241: exec of '/var/www/cgi-bin/register/register.pl' failed
[Thu Dec 24 04:01:01.468947 2015] [cgid:error] [pid 18177:tid 140578448639744] [client 106.208.31.1:2017] End of script output before headers: register.pl
[Thu Dec 24 04:14:40.401399 2015] [cgid:error] [pid 19929:tid 140578810890112] (13)Permission denied: AH01241: exec of '/var/www/cgi-bin/register/register.pl' failed
[Thu Dec 24 04:14:40.401631 2015] [cgid:error] [pid 18177:tid 140578473817856] [client 106.208.88.238:21256] End of script output before headers: register.pl
[Thu Dec 24 04:15:11.473083 2015] [cgid:error] [pid 19932:tid 140578810890112] (13)Permission denied: AH01241: exec of '/var/www/cgi-bin/register/register.pl' failed
[Thu Dec 24 04:15:11.473309 2015] [cgid:error] [pid 18177:tid 140578448639744] [client 106.208.88.238:21259] End of script output before headers: register.pl
[Thu Dec 24 04:15:29.327062 2015] [cgid:error] [pid 19933:tid 140578810890112] (13)Permission denied: AH01241: exec of '/var/www/cgi-bin/register/register.pl' failed
[Thu Dec 24 04:15:29.327299 2015] [cgid:error] [pid 18178:tid 140578515781376] [client 106.208.88.238:21261] End of script output before headers: register.pl
Can't locate Data/Alias.pm in #INC (you may need to install the Data::Alias module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/share/perl/5.18.2/Method/Signatures.pm line 980.
Compilation failed in require at /var/www/cgi-bin/register/index.pl line 11.
BEGIN failed--compilation aborted at /var/www/cgi-bin/register/index.pl line 11.
[Thu Dec 24 04:26:55.088334 2015] [cgid:error] [pid 18177:tid 140578507388672] [client 106.208.88.238:21429] End of script output before headers: index.pl
Global symbol "$objHtml" requires explicit package name at /var/www/cgi-bin/register/register.pl line 9.
Global symbol "$arrConfig" requires explicit package name at /var/www/cgi-bin/register/register.pl line 10.
Global symbol "$objMysql" requires explicit package name at /var/www/cgi-bin/register/register.pl line 10.
Global symbol "$objCaptcha" requires explicit package name at /var/www/cgi-bin/register/register.pl line 10.
Global symbol "$objHtml" requires explicit package name at /var/www/cgi-bin/register/register.pl line 10.
Global symbol "$arrConfig" requires explicit package name at /var/www/cgi-bin/register/register.pl line 12.
Global symbol "$objCaptcha" requires explicit package name at /var/www/cgi-bin/register/register.pl line 12.
Global symbol "$objHtml" requires explicit package name at /var/www/cgi-bin/register/register.pl line 12.
Global symbol "$arrConfig" requires explicit package name at /var/www/cgi-bin/register/register.pl line 15.
Global symbol "$objMysql" requires explicit package name at /var/www/cgi-bin/register/register.pl line 15.
Global symbol "$objCaptcha" requires explicit package name at /var/www/cgi-bin/register/register.pl line 15.
Global symbol "$objHtml" requires explicit package name at /var/www/cgi-bin/register/register.pl line 15.
syntax error at /var/www/cgi-bin/register/register.pl line 15, near ") {"
/var/www/cgi-bin/register/register.pl has too many errors.
[Thu Dec 24 04:27:05.714035 2015] [cgid:error] [pid 18177:tid 140578498995968] [client 106.208.88.238:21431] End of script output before headers: register.pl
[Thu Dec 24 04:40:42.364455 2015] [mpm_event:notice] [pid 18173:tid 140578810890112] AH00494: SIGHUP received. Attempting to restart
[Thu Dec 24 04:40:42.416326 2015] [mpm_event:notice] [pid 18173:tid 140578810890112] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Thu Dec 24 04:40:42.416346 2015] [core:notice] [pid 18173:tid 140578810890112] AH00094: Command line: '/usr/sbin/apache2'
Can't locate Data/Alias.pm in #INC (you may need to install the Data::Alias module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/share/perl/5.18.2/Method/Signatures.pm line 980.
Compilation failed in require at /var/www/cgi-bin/register/index.pl line 11.
BEGIN failed--compilation aborted at /var/www/cgi-bin/register/index.pl line 11.
[Thu Dec 24 04:41:59.664833 2015] [cgid:error] [pid 21137:tid 140578591315712] [client 106.208.88.238:21717] End of script output before headers: index.pl
Can't locate Data/Alias.pm in #INC (you may need to install the Data::Alias module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/share/perl/5.18.2/Method/Signatures.pm line 980.
Compilation failed in require at /var/www/cgi-bin/register/index.pl line 11.
BEGIN failed--compilation aborted at /var/www/cgi-bin/register/index.pl line 11.
[Thu Dec 24 04:42:02.220502 2015] [cgid:error] [pid 21138:tid 140578549352192] [client 106.208.88.238:21718] End of script output before headers: index.pl
Can't locate Data/Alias.pm in #INC (you may need to install the Data::Alias module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/share/perl/5.18.2/Method/Signatures.pm line 980.
Compilation failed in require at /var/www/cgi-bin/register/index.pl line 11.
BEGIN failed--compilation aborted at /var/www/cgi-bin/register/index.pl line 11.
[Thu Dec 24 04:44:49.927410 2015] [cgid:error] [pid 21138:tid 140578566137600] [client 106.208.88.238:21721] End of script output before headers: index.pl
[Thu Dec 24 04:54:15.130660 2015] [mpm_event:notice] [pid 18173:tid 140578810890112] AH00491: caught SIGTERM, shutting down
[Thu Dec 24 04:54:16.170870 2015] [mpm_event:notice] [pid 21771:tid 139956861183872] AH00489: Apache/2.4.7 (Ubuntu) configured -- resuming normal operations
[Thu Dec 24 04:54:16.170948 2015] [core:notice] [pid 21771:tid 139956861183872] AH00094: Command line: '/usr/sbin/apache2'
[Thu Dec 24 05:02:30.290833 2015] [cgid:error] [pid 22814:tid 139956861183872] (13)Permission denied: AH01241: exec of '/usr/lib/cgi-bin/index.pl' failed
[Thu Dec 24 05:02:30.291121 2015] [cgid:error] [pid 21775:tid 139956550829824] [client 106.208.88.238:21885] End of script output before headers: index.pl
[Thu Dec 24 05:02:40.239370 2015] [cgid:error] [pid 22815:tid 139956861183872] (13)Permission denied: AH01241: exec of '/usr/lib/cgi-bin/index.pl' failed
[Thu Dec 24 05:02:40.239626 2015] [cgid:error] [pid 21776:tid 139956626364160] [client 106.208.88.238:21886] End of script output before headers: index.pl
Can't locate Drivers/MySQL.pm in #INC (you may need to install the Drivers::MySQL module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/lib/cgi-bin/index.pl line 9.
BEGIN failed--compilation aborted at /usr/lib/cgi-bin/index.pl line 9.
[Thu Dec 24 05:17:15.648064 2015] [cgid:error] [pid 21775:tid 139956592793344] [client 106.208.200.98:26239] End of script output before headers: index.pl
Can't locate Data/Alias.pm in #INC (you may need to install the Data::Alias module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/share/perl/5.18.2/Method/Signatures.pm line 980.
Compilation failed in require at /usr/lib/cgi-bin/index.pl line 9.
BEGIN failed--compilation aborted at /usr/lib/cgi-bin/index.pl line 9.
[Thu Dec 24 05:22:21.030515 2015] [cgid:error] [pid 21776:tid 139956500473600] [client 106.208.200.98:26268] End of script output before headers: index.pl
Can't locate Data/Alias.pm in #INC (you may need to install the Data::Alias module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/share/perl/5.18.2/Method/Signatures.pm line 980.
Compilation failed in require at /usr/lib/cgi-bin/index.pl line 9.
BEGIN failed--compilation aborted at /usr/lib/cgi-bin/index.pl line 9.
[Thu Dec 24 05:22:29.155624 2015] [cgid:error] [pid 21775:tid 139956643149568] [client 106.208.200.98:26270] End of script output before headers: index.pl
Can't locate Data/Alias.pm in #INC (you may need to install the Data::Alias module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/share/perl/5.18.2/Method/Signatures.pm line 980.
Compilation failed in require at /usr/lib/cgi-bin/index.pl line 9.
BEGIN failed--compilation aborted at /usr/lib/cgi-bin/index.pl line 9.
[Thu Dec 24 05:26:59.929825 2015] [cgid:error] [pid 21775:tid 139956601186048] [client 106.208.200.98:26304] End of script output before headers: index.pl
Can't locate Data/Alias.pm in #INC (you may need to install the Data::Alias module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/share/perl/5.18.2/Method/Signatures.pm line 980.
Compilation failed in require at /usr/lib/cgi-bin/index.pl line 9.
BEGIN failed--compilation aborted at /usr/lib/cgi-bin/index.pl line 9.
[Thu Dec 24 05:51:24.665808 2015] [cgid:error] [pid 21776:tid 139956525651712] [client 106.208.200.98:26704] End of script output before headers: index.pl
Can't locate Data/Alias.pm in #INC (you may need to install the Data::Alias module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/share/perl/5.18.2/Method/Signatures.pm line 980.
Compilation failed in require at /usr/lib/cgi-bin/index.pl line 9.
BEGIN failed--compilation aborted at /usr/lib/cgi-bin/index.pl line 9.
[Thu Dec 24 05:53:44.378650 2015] [cgid:error] [pid 21776:tid 139956592793344] [client 106.208.200.98:26740] End of script output before headers: index.pl
Can't locate Data/Alias.pm in #INC (you may need to install the Data::Alias module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/share/perl/5.18.2/Method/Signatures.pm line 980.
Compilation failed in require at /usr/lib/cgi-bin/index.pl line 9.
BEGIN failed--compilation aborted at /usr/lib/cgi-bin/index.pl line 9.
[Thu Dec 24 05:53:47.788531 2015] [cgid:error] [pid 21776:tid 139956584400640] [client 106.208.200.98:26741] End of script output before headers: index.pl
Can't locate Data/Alias.pm in #INC (you may need to install the Data::Alias module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/share/perl/5.18.2/Method/Signatures.pm line 980.
Compilation failed in require at /usr/lib/cgi-bin/index.pl line 9.
BEGIN failed--compilation aborted at /usr/lib/cgi-bin/index.pl line 9.
[Thu Dec 24 06:01:51.924274 2015] [cgid:error] [pid 21775:tid 139956508866304] [client 106.208.200.98:26845] End of script output before headers: index.pl
Can't locate Data/Alias.pm in #INC (you may need to install the Data::Alias module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/share/perl/5.18.2/Method/Signatures.pm line 980.
Compilation failed in require at /usr/lib/cgi-bin/index.pl line 9.
BEGIN failed--compilation aborted at /usr/lib/cgi-bin/index.pl line 9.
[Thu Dec 24 06:14:41.811638 2015] [cgid:error] [pid 21776:tid 139956525651712] [client 106.208.8.87:37448] End of script output before headers: index.pl
[Thu Dec 24 06:20:34.074040 2015] [cgid:error] [pid 25176:tid 139956861183872] (8)Exec format error: AH01241: exec of '/usr/lib/cgi-bin/index.pl' failed
[Thu Dec 24 06:20:34.074226 2015] [cgid:error] [pid 21776:tid 139956753745664] [client 106.208.8.87:37575] End of script output before headers: index.pl
[Thu Dec 24 06:20:36.556068 2015] [cgid:error] [pid 25177:tid 139956861183872] (8)Exec format error: AH01241: exec of '/usr/lib/cgi-bin/index.pl' failed
[Thu Dec 24 06:20:36.556361 2015] [cgid:error] [pid 21776:tid 139956668327680] [client 106.208.8.87:37576] End of script output before headers: index.pl
[Thu Dec 24 06:22:25.511908 2015] [cgid:error] [pid 25178:tid 139956861183872] (8)Exec format error: AH01241: exec of '/usr/lib/cgi-bin/index.pl' failed
[Thu Dec 24 06:22:25.512111 2015] [cgid:error] [pid 21776:tid 139956659934976] [client 106.208.8.87:37584] End of script output before headers: index.pl
[Thu Dec 24 06:22:41.714336 2015] [cgid:error] [pid 25179:tid 139956861183872] (8)Exec format error: AH01241: exec of '/usr/lib/cgi-bin/Drivers/MySQL.pm' failed
[Thu Dec 24 06:22:41.714585 2015] [cgid:error] [pid 21776:tid 139956651542272] [client 106.208.8.87:37585] End of script output before headers: MySQL.pm
[Thu Dec 24 06:29:55.940279 2015] [cgid:error] [pid 25401:tid 139956861183872] (8)Exec format error: AH01241: exec of '/usr/lib/cgi-bin/Drivers/MySQL.pm' failed
[Thu Dec 24 06:29:55.940485 2015] [cgid:error] [pid 21776:tid 139956626364160] [client 106.208.8.87:37713] End of script output before headers: MySQL.pm
[Thu Dec 24 06:29:58.537769 2015] [cgid:error] [pid 25402:tid 139956861183872] (8)Exec format error: AH01241: exec of '/usr/lib/cgi-bin/Drivers/MySQL.pm' failed
[Thu Dec 24 06:29:58.538022 2015] [cgid:error] [pid 21776:tid 139956609578752] [client 106.208.8.87:37714] End of script output before headers: MySQL.pm
[Thu Dec 24 06:30:07.320777 2015] [cgid:error] [pid 25403:tid 139956861183872] (8)Exec format error: AH01241: exec of '/usr/lib/cgi-bin/index.pl' failed
[Thu Dec 24 06:30:07.320967 2015] [cgid:error] [pid 21776:tid 139956601186048] [client 106.208.8.87:37715] End of script output before headers: index.pl
Here are the important parts of your error log:
Can't locate Drivers/MySQL.pm in #INC (you may need to install the
Drivers::MySQL module) (#INC contains: /etc/perl
/usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5
/usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18
/usr/local/lib/site_perl .) at /var/www/cgi-bin/register/index.pl line
11. BEGIN failed--compilation aborted at /var/www/cgi-bin/register/index.pl line 11.
And:
Can't locate Data/Alias.pm in #INC (you may need to install the
Data::Alias module) (#INC contains: /etc/perl
/usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5
/usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18
/usr/local/lib/site_perl .) at
/usr/local/share/perl/5.18.2/Method/Signatures.pm line 980.
Compilation failed in require at /var/www/cgi-bin/register/index.pl
line 11. BEGIN failed--compilation aborted at
/var/www/cgi-bin/register/index.pl line 11
There's are two modules called Drivers::MySQL and Data::Alias missing. By missing I mean one of these two situations is true:
The module isn't installed on this server.
The module is installed on this server, but it isn't in one of the directories where Perl looks for libraries.
The error message gives you the list of directories where Perl looks for libraries (it's in the variable called #INC).
You have two options for fixing it. Either move the local copy of the module to one of the directories in #INC or (probably better) adjust #INC to include the directory where your module is. This is usually done with a use lib statement. For example:
use lib ('/path/to/the/directory/that/includes/Drivers',
'/path/to/the/directory/that/includes/Data');
Check your perl version by typing perl -v in the terminal. If it is 5.20< , you should install perl module CGI.pm since it has been removed from the core perl bundle.
In the top portion of your perl code, you had written as
use strict;
use warnings;
use CGI;
use Method::Signatures;
use Digest::MD5 qw(md5_hex);
use Drivers::MySQL;
use feature qw(say);
print header(); #########
my %arrConfig = (
dbHost => '127.0.0.1',
dbName => 'Luna',
dbUser => 'root',
dbPass => 'password123'
);
my $objHtml = CGI->new; #########
my $objMysql = MySQL->new;
As far as I know, it should be written as follows:
use strict;
use warnings;
use CGI;
use Method::Signatures;
use Digest::MD5 qw(md5_hex);
use Drivers::MySQL;
use feature qw(say);
my $objHtml = CGI->new; #########
print $objHtml->header(); #########
my %arrConfig = (
dbHost => '127.0.0.1',
dbName => 'Luna',
dbUser => 'root',
dbPass => 'password123'
);
my $objMysql = MySQL->new;
Hope this will work fine...
Please run following command to know if there any other syntax error in the perl using following command perl -c . It will help you identify any missing modules in the server.
From your log:
Can't locate Drivers/MySQL.pm in #INC (you may need to install the Drivers::MySQL module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /var/www/cgi-bin/register/index.pl line 11.
BEGIN failed--compilation aborted at /var/www/cgi-bin/register/index.pl line 11.
You need to install the Drivers::MySQL module.
Hopefully cpanm Drivers::MySQL will do that, but cpan has more instructions.
You have a similar issue with Data::Alias.
I've got an AWS EC2 instance running a flask app through apache.
I've installed boto via pip
I've got a wsgi file set up and if my flask app is a simple hello world it works fine:
#This works
from flask import Flask
app = Flask(__name__)
#app.route("/hello")
def hello():
return "Hello World"
if __name__ == "__main__":
app.run(host='0.0.0.0',port=80)
#http://<PUBLIC_IP>.ap-southeast-2.compute.amazonaws.com/hello
#Hello World
But if I try to import boto:
from boto import dynamodb2
from boto.dynamodb2.table import Table
When I visit http://.ap-southeast-2.compute.amazonaws.com/hello
I get an internal server error. Checking the logs reveals this
[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142] mod_wsgi (pid=2988): Target WSGI script '/var/www/myservice/myservice.wsgi' cannot be loaded as Python module.
[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142] mod_wsgi (pid=2988): Exception occurred processing WSGI script '/var/www/myservice/myservice.wsgi'.
[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142] Traceback (most recent call last):
[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142] File "/var/www/myservice/myservice.wsgi", line 4, in <module>
[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142] from myservice import app as application
[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142] File "/var/www/myservice/myservice.py", line 6, in <module>
[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142] from boto import dynamodb2
[Thu Aug 06 03:20:50 2015] [error] [client 203.220.19.142] ImportError: No module named boto
Even though I've already installed boto (pip install boto)
How can I fix this?
I searched yum for related stuff and by running:
yum install python26-boto.noarch
I fixed the issue
I have Python 2.7 installed with ampps. I tried to modify python.conf to make it point to another installation of Python 3.3 but it leads to errors in Apache start up.
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonPath "C:/Python33/Lib;C:/Python33/Lib/site-packages;C:/Python33/DLLs"
WSGIPythonHome "C:/Python33"
It generates the following error:
[Fri Aug 15 01:48:38.114336 2014] [mpm_winnt:notice] [pid 6084:tid 412] AH00418: Parent: Created child process 5592
File "C:/Python33\lib\site.py", line 173
file=sys.stderr)
^
SyntaxError: invalid syntax
[Fri Aug 15 01:48:39.146395 2014] [mpm_winnt:crit] [pid 6084:tid 412] AH00419: master_main: create child process failed. Exiting.
I am getting an error when I run the apache server through my client after going through the log I understood that the mod_wsgi uses python 2.6 during compiling and uses python 2.7 for running. After some research in the Internet I followed the below steps:
You have to recompile mod-python and/or mod-wsgi.
Remove mods
apt-get remove libapache2-mod-python libapache2-mod-wsgi
Get dependencies
apt-get build-dep libapache2-mod-python libapache2-mod-wsgi
Build mod-python
mkdir /tmp/python
cd /tmp/python
apt-get source libapache2-mod-python
cd libapache2-mod-python-[x.x.x]
dpkg-buildpackage -rfakeroot -b
Build mod-wsgi
mkdir /tmp/wsgi
cd /tmp/wsgi
apt-get source libapache2-mod-wsgi
cd mod-wsgi-[x.x.x]
dpkg-buildpackage -rfakeroot -b
Install newly compiled packages
dpkg -i /tmp/python/libapache2-mod-python-[x.x].deb /tmp/wsgi/libapache2-mod-wsgi-[x.x].deb
It was of no use, now the version has changed to 3.2, I am worried about the space being consumed through the above steps and now the compiling python has changes to python 3.2 from 2.6 but the python used for running is still 2.7. please help me with what to do ? to get back my apache server running successfully.
error.log::::
[Wed Aug 21 11:48:11 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Wed Aug 21 11:48:11 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Wed Aug 21 11:48:11 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Wed Aug 21 11:48:36 2013] [notice] caught SIGTERM, shutting down
[Wed Aug 21 22:48:29 2013] [error] child process 1226 still did not exit, sending a SIGKILL
[Wed Aug 21 22:48:30 2013] [notice] caught SIGTERM, shutting down
[Wed Aug 21 22:56:17 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Wed Aug 21 22:56:17 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Wed Aug 21 22:56:17 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Thu Aug 22 01:32:12 2013] [notice] caught SIGTERM, shutting down
[Thu Aug 22 01:32:26 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Thu Aug 22 01:32:26 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Thu Aug 22 01:32:26 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Thu Aug 22 04:04:48 2013] [notice] child pid 11212 exit signal Segmentation fault (11)
[Thu Aug 22 04:04:48 2013] [notice] caught SIGTERM, shutting down
[Thu Aug 22 04:04:56 2013] [notice] mod_python: Creating 8 session mutexes based on 6 max processes and 25 max threads.
[Thu Aug 22 04:04:56 2013] [notice] mod_python: using mutex_directory /tmp
[Thu Aug 22 04:04:56 2013] [warn] mod_wsgi: Compiled for Python/3.2.3.
[Thu Aug 22 04:04:56 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Thu Aug 22 04:04:56 2013] [notice] Apache/2.2.22 (Ubuntu) mod_python/3.3.1 Python/2.7.3 mod_wsgi/3.3 configured -- resuming normal operations
Thank you
Don't load mod_python and mod_wsgi at the same time if you don't need to. They are likely compiled against different Python versions. See the following for an explanation of the mismatch you are seeing.
http://code.google.com/p/modwsgi/wiki/InstallationIssues#Python_Version_Mismatch
If you do need both, they must both be compiled for the same version.
These days there is generally no good reason to be using mod_python for new projects.
Just to add
I have uninstalled libapache2-mod-python
sudo apt-get remove libapache2-mod-python
which I have installed
then I have overcome the above error
[Thu Aug 22 01:32:26 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Thu Aug 22 01:32:26 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
All, I'm trying to deploy a simple page using flask/apache on a digitalocean server. It all works fine locally, but not on the server.
__init__.py contains the statement:
from flask.ext.wtf import Form,TextField
try_me.wsgi is:
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/try_me/")
from try_me import app as application
application.secret_key = 'Add your secret key'
Getting the following error (from /var/log/apache2/error.log):
[Mon Jul 29 14:16:50 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Mon Jul 29 14:16:50 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Mon Jul 29 14:16:50 2013] [notice] Apache/2.2.22 (Debian) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Mon Jul 29 14:16:57 2013] [error] [client 74.66.8.166] mod_wsgi (pid=2920): Target WSGI script '/var/www/try_me/try_me.wsgi' cannot be loaded as Python module.
[Mon Jul 29 14:16:57 2013] [error] [client 74.66.8.166] mod_wsgi (pid=2920): Exception occurred processing WSGI script '/var/www/try_me/try_me.wsgi'.
[Mon Jul 29 14:16:57 2013] [error] [client 74.66.8.166] Traceback (most recent call last):
[Mon Jul 29 14:16:57 2013] [error] [client 74.66.8.166] File "/var/www/try_me/try_me.wsgi", line 7, in <module>
[Mon Jul 29 14:16:57 2013] [error] [client 74.66.8.166] from try_me import app as application
[Mon Jul 29 14:16:57 2013] [error] [client 74.66.8.166] File "/var/www/try_me/try_me/__init__.py", line 4, in <module>
[Mon Jul 29 14:16:57 2013] [error] [client 74.66.8.166] from flask.ext.wtf import Form
[Mon Jul 29 14:16:57 2013] [error] [client 74.66.8.166] File "/usr/local/lib/python2.7/dist-packages/flask/exthook.py", line 87, in load_module
[Mon Jul 29 14:16:57 2013] [error] [client 74.66.8.166] raise ImportError('No module named %s' % fullname)
[Mon Jul 29 14:16:57 2013] [error] [client 74.66.8.166] ImportError: No module named flask.ext.wtf
I was able to import manually in a python interpreter (under virtualenv):
Python 2.7.3 (default, Jan 2 2013, 16:53:07)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from flask.ext.wtf import Form
>>> Form
<class 'flask_wtf.form.Form'>
Any ideas on how to proceed here?
SOLUTION (Following Cathy's advice above, and dAnjou below), virtualenv must be activated from the wsgi script. Adding activate_this execution solved the problem:
#!/usr/bin/python
activate_this = '/var/www/try_me/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import sys
..