2

I am running Ubuntu 16.04 as a virtual machine. I have Apache2 2.4.18 installed.

I have a folder with cgi scripts that I want to use. To do that I placed a symlink to that folder in /usr/lib/cgi-bin.

When I call the script from firefox localhost/cgi-bin/linkName/script.cgi I get 403 forbidden error.

When I copy the script.cgi to /usr/lib/cgi-bin and call it with localhost/cgi-bin/script.cgi, it runs but gives a software error since it lacks the surrounding files and folders.

I have chmod 777 both the link and the folder it links to but I still get the error.

What else can I do other than coping all the files and folders into /usr/lib/cgi-bin?

1 Answer 1

0

It is because the symbolic link points to a directory, which is located outside of directories listed in your "virtualhost".conf files. So you need to write down necessary directives in your /etc/apache2/apache2.conf (or /etc/apache2/sites-available/*.conf or /etc/apache2/conf-available/*.conf) file to access /usr/lib/cgi-bin. Something like:

Alias /cgi-bin/linkName /usr/lib/cgi-bin

<Directory /usr/lib/cgi-bin>
        Options +ExecCGI FollowSymLinks
        DirectoryIndex disabled
        AllowOverride None
        Require all granted
        # etc..   
</Directory>

And maybe (but I'm not sure that it's necessary): sudo chown -R www-data:www-data /usr/lib/cgi-bin.

If you make Alias /cgi-bin/linkName /usr/lib/cgi-bin you do not need to make a symbolic link.

8
  • I have added what you suggested (without the etc...) to /etc/apache2/sites-available/000-default.conf. Now I see the content of the script but not what it should display Dec 1, 2016 at 9:00
  • @GadiArmony, I have edit my post. Require all granted was dropped. Also you need to systemctl restart apache2.service.
    – pa4080
    Dec 1, 2016 at 9:02
  • So is it works?
    – pa4080
    Dec 1, 2016 at 9:03
  • I have all 4 lines and it still show the text of the script Dec 1, 2016 at 9:04
  • 1
    Thank you, That almost did it. The cgi scripts might be written in a way that is not compatible with the new apache2. I ended up copying the whole folder into /usr/lib/cgi-bin Dec 1, 2016 at 13:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .