Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

J. J.

macrumors regular
Original poster
Oct 15, 2012
122
9
I have a server running OS X 10.8.2. I wanted to install PhpMyAdmin, so I have installed MySQL and PHP (through MacPorts) too. Then I put the PhpMyAdmin folder in the root of my webserver, but when I surf to http://SERVERADDRESS/PhpMyAdmin on any web browser on any device I get the source code of the index.php file instead of the page loaded (see screenshot). I have already uncommented out the line
Code:
#LoadModule php5_module libexec/apache2/libphp5.so
in the file httpd.conf and added the following lines:
Code:
AddHandler php5-script .php
AddType text/html .php
. I have also configured the file php.ini so I can't really understand what I'm doing wrong. (Note: I have obviously restarted Apache after changing the files.) Can you help me please?

BBPCS.png
 

Attachments

  • Schermata 2013-10-06 alle 16.42.34.png
    Schermata 2013-10-06 alle 16.42.34.png
    396.2 KB · Views: 422

bevel

macrumors newbie
Jul 18, 2009
29
238
Hi there Jaggions. Try adding this to you apache config:

Code:
<IfModule mod_php5.c>

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

</IfModule>

Also, if you installed the php5 package through macports you probs installed apache2 as well. If so, you may have 2 versions of apache installed. Macports installs a version into /opt/local and the os x version is in /usr/sbin.

If you want to use the OSX apache with the macports php you will need to specify a full path to the macports php5 shared object from your OSX httpd.conf:

Code:
LoadModule php5_module /opt/local/apache2/modules/libphp5.so

BTW I haven't tested this^ and it may not work :). You're probs better off either using the OSX version of PHP with the OSX version of apache, or using the macports version of apache2 with the macports php5. The latter would require reconfiguring macports apache to use php. The macports apache config file is located at /opt/local/apache2/conf/httpd.conf. You can get the macports version of apache to load by stopping the OSX version then running

Code:
sudo port load apache2

This will mean apache and php can both be kept up to date using macports, and any future dependencies will be handled for you by macports.
 

J. J.

macrumors regular
Original poster
Oct 15, 2012
122
9
Hi there Jaggions. Try adding this to you apache config:

Code:
<IfModule mod_php5.c>

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

</IfModule>

Thank you for your exhaustive answer. Well this didn't work :mad:

Also, if you installed the php5 package through macports you probs installed apache2 as well. If so, you may have 2 versions of apache installed. Macports installs a version into /opt/local and the os x version is in /usr/sbin.

If you want to use the OSX apache with the macports php you will need to specify a full path to the macports php5 shared object from your OSX httpd.conf:

Code:
LoadModule php5_module /opt/local/apache2/modules/libphp5.so

BTW I haven't tested this^ and it may not work :). You're probs better off either using the OSX version of PHP with the OSX version of apache, or using the macports version of apache2 with the macports php5. The latter would require reconfiguring macports apache to use php. The macports apache config file is located at /opt/local/apache2/conf/httpd.conf. You can get the macports version of apache to load by stopping the OSX version then running

Code:
sudo port load apache2

This will mean apache and php can both be kept up to date using macports, and any future dependencies will be handled for you by macports.
I didn't install Apache2 through MacPorts; I'm using the OS X one. About PHP: I didn't know it was already installed in OS X; that's why I have downloaded it. So... what's next?
 

bevel

macrumors newbie
Jul 18, 2009
29
238
I just ran the OSX version of apache in OS X 10.7.5, and made the same changes as you described to my httpd.conf - and php worked fine??

Maybe the PHP module isn't being loaded for some reason on your machine. This command will give you a list of every module running in apache:

Code:
apachectl -M

If PHP is running you should be able to see this line:

Code:
php5_module (shared)

Can you post the output?
 

alexrmc92

macrumors regular
Feb 7, 2013
218
0
Thank you for your exhaustive answer. Well this didn't work :mad:


I didn't install Apache2 through MacPorts; I'm using the OS X one. About PHP: I didn't know it was already installed in OS X; that's why I have downloaded it. So... what's next?

Loading a MacPorts installed version of PHP is not the same as loading the built in module. Theres quite a bit of custom configuration involved.

Try enable PHP in server admin
 

J. J.

macrumors regular
Original poster
Oct 15, 2012
122
9
I just ran the OSX version of apache in OS X 10.7.5, and made the same changes as you described to my httpd.conf - and php worked fine??

Maybe the PHP module isn't being loaded for some reason on your machine. This command will give you a list of every module running in apache:

Code:
apachectl -M

If PHP is running you should be able to see this line:

Code:
php5_module (shared)

Can you post the output?

Here it is:
Code:
servertoshiba:~ jaggions-osx86$ apachectl -M
WARNING: MaxClients of 150 exceeds ServerLimit value of 133 servers,
 lowering MaxClients to 133.  To increase, please see the ServerLimit
 directive.
Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 authn_file_module (shared)
 authn_dbm_module (shared)
 authn_anon_module (shared)
 authn_dbd_module (shared)
 authn_default_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_dbm_module (shared)
 authz_owner_module (shared)
 authz_default_module (shared)
 auth_basic_module (shared)
 auth_digest_module (shared)
 cache_module (shared)
 disk_cache_module (shared)
 mem_cache_module (shared)
 dbd_module (shared)
 dumpio_module (shared)
 reqtimeout_module (shared)
 ext_filter_module (shared)
 include_module (shared)
 filter_module (shared)
 substitute_module (shared)
 deflate_module (shared)
 log_config_module (shared)
 log_forensic_module (shared)
 logio_module (shared)
 env_module (shared)
 mime_magic_module (shared)
 cern_meta_module (shared)
 expires_module (shared)
 headers_module (shared)
 ident_module (shared)
 usertrack_module (shared)
 setenvif_module (shared)
 version_module (shared)
 proxy_module (shared)
 proxy_connect_module (shared)
 proxy_ftp_module (shared)
 proxy_http_module (shared)
 proxy_scgi_module (shared)
 proxy_ajp_module (shared)
 proxy_balancer_module (shared)
 ssl_module (shared)
 mime_module (shared)
 dav_module (shared)
 status_module (shared)
 autoindex_module (shared)
 asis_module (shared)
 info_module (shared)
 cgi_module (shared)
 dav_fs_module (shared)
 vhost_alias_module (shared)
 negotiation_module (shared)
 dir_module (shared)
 imagemap_module (shared)
 actions_module (shared)
 speling_module (shared)
 userdir_module (shared)
 alias_module (shared)
 rewrite_module (shared)
 php5_module (shared)
 hfs_apple_module (shared)
Syntax OK



Loading a MacPorts installed version of PHP is not the same as loading the built in module. Theres quite a bit of custom configuration involved.

Try enable PHP in server admin

I downloaded PHP because I thought it wasn't installed on OS X by default; should I uninstall it? And since OS X 10.7 there is no Server Admin app ;)
 

theluggage

macrumors G3
Jul 29, 2011
8,015
8,450
I downloaded PHP because I thought it wasn't installed on OS X by default; should I uninstall it? And since OS X 10.7 there is no Server Admin app ;)

The MacPorts PHP won't do any harm - it lives in its own little world under /opt/local.

ISTR that the way to turn on PHP in Lion Server and later is to enable blogs/wikis in the Server app. Obvious, really :confused:

Unless you're using other OSX Server features, I'd switch to the MacPorts versions of Apache2 and PHP - much easier to add the PHP modules you want.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.