Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I placed a phpmyadmin directory in the sites folder on the Mac. When I open the location of phpmyadmin in the browser, http://new-host-w.home/~username/phpmyadmin/ it opens as a directory instead of a site. If I open index.php, it opens as a text file.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

The local server environment on OS X does not provide native PHP support. Try MAMP, which is an Apache, PHP and MySQL bundle for Mac.

share|improve this answer
    
I installed PHP. My question was why when I browse to that directory and open the index.php, the browser shows a text file instead of a web page. –  user823527 Mar 23 '12 at 23:55
    
@user823527, since the local server doesn't have native PHP support, the web server will serve up that page as text, rather than rendering it as you intended. You'd need to add to either run MAMP, or do something similar to this tutorial to enable PHP: foundationphp.com/tutorials/php_leopard.php –  JW8 Mar 23 '12 at 23:59
    
And the answer is because the server doesn't render the php. Try with a sample .php file with phpinfo() and see if that works. If not, try reinstalling php/MAMP. –  0sh Mar 24 '12 at 0:00

As @Milosz mentioned, MAMP is a great option. Another option is to enable PHP for your local web server, as shown in this tutorial (for Leopard - 10.5). The steps should be similar for other versions of OS X. Quick synopsis:

  • Locate httpd.conf for the local Apache web server
  • With appropriate admin privileges (via sudo, etc.), uncomment the following line: LoadModule php5_module libexec/apache2/libphp5.so
  • Set up php.ini to enable PHP support

You should then be able to browse to the page that you noted in your question and see it as a web page instead of text.

share|improve this answer

As JW8 mentions, locate httpd.conf (usually /etc/apache2/httpd.conf) and go at the end of the file. You should see something like this :

<IfModule php5_module>
  AddType application/x-httpd-php .php
  AddType application/x-httpd-php-source .phps
  <IfModule dir_module>
    DirectoryIndex index.html
...

Replace

DirectoryIndex index.html

by

DirectoryIndex index.html index.php

and phpmyadmin should work.

You can also see here for a more complete tutorial on installing phpmyadmin.

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.