Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

OK, so I'v installed php5 and apache2 on my OS X using macports. php is running fine from the terminal, as is apache. I've edited my httpd.conf file to add the following:

LoadModule php5_module        modules/libphp5.so
AddType    application/x-httpd-php .php [I have also tried AddHandler here to no avail]
<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

Apache will redirect to an index.html file in the local root, but will not redirect to index.php. it just shows the list of files in the directory, and clicking on index.php will just output the contents of the file in plaintext. It's as if my httpd.conf changes aren't even being read. But I've searched and there are no other versions of httpd.conf stored anywhere on my system, bar one file named 'httpd.conf.bak', in my /opt/local/apache2/conf/ folder. Can anyone help?

share|improve this question

migrated from stackoverflow.com Aug 4 '11 at 15:25

This question came from our site for professional and enthusiast programmers.

    
Seek serverfault for help. –  Michael-O Aug 4 '11 at 13:46
    
Restart Apache? If that doesn't work, check your error logs. –  Berry Langerak Aug 4 '11 at 13:49
    
In case anyone missed the discussion below, the problem was that I was using virtualhost.sh to set up virtual hosts, which was editing the httpd.conf file for the default version of apache then starting that up. –  Leon Aves Aug 4 '11 at 14:40

2 Answers 2

up vote 1 down vote accepted

Have you restarted apache? Try running sudo /usr/sbin/apachectl graceful? You can also run it as sudo /usr/sbin/apachectl -t to check for errors.

EDIT: Added restart for MacPorts apache installation.

sudo /opt/local/apache2/bin/apachectl

share|improve this answer
    
Ah it might not be /usr/sbin/apachectl for you as I'm using the native apache and php on OS X. –  ace Aug 4 '11 at 13:51
    
I used restart, not graceful, but yes I've restarted many times. –  Leon Aves Aug 4 '11 at 13:55
    
-t reports no errors. just "syntax OK" –  Leon Aves Aug 4 '11 at 13:56
    
I was aware that OS X had Apache built in but it was my understanding it wasn't installed by default. Could it be that version is running over the macports version I installed? And if so, how do I overwrite it? –  Leon Aves Aug 4 '11 at 13:58
1  
You just need to open virtualhost.sh and change the following constants APACHE_CONFIG="/private/etc/apache2" APACHECTL="/usr/sbin/apachectl" to the new paths for your MacPorts apache. I think /private/etc/apache2 to /opt/local/apache2/conf/ and /usr/sbin/apachectl to /opt/local/apache2/bin/apachectl. –  ace Aug 4 '11 at 14:24

It looks like the php is not being read. I had a problem with this a while ago and added the following to my httpd.conf file.

<IfModule sapi_apache2.c>
    php_admin_flag engine on
    php_admin_flag safe_mode off
</IfModule>
<IfModule mod_php5.c>
    php_admin_flag engine on
    php_admin_flag safe_mode off
</IfModule>

Not sure if the modules are the same as yours as this was on a production server and not a Mac.

I hope this helps though.

Cheers

Adam

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.