34ce9a92d1d35b5a2e324edae77fe92c8e61a904
By:
cole007

Ubuntu 14.04/Serverpilot running CGI Scripts

November 3, 2016 119 views
Perl Apache Nginx Ubuntu

Got an odd Serverpilot query.

My client wants FTP access to a subfolder on the site - loathe to let them have full access so created a user with access to /home/FTPUSER and symlink to this from my /srv/users/serverpilot/apps/APPNAME/public/ folder so that they cannot access the system files for their main site, etc from a script.

PHP files from this folder are working fine but the client now wants to be able to run CGI/Perl scripts from this folder. I have tried following instructions at https://serverpilot.io/community/articles/how-to-create-a-cgi-bin-directory.html (updating the document root) but can't get CGI or Perl scripts to run, instead being returned as plain text.

Any thoughts?

Cole

2 Answers
jsamuelsp November 3, 2016
Accepted Answer

You might need to have that custom user's home directory somewhere under /srv/users due to that being the suexec root in ServerPilot's Apache build. That is, maybe Apache is refusing to execute these scripts for security reasons because they're under /home/CUSTOMUSER.

Alternatively, you could give your client access to a specific subdirectory by running a very simple FTP server. Take a look at this article (just added yesterday):

https://serverpilot.io/community/articles/how-to-run-a-simple-ftp-server.html

As a former Perl/CGI developer this brings back memories 😃

It's been a while since I've set up apache to run Perl scripts but there are three primary things you'll need to do:

1.) Make sure that mod_perl is installed and enabled:

apt-get update
apt-get install libapache2-mod-perl2
a2enmod perl
service apache2 restart

2.) In your configuration make sure that the directory where the scripts will be has the ExecCGI option.

3.) Make sure the scripts have execute permissions for the www-data user that apache runs under.

Have another answer? Share your knowledge.