Configuring Apache 2.4 for CGI on FreeBSD












0














I am trying to run CGI on FreeBSD 9.2.




  1. I installed Apache 2.4 (pkg install apache24)

  2. Configured it to load CGI module.

  3. Also, I did chmod a+x on files in cgi-bin directory.


And when I connect to the server to a test CGI script, the server printed this error message.



AH01215: (13)Permission denied: exec of '/usr/local/www/apache24/cgi-bin/test-cgi' failed
End of script output before headers: test-cgi


What's wrong and how to fix this problem?










share|improve this question
















bumped to the homepage by Community 34 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    0














    I am trying to run CGI on FreeBSD 9.2.




    1. I installed Apache 2.4 (pkg install apache24)

    2. Configured it to load CGI module.

    3. Also, I did chmod a+x on files in cgi-bin directory.


    And when I connect to the server to a test CGI script, the server printed this error message.



    AH01215: (13)Permission denied: exec of '/usr/local/www/apache24/cgi-bin/test-cgi' failed
    End of script output before headers: test-cgi


    What's wrong and how to fix this problem?










    share|improve this question
















    bumped to the homepage by Community 34 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0







      I am trying to run CGI on FreeBSD 9.2.




      1. I installed Apache 2.4 (pkg install apache24)

      2. Configured it to load CGI module.

      3. Also, I did chmod a+x on files in cgi-bin directory.


      And when I connect to the server to a test CGI script, the server printed this error message.



      AH01215: (13)Permission denied: exec of '/usr/local/www/apache24/cgi-bin/test-cgi' failed
      End of script output before headers: test-cgi


      What's wrong and how to fix this problem?










      share|improve this question















      I am trying to run CGI on FreeBSD 9.2.




      1. I installed Apache 2.4 (pkg install apache24)

      2. Configured it to load CGI module.

      3. Also, I did chmod a+x on files in cgi-bin directory.


      And when I connect to the server to a test CGI script, the server printed this error message.



      AH01215: (13)Permission denied: exec of '/usr/local/www/apache24/cgi-bin/test-cgi' failed
      End of script output before headers: test-cgi


      What's wrong and how to fix this problem?







      freebsd apache-httpd cgi






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 24 '16 at 19:32









      Fedor Dikarev

      993310




      993310










      asked Jan 18 '14 at 9:17









      Eonil

      1,52262128




      1,52262128





      bumped to the homepage by Community 34 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 34 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          2 Answers
          2






          active

          oldest

          votes


















          0














          The problem is shell. Apache 4.2's test CGI scripts are written for bash, and FreeBSD comes with default shell csh. The scripts are not compatible with csh, so it fails, and Apache spits an error.



          To fix this, (1) install bash, and (2) add shebang to specify bash location.



          Because FreeBSD userland is explicitly separated from base, installed bash will be placed in /usr/local/bin rather than /bin. So add a shebang like this.



          #!/usr/local/bin


          And then, the script will work well.






          share|improve this answer

















          • 1




            I'm not sure this is quite correct. It's been a long time since I've run Apache but I recall the same error the first time I tried it and switching shells, in this way, was not the solution. If you notice the error says, "Permission denied..." which is not an error from using the wrong shell and installing a package should have resolved that if the shell was the problem.
            – Rob
            Apr 15 '15 at 12:21





















          0














          You also need "others read" permissions:



          > ls -l test-cgi 
          -r-x-----x 1 root wheel 779 Dec 11 2004 test-cgi
          > curl -s -w "%{http_code}n" -o /dev/null http://localhost:8080/cgi-bin/test-cgi
          500
          > chmod o+r test-cgi ; ls -l test-cgi
          -r-x---r-x 1 root wheel 779 Dec 11 2004 test-cgi
          > curl -s -w "%{http_code}n" -o /dev/null http://localhost:8080/cgi-bin/test-cgi
          200





          share|improve this answer





















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "106"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f109866%2fconfiguring-apache-2-4-for-cgi-on-freebsd%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            The problem is shell. Apache 4.2's test CGI scripts are written for bash, and FreeBSD comes with default shell csh. The scripts are not compatible with csh, so it fails, and Apache spits an error.



            To fix this, (1) install bash, and (2) add shebang to specify bash location.



            Because FreeBSD userland is explicitly separated from base, installed bash will be placed in /usr/local/bin rather than /bin. So add a shebang like this.



            #!/usr/local/bin


            And then, the script will work well.






            share|improve this answer

















            • 1




              I'm not sure this is quite correct. It's been a long time since I've run Apache but I recall the same error the first time I tried it and switching shells, in this way, was not the solution. If you notice the error says, "Permission denied..." which is not an error from using the wrong shell and installing a package should have resolved that if the shell was the problem.
              – Rob
              Apr 15 '15 at 12:21


















            0














            The problem is shell. Apache 4.2's test CGI scripts are written for bash, and FreeBSD comes with default shell csh. The scripts are not compatible with csh, so it fails, and Apache spits an error.



            To fix this, (1) install bash, and (2) add shebang to specify bash location.



            Because FreeBSD userland is explicitly separated from base, installed bash will be placed in /usr/local/bin rather than /bin. So add a shebang like this.



            #!/usr/local/bin


            And then, the script will work well.






            share|improve this answer

















            • 1




              I'm not sure this is quite correct. It's been a long time since I've run Apache but I recall the same error the first time I tried it and switching shells, in this way, was not the solution. If you notice the error says, "Permission denied..." which is not an error from using the wrong shell and installing a package should have resolved that if the shell was the problem.
              – Rob
              Apr 15 '15 at 12:21
















            0












            0








            0






            The problem is shell. Apache 4.2's test CGI scripts are written for bash, and FreeBSD comes with default shell csh. The scripts are not compatible with csh, so it fails, and Apache spits an error.



            To fix this, (1) install bash, and (2) add shebang to specify bash location.



            Because FreeBSD userland is explicitly separated from base, installed bash will be placed in /usr/local/bin rather than /bin. So add a shebang like this.



            #!/usr/local/bin


            And then, the script will work well.






            share|improve this answer












            The problem is shell. Apache 4.2's test CGI scripts are written for bash, and FreeBSD comes with default shell csh. The scripts are not compatible with csh, so it fails, and Apache spits an error.



            To fix this, (1) install bash, and (2) add shebang to specify bash location.



            Because FreeBSD userland is explicitly separated from base, installed bash will be placed in /usr/local/bin rather than /bin. So add a shebang like this.



            #!/usr/local/bin


            And then, the script will work well.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 18 '14 at 9:17









            Eonil

            1,52262128




            1,52262128








            • 1




              I'm not sure this is quite correct. It's been a long time since I've run Apache but I recall the same error the first time I tried it and switching shells, in this way, was not the solution. If you notice the error says, "Permission denied..." which is not an error from using the wrong shell and installing a package should have resolved that if the shell was the problem.
              – Rob
              Apr 15 '15 at 12:21
















            • 1




              I'm not sure this is quite correct. It's been a long time since I've run Apache but I recall the same error the first time I tried it and switching shells, in this way, was not the solution. If you notice the error says, "Permission denied..." which is not an error from using the wrong shell and installing a package should have resolved that if the shell was the problem.
              – Rob
              Apr 15 '15 at 12:21










            1




            1




            I'm not sure this is quite correct. It's been a long time since I've run Apache but I recall the same error the first time I tried it and switching shells, in this way, was not the solution. If you notice the error says, "Permission denied..." which is not an error from using the wrong shell and installing a package should have resolved that if the shell was the problem.
            – Rob
            Apr 15 '15 at 12:21






            I'm not sure this is quite correct. It's been a long time since I've run Apache but I recall the same error the first time I tried it and switching shells, in this way, was not the solution. If you notice the error says, "Permission denied..." which is not an error from using the wrong shell and installing a package should have resolved that if the shell was the problem.
            – Rob
            Apr 15 '15 at 12:21















            0














            You also need "others read" permissions:



            > ls -l test-cgi 
            -r-x-----x 1 root wheel 779 Dec 11 2004 test-cgi
            > curl -s -w "%{http_code}n" -o /dev/null http://localhost:8080/cgi-bin/test-cgi
            500
            > chmod o+r test-cgi ; ls -l test-cgi
            -r-x---r-x 1 root wheel 779 Dec 11 2004 test-cgi
            > curl -s -w "%{http_code}n" -o /dev/null http://localhost:8080/cgi-bin/test-cgi
            200





            share|improve this answer


























              0














              You also need "others read" permissions:



              > ls -l test-cgi 
              -r-x-----x 1 root wheel 779 Dec 11 2004 test-cgi
              > curl -s -w "%{http_code}n" -o /dev/null http://localhost:8080/cgi-bin/test-cgi
              500
              > chmod o+r test-cgi ; ls -l test-cgi
              -r-x---r-x 1 root wheel 779 Dec 11 2004 test-cgi
              > curl -s -w "%{http_code}n" -o /dev/null http://localhost:8080/cgi-bin/test-cgi
              200





              share|improve this answer
























                0












                0








                0






                You also need "others read" permissions:



                > ls -l test-cgi 
                -r-x-----x 1 root wheel 779 Dec 11 2004 test-cgi
                > curl -s -w "%{http_code}n" -o /dev/null http://localhost:8080/cgi-bin/test-cgi
                500
                > chmod o+r test-cgi ; ls -l test-cgi
                -r-x---r-x 1 root wheel 779 Dec 11 2004 test-cgi
                > curl -s -w "%{http_code}n" -o /dev/null http://localhost:8080/cgi-bin/test-cgi
                200





                share|improve this answer












                You also need "others read" permissions:



                > ls -l test-cgi 
                -r-x-----x 1 root wheel 779 Dec 11 2004 test-cgi
                > curl -s -w "%{http_code}n" -o /dev/null http://localhost:8080/cgi-bin/test-cgi
                500
                > chmod o+r test-cgi ; ls -l test-cgi
                -r-x---r-x 1 root wheel 779 Dec 11 2004 test-cgi
                > curl -s -w "%{http_code}n" -o /dev/null http://localhost:8080/cgi-bin/test-cgi
                200






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 24 '16 at 19:08









                Fedor Dikarev

                993310




                993310






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f109866%2fconfiguring-apache-2-4-for-cgi-on-freebsd%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Accessing regular linux commands in Huawei's Dopra Linux

                    Can't connect RFCOMM socket: Host is down

                    Kernel panic - not syncing: Fatal Exception in Interrupt