Enabling PHP in Leopard

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gordon

    Enabling PHP in Leopard

    I want to use my new Macbook Pro as a development platform for work,
    so I went looking for info on installing Apache, PHP, Postgres, etc on
    Leopard. I discovered in my search that Apache and PHP are already
    installed by default, but disabled, so I'd just have to enable the
    already-installed versions.

    Getting Apache up and running was no problem. You just check "enable
    web sharing" in the Sharing control panel and away you go. getting
    PHP working is proving not to be so simple.

    I made sure Apache was not running, started a terminal and followed
    the instructions I had found online. Namely I CD'd to /etc/apache2,
    then sudo pico httpd.conf and uncommented the line that loads
    php5_module.so. I saved my changes and restarted the server. No
    joy. The server was serving HTML no trouble, but PHP files were not
    executing and just echoing their source code back.

    I'm obviously missing something, but what? Do I need to add the PHP
    MIME type to httpd.conf? None of the websites with instructions for
    enabling PHP mentioned needing to do so. Or is there some other step
    that I'm missing?
  • Rik Wasmus

    #2
    Re: Enabling PHP in Leopard

    On Tue, 11 Dec 2007 14:43:05 +0100, Gordon <gordon.mcvey@n tlworld.com>
    wrote:
    I want to use my new Macbook Pro as a development platform for work,
    so I went looking for info on installing Apache, PHP, Postgres, etc on
    Leopard. I discovered in my search that Apache and PHP are already
    installed by default, but disabled, so I'd just have to enable the
    already-installed versions.
    >
    Getting Apache up and running was no problem. You just check "enable
    web sharing" in the Sharing control panel and away you go. getting
    PHP working is proving not to be so simple.
    >
    I made sure Apache was not running, started a terminal and followed
    the instructions I had found online. Namely I CD'd to /etc/apache2,
    then sudo pico httpd.conf and uncommented the line that loads
    php5_module.so. I saved my changes and restarted the server. No
    joy. The server was serving HTML no trouble, but PHP files were not
    executing and just echoing their source code back.
    >
    I'm obviously missing something, but what? Do I need to add the PHP
    MIME type to httpd.conf? None of the websites with instructions for
    enabling PHP mentioned needing to do so. Or is there some other step
    that I'm missing?
    <http://nl2.php.net/manual/en/install.macosx. bundled.php>
    (this still mentions php4, but you get the drift)

    Add these lines to httpd.conf, and then restart the server:

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

    And possibly add 'index.php' to the DirectoryIndex directive.
    --
    Rik Wasmus

    Comment

    • David Empson

      #3
      Re: Enabling PHP in Leopard

      Rik Wasmus <luiheidsgoeroe @hotmail.comwro te:
      On Tue, 11 Dec 2007 14:43:05 +0100, Gordon <gordon.mcvey@n tlworld.com>
      wrote:
      >
      I want to use my new Macbook Pro as a development platform for work,
      so I went looking for info on installing Apache, PHP, Postgres, etc on
      Leopard. I discovered in my search that Apache and PHP are already
      installed by default, but disabled, so I'd just have to enable the
      already-installed versions.

      Getting Apache up and running was no problem. You just check "enable
      web sharing" in the Sharing control panel and away you go. getting
      PHP working is proving not to be so simple.

      I made sure Apache was not running, started a terminal and followed
      the instructions I had found online. Namely I CD'd to /etc/apache2,
      then sudo pico httpd.conf and uncommented the line that loads
      php5_module.so. I saved my changes and restarted the server. No
      joy. The server was serving HTML no trouble, but PHP files were not
      executing and just echoing their source code back.
      That's exactly what I did.

      I had the same problem the first time I tried to execute some PHP but it
      seemed to correct itself subsequently (no idea why). It is working fine
      at the moment.

      I initially thought there was a problem recognising the "<?" prefix but
      it was OK with "<?php", or it didn't like jumping straight into PHP
      without an HTML header, as it worked after I made those changes. On
      further investigation these turned out to be red herrings. I have a test
      file called info.php which works fine and it contains the following
      single line:

      <? phpinfo(); ?>

      Mac OS X 10.5.1, Apache 2.2.6 (standard) and PHP 5.2.4 (standard).

      I've kept a copy of the original httpd.conf and comparing it to my
      version, the only relevant change I made was uncommenting the
      "LoadModule php5_module ..." line.

      I can't see anything strange in /var/log/apache2/error_log around the
      time I enabled PHP. It shows Apache starting up with PHP loaded, which
      it didn't the previous time.
      I'm obviously missing something, but what? Do I need to add the PHP
      MIME type to httpd.conf? None of the websites with instructions for
      enabling PHP mentioned needing to do so. Or is there some other step
      that I'm missing?
      >
      <http://nl2.php.net/manual/en/install.macosx. bundled.php>
      (this still mentions php4, but you get the drift)
      >
      Add these lines to httpd.conf, and then restart the server:
      >
      AddType application/x-httpd-php .php
      AddType application/x-httpd-php-source .phps
      >
      And possibly add 'index.php' to the DirectoryIndex directive.
      None of that is necessary. There is a file /etc/apache2/other/php5.conf
      which contains all of those instructions, conditional on the PHP5 module
      being loaded. All files in 'other' are included by httpd.conf.

      --
      David Empson
      dempson@actrix. gen.nz

      Comment

      • Captain Paralytic

        #4
        Re: Enabling PHP in Leopard

        On 11 Dec, 14:24, demp...@actrix. gen.nz (David Empson) wrote:
        I initially thought there was a problem recognising the "<?" prefix but
        it was OK with "<?php"
        You may have to spcifically set short tags on. Or better, don't use
        'em at all.

        Comment

        • Rik Wasmus

          #5
          Re: Enabling PHP in Leopard

          On Tue, 11 Dec 2007 15:24:27 +0100, David Empson <dempson@actrix .gen.nz>
          wrote:
          Rik Wasmus <luiheidsgoeroe @hotmail.comwro te:
          >On Tue, 11 Dec 2007 14:43:05 +0100, Gordon <gordon.mcvey@n tlworld.com>
          >wrote:
          >>
          I want to use my new Macbook Pro as a development platform for work,
          so I went looking for info on installing Apache, PHP, Postgres, etc on
          Leopard. I discovered in my search that Apache and PHP are already
          installed by default, but disabled, so I'd just have to enable the
          already-installed versions.
          >
          Getting Apache up and running was no problem. You just check "enable
          web sharing" in the Sharing control panel and away you go. getting
          PHP working is proving not to be so simple.
          >
          I made sure Apache was not running, started a terminal and followed
          the instructions I had found online. Namely I CD'd to /etc/apache2,
          then sudo pico httpd.conf and uncommented the line that loads
          php5_module.so. I saved my changes and restarted the server. No
          joy. The server was serving HTML no trouble, but PHP files were not
          executing and just echoing their source code back.
          >
          That's exactly what I did.
          >
          I had the same problem the first time I tried to execute some PHP but it
          seemed to correct itself subsequently (no idea why). It is working fine
          at the moment.
          >
          I initially thought there was a problem recognising the "<?" prefix but
          it was OK with "<?php", or it didn't like jumping straight into PHP
          without an HTML header, as it worked after I made those changes.
          It's called short_open_tags , and it's been turned OFF by default in PHP 5,
          ON in PHP 4. You can set it in php.ini, but I'd advice you never to rely
          on short tags, it will ensure portability, and it's easier to output an
          XML header.
          --
          Rik Wasmus

          Comment

          • David Empson

            #6
            Re: Enabling PHP in Leopard

            Rik Wasmus <luiheidsgoeroe @hotmail.comwro te:
            On Tue, 11 Dec 2007 15:24:27 +0100, David Empson <dempson@actrix .gen.nz>
            wrote:
            Rik Wasmus <luiheidsgoeroe @hotmail.comwro te:
            I made sure Apache was not running, started a terminal and followed
            the instructions I had found online. Namely I CD'd to /etc/apache2,
            then sudo pico httpd.conf and uncommented the line that loads
            php5_module.so. I saved my changes and restarted the server. No
            joy. The server was serving HTML no trouble, but PHP files were not
            executing and just echoing their source code back.
            That's exactly what I did.

            I had the same problem the first time I tried to execute some PHP but it
            seemed to correct itself subsequently (no idea why). It is working fine
            at the moment.

            I initially thought there was a problem recognising the "<?" prefix but
            it was OK with "<?php", or it didn't like jumping straight into PHP
            without an HTML header, as it worked after I made those changes.
            >
            It's called short_open_tags , and it's been turned OFF by default in PHP 5,
            ON in PHP 4. You can set it in php.ini, but I'd advice you never to rely
            on short tags, it will ensure portability, and it's easier to output an
            XML header.
            Ok, thanks for the heads-up.

            As far as I can tell, Apple's PHP 5 build is pointing at /etc to locate
            its configuration file:

            --with-config-file-path=/etc

            There is no php.ini in that directory, so this suggests that PHP 5 is
            running with default configuration, but perhaps Apple has modified the
            defaults.

            There is a /etc/php.ini.default . This file contains the line:

            short_open_tag = On

            I also see that my phpinfo() output says short_open_tags is On.

            It looks like the same file is present in a fresh install of Mac OS X
            10.5, so all evidence says that Apple's default configuration for PHP 5
            is to have short_open_tag On.

            This may be a side issue to Gordon's problem.

            --
            David Empson
            dempson@actrix. gen.nz

            Comment

            • Gordon

              #7
              Re: Enabling PHP in Leopard

              On Dec 11, 3:44 pm, demp...@actrix. gen.nz (David Empson) wrote:
              Rik Wasmus <luiheidsgoe... @hotmail.comwro te:
              On Tue, 11 Dec 2007 15:24:27 +0100, David Empson <demp...@actrix .gen.nz>
              wrote:
              Rik Wasmus <luiheidsgoe... @hotmail.comwro te:
              I made sure Apache was not running, started a terminal and followed
              the instructions I had found online. Namely I CD'd to /etc/apache2,
              then sudo pico httpd.conf and uncommented the line that loads
              php5_module.so. I saved my changes and restarted the server. No
              joy. The server was serving HTML no trouble, but PHP files were not
              executing and just echoing their source code back.
              >
              That's exactly what I did.
              >
              I had the same problem the first time I tried to execute some PHP but it
              seemed to correct itself subsequently (no idea why). It is working fine
              at the moment.
              >
              I initially thought there was a problem recognising the "<?" prefix but
              it was OK with "<?php", or it didn't like jumping straight into PHP
              without an HTML header, as it worked after I made those changes.
              >
              It's called short_open_tags , and it's been turned OFF by default in PHP 5,
              ON in PHP 4. You can set it in php.ini, but I'd advice you never to rely
              on short tags, it will ensure portability, and it's easier to output an
              XML header.
              >
              Ok, thanks for the heads-up.
              >
              As far as I can tell, Apple's PHP 5 build is pointing at /etc to locate
              its configuration file:
              >
              --with-config-file-path=/etc
              >
              There is no php.ini in that directory, so this suggests that PHP 5 is
              running with default configuration, but perhaps Apple has modified the
              defaults.
              >
              There is a /etc/php.ini.default . This file contains the line:
              >
              short_open_tag = On
              >
              I also see that my phpinfo() output says short_open_tags is On.
              >
              It looks like the same file is present in a fresh install of Mac OS X
              10.5, so all evidence says that Apple's default configuration for PHP 5
              is to have short_open_tag On.
              >
              This may be a side issue to Gordon's problem.
              >
              --
              David Empson
              demp...@actrix. gen.nz
              I don't think short tags are causing the problem, as both <?php
              phpinfo (); ?and <? phpinfo (); ?are failing to execute.

              Comment

              • tricky

                #8
                Re: Enabling PHP in Leopard

                On 2007-12-11 13:51:15 +0000, "Rik Wasmus" <luiheidsgoeroe @hotmail.comsai d:
                On Tue, 11 Dec 2007 14:43:05 +0100, Gordon <gordon.mcvey@n tlworld.com wrote:
                >
                >I want to use my new Macbook Pro as a development platform for work,
                >so I went looking for info on installing Apache, PHP, Postgres, etc on
                >Leopard. I discovered in my search that Apache and PHP are already
                >installed by default, but disabled, so I'd just have to enable the
                >already-installed versions.
                I know it does not exactly answer your post, but I use MAMP to test my
                PHP webpages and it works extremely well. It might tie you over until
                you can sort this mess out!


                --
                Replace vetsco with a well known supermarket chain

                Comment

                • Chris Ridd

                  #9
                  Re: Enabling PHP in Leopard

                  On 2007-12-11 17:25:43 +0000, tricky <rsvp@vetsco.ne tsaid:
                  On 2007-12-11 13:51:15 +0000, "Rik Wasmus" <luiheidsgoeroe @hotmail.comsai d:
                  >
                  >On Tue, 11 Dec 2007 14:43:05 +0100, Gordon <gordon.mcvey@n tlworld.com wrote:
                  >>
                  >>I want to use my new Macbook Pro as a development platform for work,
                  >>so I went looking for info on installing Apache, PHP, Postgres, etc on
                  >>Leopard. I discovered in my search that Apache and PHP are already
                  >>installed by default, but disabled, so I'd just have to enable the
                  >>already-installed versions.
                  >
                  I know it does not exactly answer your post, but I use MAMP to test my
                  PHP webpages and it works extremely well. It might tie you over until
                  you can sort this mess out!
                  It should be fairly straightforward to see what Apache's *really* doing
                  with a spot of playing with Instruments.app .

                  Cheers,

                  Chris

                  Comment

                  • David Empson

                    #10
                    Re: Enabling PHP in Leopard

                    Gordon <gordon.mcvey@n tlworld.comwrot e:
                    On Dec 11, 3:44 pm, demp...@actrix. gen.nz (David Empson) wrote:
                    Rik Wasmus <luiheidsgoe... @hotmail.comwro te:
                    On Tue, 11 Dec 2007 15:24:27 +0100, David Empson <demp...@actrix .gen.nz>
                    wrote:
                    Rik Wasmus <luiheidsgoe... @hotmail.comwro te:
                    I made sure Apache was not running, started a terminal and followed
                    the instructions I had found online. Namely I CD'd to /etc/apache2,
                    then sudo pico httpd.conf and uncommented the line that loads
                    php5_module.so. I saved my changes and restarted the server. No
                    joy. The server was serving HTML no trouble, but PHP files were not
                    executing and just echoing their source code back.
                    [snip]
                    I don't think short tags are causing the problem, as both <?php
                    phpinfo (); ?and <? phpinfo (); ?are failing to execute.
                    Have a look at the files I mentioned in earlier posts.

                    In particular: what do you see in "/var/log/apache2/error_log" ?

                    Look for lines resembling this:

                    [Wed Nov 07 04:21:39 2007] [notice] Apache/2.2.6 (Unix) mod_ssl/2.2.6
                    OpenSSL/0.9.7l DAV/2 configured -- resuming normal operations

                    The above line is what I got when I first started Apache2 _without_ PHP.

                    [Wed Nov 28 23:33:58 2007] [notice] Apache/2.2.6 (Unix) mod_ssl/2.2.6
                    OpenSSL/0.9.7l DAV/2 PHP/5.2.4 configured -- resuming normal operations

                    The above line is what I got when I started Apache2 after enabling PHP.
                    Note that "PHP/5.2.4" appeared in the log entry.

                    This will show whether Apache thinks it is loading the PHP module. Also
                    look for any other error messages around recent Apache startups.

                    Next, have a look in /etc for any files relating to PHP. I have a
                    "php.ini.defaul t" but no "php.ini". If you have a php.ini, it might have
                    been retained from an earlier system (after an upgrade or migration) and
                    it might not be compatible with PHP 5. If so, I'd expect to see an error
                    message appearing somewhere in a log.

                    If there is nothing in the Apache error log, check the Console and
                    system.log around the time of Apache's last startup (as given by the
                    timestamp in the Apache error log).

                    --
                    David Empson
                    dempson@actrix. gen.nz

                    Comment

                    • Toby A Inkster

                      #11
                      Re: Enabling PHP in Leopard

                      tricky wrote:
                      I know it does not exactly answer your post, but I use MAMP to test my
                      PHP webpages and it works extremely well.
                      Yeah, I tend to use MAMP too. I've got the built-in Apache running too.

                      --
                      Toby A Inkster BSc (Hons) ARCS
                      [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
                      [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 4 days, 9:11.]

                      Sharing Music with Apple iTunes

                      Comment

                      • Warren Oates

                        #12
                        Re: Enabling PHP in Leopard

                        In article
                        <f314f6cb-8dd1-4317-afaf-296528e1c4b3@e1 0g2000prf.googl egroups.com>,
                        Gordon <gordon.mcvey@n tlworld.comwrot e:
                        I want to use my new Macbook Pro as a development platform for work,
                        so I went looking for info on installing Apache, PHP, Postgres, etc on
                        Leopard. I discovered in my search that Apache and PHP are already
                        installed by default, but disabled, so I'd just have to enable the
                        already-installed versions.
                        >
                        Getting Apache up and running was no problem. You just check "enable
                        web sharing" in the Sharing control panel and away you go. getting
                        PHP working is proving not to be so simple.
                        >
                        I made sure Apache was not running, started a terminal and followed
                        the instructions I had found online. Namely I CD'd to /etc/apache2,
                        then sudo pico httpd.conf and uncommented the line that loads
                        php5_module.so. I saved my changes and restarted the server. No
                        joy. The server was serving HTML no trouble, but PHP files were not
                        executing and just echoing their source code back.
                        >
                        I'm obviously missing something, but what? Do I need to add the PHP
                        MIME type to httpd.conf? None of the websites with instructions for
                        enabling PHP mentioned needing to do so. Or is there some other step
                        that I'm missing?
                        You have to serve your files from ~/Sites, and then do

                        http://[your.ip.address]/test.php

                        Once you've uncommented that line like you did, and restarted the
                        server, that's all you need to do. Put a test.php file in ~/Sites that
                        has

                        <?php
                        phpinfo();
                        ?>

                        in it, and all should be well. The pages have to be _served_, you can't
                        just drag a php file into the browser window. Note that if you add

                        Listen: 127.0.0.1:80

                        to httpd.conf (almost at the very beginning), you can do



                        and view your pages.
                        --
                        W. Oates

                        Comment

                        • Jerry Stuckle

                          #13
                          Re: Enabling PHP in Leopard

                          Gordon wrote:
                          On Dec 11, 3:44 pm, demp...@actrix. gen.nz (David Empson) wrote:
                          >Rik Wasmus <luiheidsgoe... @hotmail.comwro te:
                          >>On Tue, 11 Dec 2007 15:24:27 +0100, David Empson <demp...@actrix .gen.nz>
                          >>wrote:
                          >>>Rik Wasmus <luiheidsgoe... @hotmail.comwro te:
                          >>>>>I made sure Apache was not running, started a terminal and followed
                          >>>>>the instructions I had found online. Namely I CD'd to /etc/apache2,
                          >>>>>then sudo pico httpd.conf and uncommented the line that loads
                          >>>>>php5_modul e.so. I saved my changes and restarted the server. No
                          >>>>>joy. The server was serving HTML no trouble, but PHP files were not
                          >>>>>executin g and just echoing their source code back.
                          >>>That's exactly what I did.
                          >>>I had the same problem the first time I tried to execute some PHP but it
                          >>>seemed to correct itself subsequently (no idea why). It is working fine
                          >>>at the moment.
                          >>>I initially thought there was a problem recognising the "<?" prefix but
                          >>>it was OK with "<?php", or it didn't like jumping straight into PHP
                          >>>without an HTML header, as it worked after I made those changes.
                          >>It's called short_open_tags , and it's been turned OFF by default in PHP 5,
                          >>ON in PHP 4. You can set it in php.ini, but I'd advice you never to rely
                          >>on short tags, it will ensure portability, and it's easier to output an
                          >>XML header.
                          >Ok, thanks for the heads-up.
                          >>
                          >As far as I can tell, Apple's PHP 5 build is pointing at /etc to locate
                          >its configuration file:
                          >>
                          >--with-config-file-path=/etc
                          >>
                          >There is no php.ini in that directory, so this suggests that PHP 5 is
                          >running with default configuration, but perhaps Apple has modified the
                          >defaults.
                          >>
                          >There is a /etc/php.ini.default . This file contains the line:
                          >>
                          >short_open_t ag = On
                          >>
                          >I also see that my phpinfo() output says short_open_tags is On.
                          >>
                          >It looks like the same file is present in a fresh install of Mac OS X
                          >10.5, so all evidence says that Apple's default configuration for PHP 5
                          >is to have short_open_tag On.
                          >>
                          >This may be a side issue to Gordon's problem.
                          >>
                          >--
                          >David Empson
                          >demp...@actrix .gen.nz
                          >
                          I don't think short tags are causing the problem, as both <?php
                          phpinfo (); ?and <? phpinfo (); ?are failing to execute.
                          >
                          After making the changes did you fully stop and restart Apache?
                          Reloading isn't good enough - all that does is reload the configuration.
                          It won't load new modules.

                          --
                          =============== ===
                          Remove the "x" from my email address
                          Jerry Stuckle
                          JDS Computer Training Corp.
                          jstucklex@attgl obal.net
                          =============== ===

                          Comment

                          • Gordon

                            #14
                            Re: Enabling PHP in Leopard

                            On Dec 12, 3:52 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
                            Gordon wrote:
                            On Dec 11, 3:44 pm, demp...@actrix. gen.nz (David Empson) wrote:
                            Rik Wasmus <luiheidsgoe... @hotmail.comwro te:
                            >On Tue, 11 Dec 2007 15:24:27 +0100, David Empson <demp...@actrix .gen.nz>
                            >wrote:
                            >>Rik Wasmus <luiheidsgoe... @hotmail.comwro te:
                            >>>>I made sure Apache was not running, started a terminal and followed
                            >>>>the instructions I had found online. Namely I CD'd to /etc/apache2,
                            >>>>then sudo pico httpd.conf and uncommented the line that loads
                            >>>>php5_module .so. I saved my changes and restarted the server. No
                            >>>>joy. The server was serving HTML no trouble, but PHP files were not
                            >>>>executing and just echoing their source code back.
                            >>That's exactly what I did.
                            >>I had the same problem the first time I tried to execute some PHP but it
                            >>seemed to correct itself subsequently (no idea why). It is working fine
                            >>at the moment.
                            >>I initially thought there was a problem recognising the "<?" prefix but
                            >>it was OK with "<?php", or it didn't like jumping straight into PHP
                            >>without an HTML header, as it worked after I made those changes.
                            >It's called short_open_tags , and it's been turned OFF by default in PHP 5,
                            >ON in PHP 4. You can set it in php.ini, but I'd advice you never to rely
                            >on short tags, it will ensure portability, and it's easier to output an
                            >XML header.
                            Ok, thanks for the heads-up.
                            >
                            As far as I can tell, Apple's PHP 5 build is pointing at /etc to locate
                            its configuration file:
                            >
                            --with-config-file-path=/etc
                            >
                            There is no php.ini in that directory, so this suggests that PHP 5 is
                            running with default configuration, but perhaps Apple has modified the
                            defaults.
                            >
                            There is a /etc/php.ini.default . This file contains the line:
                            >
                            short_open_tag = On
                            >
                            I also see that my phpinfo() output says short_open_tags is On.
                            >
                            It looks like the same file is present in a fresh install of Mac OS X
                            10.5, so all evidence says that Apple's default configuration for PHP 5
                            is to have short_open_tag On.
                            >
                            This may be a side issue to Gordon's problem.
                            >
                            --
                            David Empson
                            demp...@actrix. gen.nz
                            >
                            I don't think short tags are causing the problem, as both <?php
                            phpinfo (); ?and <? phpinfo (); ?are failing to execute.
                            >
                            After making the changes did you fully stop and restart Apache?
                            Reloading isn't good enough - all that does is reload the configuration.
                            It won't load new modules.
                            >
                            --
                            =============== ===
                            Remove the "x" from my email address
                            Jerry Stuckle
                            JDS Computer Training Corp.
                            jstuck...@attgl obal.net
                            =============== ===
                            I restarted the whole computer.

                            Comment

                            Working...