0

I have a macbook pro i5.
my understanding is that by default it should be able to serve php5.
i have uncommented the relevant line in /etc/apache2/httpd.conf

LoadModule php5_module        libexec/apache2/libphp5.so

I have restarted apache with

sudo apachectl -k restart

and when i try to access a file with a php extension, Apache prompts me to download the file. i.e. instead of processing the php and sending me html, it thinks i want to download the file....

when i look in apache error log i see this

[Fri Nov 12 10:16:14 2010] [notice] Apache/2.2.14 (Unix) PHP/5.3.2 mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 mod_wsgi/3.2 Python/2.6.1 configured -- resuming normal operations

so it looks like php5 is loading properly.

I'd like to know either:
How do i fix this?
or
How do I reinstall apache2 so that it's like i just installed the os?

thanks in advance


update @Zayne - the end of my httpd.conf has

Include /private/etc/apache2/other/*.conf

and i have a file /etc/apache2/other/php.conf with the contents

<IfModule php5_module>
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    <IfModule dir_module>
        DirectoryIndex index.html index.php
    </IfModule>
</IfModule>

@Zayne I've already copied php.ini.default to php.ini in the same folder. when i run

sudo apachectl configtest

i get

/usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument
httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName
Syntax OK

furthermore i decided to try

apachectl -M

which shows all loaded modules Most importantly in the list of loaded modules i got

Loaded Modules:
 php5_module (shared)

Since the module is being loaded, it seems like the issue has more to do with making apache use php engine to process the php files.... so something wrong with the ifmodule directive?

w-01
  • 215
  • 2
  • 12
  • Got the `apachectl configtest` info from the obvious place: http://httpd.apache.org/docs/2.2/programs/apachectl.html. I'd recommend changing your IfModule to look more like mine: `` - per another obvious piece of documentation (from http://httpd.apache.org/docs/2.0/mod/core.html#ifmodule): `The module name argument is the file name of the module, at the time it was compiled. For example, mod_rewrite.c.` – Zayne S Halsall Nov 14 '10 at 19:56
  • My Include is php5.conf, not just php.conf. Try copying the file and naming it php5.conf and see if that works for you. – eric.s Nov 14 '10 at 21:16

3 Answers3

1

Brand new Macbook, clean install, I did:

sudo cp /etc/php.ini.default /etc/php.ini

and uncommented the line in /etc/apache2/httpd.conf:

LoadModule php5_module        libexec/apache2/libphp5.so

then ran:

sudo apachectl restart

and it worked.

bouchard
  • 111
  • 2
0

You need to let apache know what to do with the .php extension files. So the configs should somewhere include lines similar to:

<IfModule mod_php5.c>
  AddType application/x-httpd-php .php .phtml .php3
  AddType application/x-httpd-php-source .phps
</IfModule>

Uncomment/add as necessary, and let us know if that doesn't fix it.


UPDATE

No longer have a Mac to test on, so did a bit of reading and it seems the following actions are all that are necessary to enable PHP and apache2 on Snow Leopard:

  • enable LoadModule for PHP (which you've done)
  • check the apache config by running apachectl configtest
  • copy the /etc/php.ini.default file to /etc/php.ini, and make it readable to apache's user

Not sure if you've tried the last two - could you give it a try and let us know if this helps?

Zayne S Halsall
  • 1,982
  • 15
  • 19
  • pls see update above thx. –  Nov 12 '10 at 21:15
  • Updated my response, as well. Let me know. – Zayne S Halsall Nov 13 '10 at 12:58
  • Thanks for your continued efforts on this Zayne. I had never read about the apachectl configtest thing before. Where did you read this? added my updates above. –  Nov 14 '10 at 18:34
  • 1
    Zayne, your last comment "I'd recommend changing your IfModule to look more like mine: - per another obvious piece of documentation (from httpd.apache.org/docs/2.0/mod/core.html#ifmodule): The module name argument is the file name of the module, at the time it was compiled...." was bang on. the ifmodule directive wasn't getting picked up because the the directive had the incorrect name of the module. god knows why as i never touched the stupid thing. if you can emphasize that in your answer, i think it will help others who happen to have the same issue. Thanks! –  Nov 15 '10 at 01:35
0

I know it's a bit long after this was asked but I just macported my AMP stack and disabled the default apache this way I don't mess with the system default version

Dark Star1
  • 1,385
  • 7
  • 22
  • 37