简体   繁体   中英

How to allow perl cgi-bin script to run system commands?

I'm currently working on developing a perl script as a cgi-bin in my website.

I successfully config it to run without any issues. Here are the config I have done for it.

ScriptAlias /cgi-bin/ /my web directory/cgi-bin/
    <Directory /my web directory/cgi-bin/>
        Options ExecCGI
        AddHandler cgi-script cgi pl
    </Directory>

But I cannot use system() function in the script to run some system commands. It gives Can't exec, No such file or directory or Permission denied.

What should add you apache config to allow cgi-bin to run those commands?

Thank you!

Ok, Found the problem and fixed.

Steps I followed:

apt-get install apache2-suexec-custom
a2enmod suexec
/etc/init.d/apache2 reload

Then go to website apache config and added SuexecUserGroup asterisk asterisk in here asterisk is the use that I didn't have the permission to run commands.

Then go to /etc/apache2/suexec/www-data and you will see 2 un-comment lines. We need to give correct absolute path for cgi-bin and alias path for the cgi-bin. By default it have /var/www and public_html/cgi-bin .

That's it. This fixed my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM