How to run cgi script on apache server

后端 未结 3 803
遥遥无期
遥遥无期 2020-12-11 08:40

This is my program:

[root@localhost cgi-bin]# locate first.pl 
/home/Ram/Desktop/work/first.pl
/usr/local/apache2/cgi-bin/first.pl
[root@localhost cgi-bin]#          


        
3条回答
  •  攒了一身酷
    2020-12-11 09:14

    You basically need to change two files after installing apache2 on linux.

    Go to terminal and set the following configs:

    1. sudo vim /etc/apache2/sites-enabled/000-default.conf and add the follwing:

      
          SetHandler perl-script
          PerlResponseHandler ModPerl::PerlRun
          Options +ExecCGI
          PerlSendHeader On
      
      
    2. sudo vim /etc/apache2/apache2.conf and add the following:

      AddHandler cgi-script .cgi .pl Options FollowSymLinks ExecCGI AllowOverride None

    After adding these two config changes, write a perl script, place it in the cgi-bin directory, and then give it sufficient privileges (sudo chmod 755 )

    Finally, restart apache2: sudo apache2ctl restart

    Screenshots:

提交回复
热议问题