Is there any restriction between Apache and PHP version - php

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.

Related

Two versions of php in El Capitan. How do I get rid of one or upgrade the other?

In terminal,
php -v
gives
PHP 5.3.29 (cli) (built: Sep 28 2015 06:33:13)
(with imagick installed) but, in the browser (using apache)
phpinfo();
gives
PHP Version 5.5.27
(with no imagick installed) How do I resolve this?
I don't want to mess about with php.ini and httpd.conf when I'm not entirely sure what I'm doing!
Solved it. I entered
locate libphp5.so
into terminal to find paths to the php installations. This outputted
/usr/libexec/apache2/libphp5.so
/usr/local/Cellar/php53/5.3.29_4/libexec/apache2/libphp5.so
I then edited the apache configuration file
sudo nano /private/etc/apache2/httpd.conf
and changed
LoadModule php5_module libexec/apache2/libphp5.so
to
LoadModule php5_module /usr/local/Cellar/php53/5.3.29_4/libexec/apache2/libphp5.so
NOTE : This line will be different for your local installation, copy the value outputted from the locate command above
I then restarted apache with:
sudo apachectl graceful
Credit to this solution for the command to find the php installations
This may be a help to you : Upgrade to PHP 5.4 on MAC and remove version 5.3.10
I would suggest that you work in a virtual setup instead.
like Vagrant: https://www.vagrantup.com/
Also take a look at Homestead: http://laravel.com/docs/4.2/homestead
"Laravel Homestead is an official, pre-packaged Vagrant "box" that provides you a wonderful development environment without requiring you to install PHP, HHVM, a web server, and any other server software on your local machine.
"
It will also allow you to keep your configuration if you change machine and/or operating system.

Specify PHP version in MAMP

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

Change PHP binary being used by localhost

I had been PHP version using 5.5.11 on my Mac and have some modules installed. They took quite a lot of tinkering around to get working. I have my OSX already using this version by using a PATH in my ./~profile. After I installed Yosemite though my localhost now runs PHP 5.5.14, which doesn't have the modules installed. How do I get my localhost to use my other PHP installation?
I have tried in httpd.conf LoadModule php5_module \path\to\other\binary. I restarted Apache but it wouldn't load my page then. So i'm unsure of how to achieve this.
Not so easy, in my mind the easy way should be to install a new version with the modules you need
If you are lucky all modules you need are present in the package from
http://php-osx.liip.ch/
The hard way : install manually the php and all modules ...

Apache 2.4 Php5.4 Zend Loader

I've been running a development site with Apache 2.2, PHP5.2 and MySql using, in part, software obfuscated with ZendGuard (version unknown). The actual online hosting sight is discontinuing PHP5.2 forcing an upgrade to PHP5.4. I've ended up uninstalling Apache and PHP. I can get Apache 2.4 running; however, if I understand right ZendGuard requires a non thread safe version of PHP5.4. I can not figure out how to install PHP5.4 nts on my Windows pc to work with Apache2.4.
Here's the link to the non thread safe windows pre-compiled version of PHP
For Apache on Windows, it's recommended to use the VC11 Apache lounge build: here
You'll need to add the following lines in Apache's httpd.conf:
LoadModule php5_module "c:/php/php5apache2_2.dll" #or wherever you put it
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php" #your path
I'm not too familiar with ZendGuard, but once you have the Apache server configured for php I'm sure it will just be a case of trivial configuration.

Apache/PHP on Windows 8

I'm having trouble with Apache/PHP on Windows 8. I have previously been using them on XP (along with MySQL) with no problems. I never used Windows 7.
Apache installs without issues. Everything works OK, including all my virtual servers.
PHP installs OK, the installation puts entries into httpd.conf without giving errors.
However, when I try to load Apache after installing PHP, Apache won't load.
I'm confused by the error that Apache returns when the PHP entries are included in httpd.conf:
Syntax error on line 1029 of C:/Program Files/Apache Group/Apache2/conf/httpd.conf:
Cannot load C:/Program Files/PHP/php5apache2_2.dll into server: The specified module could not be found.
The lines are:
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
PHPIniDir "C:\Program Files\PHP\"
LoadModule php5_module "C:\Program Files\PHP\php5apache2_2.dll"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
(line 1029 is the LoadModule line).
That location for the dll is definitely correct. The syntax of the line is as inserted by PHP. I have compared the syntax to previous versions of httpd.conf that I have and it appears correct. I think the syntax error is a red herring.
I have tried:
Switching backslashes to slashes in the dll location.
Adding PHP to the path.
Installing Apache and PHP in both sequences.
Checking the permissions to the PHP folder and the individual files
to ensure that SYSTEM has read/execute.
Comment out the PHP lines and Apache loads fine. If I comment out the LoadModule line and and just leave the PHPIniDir line, it still fails. Apache seems to be behaving as though it can't see the PHP directory, but I can't work out why.
There is nothing on the Windows event log. Latest versions of PHP and Apache. I'm at a bit of a loss what to try next. Any suggestions please?
Download and follow instructions from this link:
http://www.apachelounge.com/download/
The latest download (2.4) works on Windows 8 and Server 2012.
I downloaded and tested with the following on Windows 8:
Each zip has a readme.txt or install.txt with instructions.
Apache 2.4
http://www.apachelounge.com/download/win32/binaries/httpd-2.4.3-win32.zip
PHP 5.4.8
http://windows.php.net/downloads/releases/php-5.4.8-Win32-VC9-x86.zip
PHP 5.4.8 handler for Apache
http://www.apachelounge.com/download/win32/modules-2.4/php5apache2_4.dll-php-5.4-win32.zip
My httpd.conf lines that were added/modified were:
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module "C:/Apache24/php-5.4.8/php5apache2_4.dll"
LoadFile "C:/Apache24/php-5.4.8/php5ts.dll"
PHPIniDir "C:/Apache24/php-5.4.8"
<IfModule php5_module>
<Location />
AddType text/html .php
AddHandler application/x-httpd-php .php
#AddHandler application/x-httpd-php-source .phps
</Location>
</IfModule>
Its mentioned in the Readme.txt file packed with the dll's at ApacheLounge, but not anywhere else on the download page or in the filename (as all other versions):
"Runs with PHP 5.4 Thread Safe (TS), and only with Apache 2.4 Win32 VC9 or VC10"
The dlls are only for the TS version, so if you've downloaded the other one, you are basically screwed. TS php binaries fixed it for me.
GL.
Presuming this is your development, not deployment environment, why don't you just download xampp from apache friends? It should come preconfigured, and you will deploy in other setup anyway.
I ran into the similar issue when reinstalling Apache and PHP on Win 8 (I am more Linux user though). And similar to the original post, no matter what I tried to do in httpd.conf and php.ini Apache simply either did not start or did not see the PHP. After spending unreasonable amount of time, I decided to download the PHP 5.3 (5.3.27)-VC9 x86 Thread Safe (2013-Jul-10 21:56:58) Installer [45.86MB] instead of the non-tread safe version which I have been using before. There is a difference in the .msi installers. The one for the thread-safe version actually contains the required files and if you follow the installer prompts it will actually asks you if the php installation should be "linked" to Apache server. Then you just provide the hhtpd.conf directory and all works fine. Thats my 2c on this :)
I think the problem is in the blank "Program Files".

Categories