tel7
Posts: 8
Joined: Fri Oct 19, 2018 5:52 am
Location: NZ

Webserver LAMP (Perl) Errors

Fri Oct 19, 2018 7:21 am

Hi Pi experts,

Last month I bought a Raspberry Pi 3 B+, put NOOBS_v2_8_2 on it and installed Raspbian (not Lite).

I’m wanting to try using it as a local webserver, so I presume I have to put some kind of LAMP on it, and I need the “P” to be Perl. (I don’t need PHP yet, but might want it someday.)

The only resource I’ve found for this so far is this YouTube video from 2013 and its accompanying summary of commands. As you can see, it uses nginx instead of Apache (fine by me) and includes PHP and Perl.
My current problem is that when I get to this step:

Code: Select all

service perl-fcgi start
I get this error:

Code: Select all

    ‘Job for perl-fcgi.service failed because the control process exited with error code.
    See "systemctl status perl-fcgi.service" and "journalctl -xe" for details.’
(Yes, I am root, courtesy of the “sudo -i” command at the top of the command summary.)
So I tried entering the commands in the error message to see if they would help with trouble shooting. Here they are:

1st command:

Code: Select all

[email protected]:~# systemctl status perl-fcgi.service
● perl-fcgi.service - LSB: Start the Perl FastCGI daemon.
   Loaded: loaded (/etc/init.d/perl-fcgi; generated; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2018-10-19 20:10:35 NZDT; 41s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1324 ExecStart=/etc/init.d/perl-fcgi start (code=exited, status=1/FAILURE)

Oct 19 20:10:34 raspberrypi systemd[1]: Starting LSB: Start the Perl FastCGI daemon....
Oct 19 20:10:34 raspberrypi su[1325]: Successful su for www-data by root
Oct 19 20:10:34 raspberrypi su[1325]: + ??? root:www-data
Oct 19 20:10:34 raspberrypi su[1325]: pam_unix(su:session): session opened for user www-data by (uid=0)
Oct 19 20:10:35 raspberrypi perl-fcgi[1324]: This account is currently not available.
Oct 19 20:10:35 raspberrypi systemd[1]: perl-fcgi.service: Control process exited, code=exited status=1
Oct 19 20:10:35 raspberrypi systemd[1]: Failed to start LSB: Start the Perl FastCGI daemon..
Oct 19 20:10:35 raspberrypi systemd[1]: perl-fcgi.service: Unit entered failed state.
Oct 19 20:10:35 raspberrypi systemd[1]: perl-fcgi.service: Failed with result 'exit-code'.

2nd command:

Code: Select all

[email protected]:~# journalctl -xe
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit user-33.slice has finished shutting down.
Oct 19 19:32:36 raspberrypi kernel: Under-voltage detected! (0x00050005)
Oct 19 19:32:40 raspberrypi kernel: Voltage normalised (0x00000000)
Oct 19 19:39:01 raspberrypi CRON[1001]: pam_unix(cron:session): session opened f
Oct 19 19:39:01 raspberrypi CRON[1005]: (root) CMD (  [ -x /usr/lib/php/sessionc
Oct 19 19:39:01 raspberrypi CRON[1001]: pam_unix(cron:session): session closed f
Oct 19 19:39:03 raspberrypi systemd[1]: Starting Clean php session files...
-- Subject: Unit phpsessionclean.service has begun start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit phpsessionclean.service has begun starting up.
Oct 19 19:39:03 raspberrypi systemd[1]: Started Clean php session files.
-- Subject: Unit phpsessionclean.service has finished start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit phpsessionclean.service has finished starting up.
--
-- The start-up result is done.
lines 2327-2349/2349 (END)

I see the video actually used this command

Code: Select all

/etc/init.d/perl-fcgi start
and a comment appears in the video to say it's the same as "service perl-fcgi start".
This is the error I get from the "/etc/init.d/perl-fcgi start" command:

Code: Select all

[email protected]:~# /etc/init.d/perl-fcgi start
This account is currently not available.

So based on 2 of the above messages it looks as if the www-data account may not be available for some reason?


Questions:
Q1. Any ideas what the problem is and how to resolve it?
Q2. Alternatively, any suggestions of alternative LAMP (with Perl) tutorials I could use?
Q3. How much of a problem does the "Under-voltage detected!" in the output from the "journalctl -xe" command, represent and could it be causing my problem?
Q4. Is "Troubleshooting" the best place for this kind of questions, or should I use "Advanced"?

Thanks very much!
Terry

Andyroo
Posts: 466
Joined: Sat Jun 16, 2018 12:49 am
Location: Side of the hill in Lincolnshire

Re: Webserver LAMP (Perl) Errors

Fri Oct 19, 2018 12:17 pm

I think this part of the log ‘perl-fcgi[1324]: This account is currently not available’ is due to the www-data user not being able to log on as it’s a service account as you get a similar error from SSH when the wrong account is used.

Problem is I have no skills in either Perl or Nginx :oops: but did find these install instructions https://nginxlibrary.com/perl-fastcgi/ that may work!
Need Pi spray - these things are breeding in my house...

User avatar
DougieLawson
Posts: 34167
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Webserver LAMP (Perl) Errors

Fri Oct 19, 2018 8:47 pm

I'd already got fcgiwrap installed so I added this to my /etc/nginx/sites-available/default configuration

Code: Select all

        location ~ \.pl|cgi$ {
                try_files $uri =404;
                gzip off;
                fastcgi_pass  unix:/var/run/fcgiwrap.socket;
                fastcgi_index index.pl;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

These are the fcgi components I've got installed
sudo apt install fcgiwrap libfcgi-bin libfcgi-perl
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

tel7
Posts: 8
Joined: Fri Oct 19, 2018 5:52 am
Location: NZ

Re: Webserver LAMP (Perl) Errors

Sat Oct 20, 2018 6:20 am

Thank you both for taking the time to read my issue and respond.

@Andy,
Thanks very much for that link. Unfortunately when I got to the "/etc/init.d/perl-fcgi start" step, I ran into the same problem, i.e. "This account is currently not available.". I temporarily worked around it by changing the www-data's shell in /etc/passwd from "/usr/sbin/nologin" to "/usr/bash", and although that allowed me to serve Perl webpages, I wasn't sure of the security implications so I emailed the tutorial author. While waiting, I reinstalled Raspbian and looked at Dougie's answer.

@Dougie,
Your setup seemed to work well, thank you! At first glance I thought it must be missing a lot of commands, but I think all I had to add was "apt install nginx" and I was all go, with no www-data user issues! Thank you!
I note the only difference between the code you added to /etc/nginx/sites-available/default and the code from the YouTube tutorial and the one Andy linked to, is, yours has this line:
"fastcgi_pass unix:/var/run/fcgiwrap.socket;"
while the other 2 have this line:
"fastcgi_pass 127.0.0.1:8999;"
Any ideas what the effective difference/implications is/are?


And if anyone can suggest a tutorial for adding PHPMyAdmin + MySQL (replaced by MariaDB now I believe) in such a way that it will work with Perl, that would be appreciated. I've seen several tutorials for installing them, but they don't seem to mention Perl so I'm not sure they'll work with it.


Thanks again.
Terry
NZ

User avatar
DougieLawson
Posts: 34167
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Webserver LAMP (Perl) Errors

Sat Oct 20, 2018 10:41 am

fccgiwrap uses a AF_UNIX socket. Your set-up uses a AF_INET socket.
For comms between processes on the same Linux system an AF_UNIX socket has a lower CPU cost.

The stuff I've got works for both Perl & PHP.

Code: Select all

        location ~ \.pl|cgi$ {
                try_files $uri =404;
                gzip off;
                fastcgi_pass  unix:/var/run/fcgiwrap.socket;
                fastcgi_index index.pl;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

        #
        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                fastcgi_pass  unix:/var/run/fcgiwrap.socket;
                fastcgi_index index.php;
                include fastcgi_params;
        }

I had to add

Code: Select all

#!/usr/bin/php
to the top of my php programs and make them executable with chmod 755 mypgm.php
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

tel7
Posts: 8
Joined: Fri Oct 19, 2018 5:52 am
Location: NZ

Re: Webserver LAMP (Perl) Errors

Sun Oct 21, 2018 11:34 pm

Thanks again for that, Dougie.

I've never seen the need to have the shebang line at the top of PHP scripts before, or execute access, but I guess I could work with that, though it might be a pain in some situations (e.g. if I have a huge application like WordPress which needs those changes on all its PHP scripts). I know I could make the chmod changes en masse with a one-liner Linux command, and insert the shebang lines en masse with a Perl one-liner, but still a hassle each time I install new PHP code. Any suggestions there?

Also, do you know of any suggested tutorials on how to install PHP in a way which is compatible with what you've supplied? I've seen this kind of thing, for installing nginx + PHP, but it may be more of an alternative than a compatible option.

UPDATE:
What I've now done is:
- Reinstalled Raspbian
- Followed this tutorial to install nginx+PHP: https://pimylifeup.com/raspberry-pi-nginx/
- Followed this tutorial to install MariaDB+PHPMyAdmin: https://pimylifeup.com/raspberry-pi-mysql-phpmyadmin/
- Run your "apt install fcgiwrap" command.
- Added your Perl block to /etc/nginx/sites-available/default
- Restarted nginx.
And it looks as if all might be working (though I haven't tested much yet).

So my question is, am I going to need to install libfcgi-bin and/or libfcgi-perl for anything now? How can I test whether I need them?

Thanks again.

User avatar
DougieLawson
Posts: 34167
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Webserver LAMP (Perl) Errors

Mon Oct 22, 2018 9:22 am

Simple way to test PHP is

Code: Select all

<?PHP phpinfo()?>
Simple way to test Perl is

Code: Select all

#!/usr/bin/perl

use strict;
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

print header;
print start_html("Environment");

foreach my $key (sort(keys(%ENV))) {
    print "$key = $ENV{$key}<br>\n";
}

print end_html;
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

tel7
Posts: 8
Joined: Fri Oct 19, 2018 5:52 am
Location: NZ

Re: Webserver LAMP (Perl) Errors

Mon Oct 22, 2018 9:32 am

Thanks Dougie,
I'd basically done those two tests already and they were successful so does that mean that I don't need to install either of these?:
libfcgi-bin
libfcgi-perl
Last edited by tel7 on Tue Oct 23, 2018 10:30 pm, edited 1 time in total.

User avatar
DougieLawson
Posts: 34167
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Webserver LAMP (Perl) Errors

Mon Oct 22, 2018 10:49 am

Install fcgiwrap and it will pull in just the stuff it needs.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

tel7
Posts: 8
Joined: Fri Oct 19, 2018 5:52 am
Location: NZ

Re: Webserver LAMP (Perl) Errors

Mon Oct 22, 2018 10:53 am

OK, thanks again.

Return to “Troubleshooting”