Apache/PHP Failure

Discussion in 'Web Design and Development' started by andy9l, Aug 31, 2009.

  1. andy9l macrumors 68000

    Joined:
    Aug 31, 2009
    Location:
    England, UK
    #1
    Firstly, my PHP setup had magically destroyed itself when I came to load a site last night. To be fair, I hadn't used it in several months...but I got it up and running again.

    Today, I turn on the Mac, load up the same site I started working on last night, and apparently no PHP is executed...either Snow Leopard has some serious issue with restarts, or the mice have been at my computer again whilst I'm sleeping, because there's no way this situation is even slightly logical, or even possible.

    PHP is just in the source code of the site, like:

    Code:
    <? require_once 'headers.php'; ?>
    The HMTL works fine, and the index.php will go into safari without looking like a script ... but the PHP just gets shoved into the source code. Other pages on the site show the PHP code as text on the page. But it was working before I turned the computer off last night?!

    I can't make sense of this, I would really appreciate some help trying to figure out what has happened.

    I'm trying to load a PHP site located at /Users/Me/Sites/newsite, and no PHP is being executed, yet if I go to phpMyAdmin, at 'Users/Me/Sites/pma' the PHP and MySQL work together fine?!

    I'm lost. It doesn't make sense to me, and I'm honestly fed up of problems with Apache on OS X at the moment.

    As I said, any questions you have about my setup, or help/guidance would be MUCH appreciated. I'm so bored of problems at the moment.
     
  2. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #2
    Obviously the best long term solution is to switch to MAMP, a LAMP setup designed specifically for Mac OS X (Mac, Apache, MySQL, PHP). It works very reliably and does not interfere with your Mac setup.

    To try to help you with the current issue and without seeing your httpd.conf or knowing which version of PHP you're running or any error logs, so far I can only think of two things, and you might laugh when I suggest this first one:

    Instead of <? ...phpcode... ?> use <?php ...phpcode... ?>

    You see, when I upgraded to PHP5 series I noticed in php.ini that the "short_open_tag = On" was set to OFF. Set it to On and you can use either tag method -- restart Apache for any change to take effect.

    Also make sure the file extension of the script you're running (not the header.php, that's fine) actually ends is .php so the scripting is parsed properly. If it's not, change or [with caution] add the extension you're using to Apache's httpd.conf in this line which determines which file extensions are to be PHP parsed:

    Note: Adding .html or .htm will parse ALL such files regardless if PHP code exists on not, a serious performance hit on the server. But for dedicated localhost sandboxes it's been done before -- never in production, my .02.

    -jim
     
  3. andy9l thread starter macrumors 68000

    Joined:
    Aug 31, 2009
    Location:
    England, UK
    #3
    Right, major breakthrough! Thank-you.
    Still not working, HOWEVER... Short tags is the issue. How do I allow short tags?

    I've made a <?php phpinfo(); ?> file, and it works, whereas <? phpinfo(); ?> doesn't.

    Any ideas how I turn that little setting back 'on' ?

    Thank-you so much for the help.

    EDIT: I believe I've done it, but now MySQL is reporting errors. I'll try get this problem solved now :(
    Thank-you for the guidance.

    SECOND EDIT: MySQL error fixed, needed a port address. Some crazy stuff has happened since restarting my Mac then?! Weird how it was all fine last night.

    Thanks again
     
  4. trule macrumors 6502

    Joined:
    Mar 16, 2007
    #4
    IIRC each time you update Mac OS it trashes your PHP/Apache environment that you worked so hard on to get running.

    Download the sources or one of the MAMP/LAMP packages and re-install.
     
  5. scottlewis1978 macrumors newbie

    Joined:
    Aug 31, 2009
    #5

Share This Page