I reciently installed PHP5 and a new version of Apache on my linux system. After a bit of fiddling around, I was able to get PHP to work.

However what I can't figure out is that my simple php scripts (even the "hello") will only run if I copy them into the cgi-bin directory of my apache document root (/var/www/cgi-bin).

For example if I run localhost/hello.php, I get the Not Found /hello.php not found, but if I copy the hello.php into cgi-bin directory, and then do localhost/cgi-bin/hello.php, the script will run fine.

What did I do wrong.

Thanks for the help.

Tom

    What changes to Apache's httpd.conf file have you made in order to install PHP?

      Thanks for the reply. I added the following
      LoadModule php5_module modules/libphp5.so

      DirectoryIndex index.php

      AddType application/x-httpd-php .php .phtml
      AddType application/x-httpd-php-source .phps

      AddHandler application/x-httpd=php .php
      Action application/x-httpd-x-httpd-php /usr/local/bin/php

        Try getting rid of those last two lines and just using the AddType lines.

          I commented out the last two lines, and the php script did not work at all.

          I uncommented the Action application line and the php script acted as it did before, so apparently the first of the two lines is not doing anything.

          Tom

            I'm at a loss here. As the manual page for [man]install.unix.apache2[/man] says, the only thing you need to add to your Apache httpd.conf file is:

            LoadModule php5_module modules/libphp5.so
            
            AddType application/x-httpd-php .php .phtml
            AddType application/x-httpd-php-source .phps

            and then restart Apache.

            What happens if you do this and try to access a .php script via a browser?

              If I comment out the two lines mentioned and try to run the same php script I get this error

              Internal Server Error

              The server encountered an internal error or misconfiguration and was unable to complete your request.

              Please contact the server administrator, root@sbmsinc.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

              More information about this error may be available in the server error log.

                The error log says /var/www/sbmsinc/test.php not found or unable to stat

                  Out of curiosity, have you tried CHMOD'ing the test.php file to 755 ?

                    Sorry no difference.

                    This is a tough one! I am running out of things to try myself!!

                      Get XAMPP for Linux...it is in my signature.

                        7 days later

                        I basically gave up on RedHat, installed Ubuntu and everthing worked out of the box.

                          Write a Reply...