Using Mamp 3.3, the conf/apache/httpd.conf file has the following line to specify PHP:
LoadModule php5_module /Applications/MAMP/bin/php/php5.6.10/modules/libphp5.so
When I update the line to a different version of PHP e.g.
LoadModule php5_module /Applications/MAMP/bin/php/php5.4.29/modules/libphp5.so
As soon as I restart MAMP it automatically resets it back to 5.6.10. Is there a way to force a PHP version?
Found a solution for this in MAMP forums. Just rename PHP versions not required. For example after renaming the following, they are not shown in the preferences:
/Applications/MAMP/bin/php/X_php5.6.10
/Applications/MAMP/bin/php/X_php5.4.42
Related
OS: Sierra 10.12
PHP Version: 5.6.30
Originally I had a problem with ACPU module, after installing it using homebrew, it did not load properly, I used this article:
https://gist.github.com/andrewstobbe/7c56de552df41e444f0a1d5bdfa02ffe
And more specifically, I change line in httpd.conf file from this:
LoadModule php5_module libexec/apache2/libphp5.so
to this:
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
ACPU, Xdebug and rest of modules works properly and they are visible in phpinfo(), but when I try to run one of projects, i've got an error:
Fatal error: Call to undefined function mysql_connect()
UPDATE:
I know that I should use mysqli instead, but i can't change this right now, mysql loads fine and works properly with original line in httpd.conf (LoadModule php5_module libexec/apache2/libphp5.so)
try
brew reinstall php56 --with-libmysql
I downloaded MAMP 4.1 on my Mac; by default, the only PHP versions I can use are 7.0.15 and 7.1.1
How can I use PHP 5.6?
I tried the solution here Which says I should rename the versions I don't want to use to something else. But it didn't work for me.
As mentioned by #Scott in the comments under your question:
Your here is the right link. Use the bottom answer to rename the
bin/php directory. The MAMP preference pane will show the 2 latest
versions in the php directory. – Scott Eisenberg
And the answer in that links is:
First stop the Server if its running. Go to "/Applications/MAMP/bin/",
rename the PHP Version you don't need (MAMP is only allowed to use 2
PHP Versions), e.g. "_php5.2.17". Now MAMP will use the php versions
that are left. Go to the MAMP Manager and then settings, then switch
to the php version you need.
In my case (and similarly yours), I renamed the folder named php7.1.1 to _php7.1.1 and now MAMP shows me 5.6.30 and 7.0.15 in the preferences pane.
This is how my 'php' folder look like
Created another folder 'php-versions' and moved all versions, and kept only two version which I wanted in the 'php' folder. And restarted the Mamp, go the version '5.6.31'
I am using MAMP version 4.5. I changed php version on the httpd.conf:
/Applications/MAMP/conf/apache/httpd.conf
I wanted to the version to php7.1 so here is what I did:
Original line:
LoadModule php7_module /Applications/MAMP/bin/php/php7.2.1/modules/libphp7.so
Updated line:
LoadModule php7_module /Applications/MAMP/bin/php/php7.1.12/modules/libphp7.so
It worked for me!
I downloaded and installed php 5.6 from php-osx.liip.ch and also edited the path to /usr/local/bin in /.bash_profile.
I am getting php version 5.6.19 in terminal, but when I execute phpinfo(); I still see the previous 5.4 version
also the php info shows that the php.ini lies in /etc directory
how can I solve this?
Although this is 3 months old, this just happened to me yesterday with the same installer (php-osx.liip.ch), so here's my solution.
In my case, the apache configuration (httpd.conf) was pointing to the old php extension:
LoadModule php5_module libexec/apache2/libphp5.so
When it should be this:
LoadModule php5_module /usr/local/php5/libphp5.so
Your path should be the same as mine. My httpd.conf is on /private/etc/apache2/httpd.conf
After editing httpd, restart apache and phpinfo() should return the correct version.
Is there any restriction between apache and php version? Suppose I am running Apache version 2.2. Am I restricted to certain PHP version (5.3?) such that beyond that version (5.4 or 5.5), PHP can't be run as an apache module?
To be more specific, is mod_php bound to certain PHP version?
In general Apache doesn’t care what version of PHP you are using and PHP doesn’t really care what version of Apache you are using. I say “in general”, because there can be some extreme cases where you will most likely know you are getting into a mess before you even begin. But for common use, it’s not a worry.
For example, on my desktop I am using MAMP running Apache version 2.2.25 and PHP 5.5.3. In fact I can toggle MAMP to use PHP 5.2.17 if need be. And in other setups you can have dozens of different PHP module versions you can select to load into Apache. Using Ubuntu 12.04 as an example you just have to edit this file:
/etc/apache2/mods-available/php5.load
And have it load whatever PHP module you wish to load:
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
The name libphp5.so has little to do with the contents. That is the name the file is given when compiled. For my own testing purposes when manually compiling I have renamed libphp5.so all of the following & it always worked fine:
LoadModule php5_module /usr/lib/apache2/modules/libphp535.so
LoadModule php5_module /usr/lib/apache2/modules/libphp533-gd.so
LoadModule php5_module /usr/lib/apache2/modules/libphp530-gd.so
LoadModule php5_module /usr/lib/apache2/modules/libphp529-gd.so
LoadModule php5_module /usr/lib/apache2/modules/libphp525-gd.so
LoadModule php5_module /usr/lib/apache2/modules/libphp516-gd.so
And I have even manually compiled PHP 5.1.6 —painful but doable & necessary for a project—on an Ubuntu 12.04 setup running Apache 2.2.25 without any issue. The biggest issue I ran into when compiling PHP 5.1.6 was simply ensuring I had the proper libraries loaded or installed on the system. But that is a nightmare you don’t want to know about!
In general, an upgrade from PHP 5.3 to PHP 5.4 or 5.5 should be a relatively easy process. No worries.
This is the guide I followed to make PHP work on Snow Leopard:
http://maestric.com/doc/mac/apache_php_mysql_snow_leopard
Apache2 is working.
http://localhost.lan works just fine. Virtualhost works too.
Mysql is working.
PHP5 is not even with
LoadModule php5_module libexec/apache2/libphp5.so
I think your apache2 install has a problem.
You need to re-install apache2 then try
LoadModule php5_module libexec/apache2/libphp5.so
again.
To clarify Neoryder's post, edit /etc/apache2/httpd.conf, find the line:
#LoadModule php5_module libexec/apache2/libphp5.so
and remove the hash sign from the beginning to enable PHP in your web server. You have to go to your Sharing preference pane and uncheck and recheck Web sharing for the change to take effect.
I'll mention one more thing that caught me out moving from Linux to OS X...
Most people want to serve PHP files from their own Sites folders. There's lots of advice out there about configuring Apache using .htaccess files, and some of it won't work under OS X because Apache is locked down a bit by default.
For example, if you want to have PHP files ending with .html or .htm, most people will tell you to create an .htaccess file and put in it the line:
AddType application/x-httpd-php .html .htm
If you're a developer and this is annoying you, you may want to edit the file /etc/apache2/users/<myusername>.conf and change the line:
AllowOverride None
to:
AllowOverride All
This will allow your local .htaccess files to override various global defaults that they couldn't before.
This is obviously a late answer...but I had the exact same problem and I used Homebrew to install a later version of php:
http://notfornoone.com/2010/07/install-php53-homebrew-snow-leopard/
brew install php --with-apache --with-mysql
I then went into my httpd.conf file:
cd /etc/apache2
sudo nano httpd.conf
And changed the line:
#LoadModule php5_module libexec/apache2/libphp5.so --> the old version
# Below is the link to the new homebrew version
LoadModule php5_module /usr/local/Cellar/php/5.3.7/libexec/apache2/libphp5.so
(It depends where you install Homebrew, but the default is /usr/local)