Results 1 to 6 of 6

Thread: Apache2 madening php error

  1. #1
    Join Date
    Jan 2007
    Beans
    27

    Apache2 madening php error

    I am pretty new at this, but I am trying to run apache server and I have a php test page in the sites-enabled directory that consists simply of the text:

    <?php
    phpinfo();
    echo "Hello World";
    ?>

    When I try to start apache2 I get the error:

    "apache2: Syntax error on line 298 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/sites-enabled/phptest.php: /etc/apache2/sites-enabled/phptest.php:1: <?php> was not closed.

    From what I can tell online, my PHP looks fine. Can anyone tell me what I am missing?

  2. #2
    Join Date
    Jul 2008
    Beans
    59

    Re: Apache2 madening php error

    That looks like it should work. You could try single quotes or use print rather than echo, but I think that should work. Try this:

    <?php
    phpinfo();
    echo 'Hello World';
    ?>

  3. #3
    Join Date
    Jan 2007
    Beans
    27

    Re: Apache2 madening php error

    I just tried it with the single quotes as you suggested, and I am getting the same error.

  4. #4
    Join Date
    Jul 2008
    Beans
    59

    Re: Apache2 madening php error

    My guess is you have something going on with your apache configuration. I say that because code you are typing is essentially THE test line. If you are configuring everything yourself, that is, without the default LAMP install, I would open the apache2.conf and see if anything seems fishy on line 298.

    I'm assuming you have tried it without the phpinfo() call and simply added it for feedback.

  5. #5
    Join Date
    Apr 2005
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Apache2 madening php error

    the location of your php file should not be the site-enabled folder.

    put your php file in /var/www/

    the sites-enabled folder typically houses symbolic links to conf files in sites-available. It should not contain php or html files.

    Apache's error is telling you that it is trying to read your php file as a configuration file for apache which is not what you want.

  6. #6
    Join Date
    Jan 2007
    Beans
    27

    Re: Apache2 madening php error

    Thanks Mbeach! I knew it had to be something dumb that I was doing wrong. I am trying to teach myself how to set up mysql and this was basically the very first step in making sure everything was installed. I must have mis-read the directions I found online.

    I moved the file to /var/www and now I can navigate to http://localhost/phptest.php

    Thanks again for the help.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •