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.
3 Answers
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.
-
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. Mar 23, 2012 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– JW8Mar 23, 2012 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. Mar 24, 2012 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.
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
.