Apache2 using PHP 5.4 while 5.6 is installed - php

I'm currently using Raspbian Wheezy 7.0 right now. Since PHP 5.6 is not available on the apt repositories for wheezy, I decided to build it from source. The build worked perfectly, I didn't receive any errors from it.
So when I used php -v it gave me the following output.
PHP 5.6.10 (cli) (built: Sep 18 2016 09:23:21)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
Ok, I thought. Perfect, everything is updated like it should be.
Here's where the problem comes in. For some reason, when I use phpinfo() on my apache2 server. It says that I'm still on version 5.4.45.
My first guess was that the module apache was using libphp5.so located in /usr/lib/apache2/modules/ was out of date. But, I have no idea where the libphp5.so module is for the new php version that I just installed is.
It'd be great if anyone could help me with this or point me in the right direction. I'm using Apache version 2.2.

As you can see from your console, php -v is the CLI binary. When building PHP you can build many different binaries for different SAPIs (Server APIs), one of them being CLI. Apache2 Handler or mod_php would be another one. In order to build your PHP as an Apache httpd module you need to make sure you include the --with-apxs2 configuration option when compiling from source. This means running ./configure --with-apxs2 before you make; make install; the binary. You then need to make sure to load the newly built libphp5.so or mod_php.so (however you built it) to the appropriate directly and load it from your Apaache httpd config. Where your newly compiled binaries are stored, depends on your compile time configuration options and environment, but typically they are located in $PREFIX/$HOME/bin. So for example, if you compiled --with-prefix=/usr you might get /usr/php/bin/libphp5.so, but typically the binary is moved for you by make install. You do need to make sure you restart httpd for the newly built binary to be loaded.
See the PHP manual on installation for more details.

Related

Should I install additional php when XAMPP has default php package in it?

I'm a begginer in Laravel and I installed XAMPP as local server. I noticed that my XAMPP already install php 7.4 as it's dependency. But when I tried php -v in www dir in php it shown.
'php' is not recognized as an internal or external command, operable
program or batch file.
But in php directory is shown
PHP 7.4.15 (cli) (built: Feb 2 2021 20:47:45) ( ZTS Visual C++ 2017
x64 ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c)
Zend Technologies
So, should I install additional php in my system for development? Should the version of the php matche with XAMPP php 7.4?
php -v will only tell you if you have PHP installed as a command line interface (PHP-CLI) which would enable you to run php code in cmd.exe or powershell. You'd normally not need this, but for reference here's how to enable it: https://stackoverflow.com/a/10753133 (mind the comment on Windows 10).
To check if PHP runs in your webserver environment (which is by default available in xampp), create a file test.php in your www folder with the following content:
<?php
phpinfo();
?>
Call this file in a browser, you will get an overview of all php features available. Delete the file before you go productive, because it will also give hackers a lot of information (which you don't want).
Try to add XAMPP PHP to Environment Variables
here is an instructions for Windows 10

How do I upgrade PHP version in macOS Server?

Good day,
Just to clarify, I'm asking about macOS Server, the application published by Apple. I'm not referring to the system's PHP version.
I've looked everywhere, Google, SO, forums, for quite some time and haven't found a solution.
I'm unable to upgrade my PHP version for macOS Server no matter what I try. There's just simply no documentation.
I've updated the app from the App Store, I've upgraded my PHP version on my Mac, and I've changed the PATH to reflect the new PHP install, and when I do php -v in Terminal, it shows the correct version I want.
However, macOS Server seems complete unaffected by it. I tried looking around everywhere possible, but I don't see a separate install of PHP for Server, and I looked in the config files, everywhere, but can't see where and which PHP it's using.
Any help?
EDIT: I just realised that it's a whole application which many parts actively use PHP, and upgrading it on my own may break those things, but I'm willing to give it a shot, if it's at all possible. I mean, the worst that can happen is for me to delete and re-install Server, right?
Installing php on macOS
Honestly, you sound like you know more about this than is evident in the question. So you probably know a lot of this, but I wanted to be as complete as I can, from my experience, since these responses remain for others who may locate them in the future and find the information useful. If I have left anything out, I hope someone will point it out for me so I can learn a bit more along the way.
Back in the day, then thunder gods ruled the world:
php has come bundled standard on Macs since Mac OS X version 10.0.0, as you can read about here. The first version of Mac OS X Server (1.0) was a hybrid of OPENSTEP from Steve Jobs' NeXT Computer and Mac OS 8.5.1 released in 1999.
Starting with Mac OS X 10.7 (Lion) Mac OS X and Mac OS X Server have been combined into one operating system package and the macOS Server is an add-on package available through the App Store. This means that you can't really worry very much about ruining anything too important.
You can't always get what you want ...
A lot of the value in this response will depend on what you use the Server package for. If you only use the web server for a development environment, it can easily be replaced with any version of the typical LAMP (linux-apache-mysql-php) style environment.
For macOS, this means upgrade apache, install php, and install MySQL if you cannot use SQLite that comes bundled with macOS. Here is one of the many great tutorials available online. (no affiliation) It can get complicated ...
Another option that is popular, but that I haven't used myself, is the non-profit XAMPP. They are focused on making it simpler to setup php development, Wordpress, Drupal, e-commerce, and popular open source apps.
When you're a stranger ...
If you are using some of the more esoteric apps that came with the server package, you will have to upgrade them separately. But since you are asking about php and the server recognizing it, I'm assuming you are talking about the web server and that you are using something like this to see what php version apache is finding:
<?php phpinfo(); ?>
Most likely, what you are saying is that the command line php version shows correct versions and settings, but the web page version served by apache shows the old version. Is that right?
Version and File Locations:
I'm not sure if you have checked for this, but the first thing I would do is find out for sure what the path is and what version I am using. This also gives me a quick direct link to the ini file so I can go break stuff faster. Here are my results (screenshot at the end) using php --version and php --ini:
$ which php
/usr/local/bin/php
$ php --version
PHP 7.3.6 (cli) (built: May 31 2019 23:38:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.6, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.7.0, Copyright (c) 2002-2019, by Derick Rethans
with Zend OPcache v7.3.6, Copyright (c) 1999-2018, by Zend Technologies
$ php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/7.3
Loaded Configuration File: /usr/local/etc/php/7.3/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.3/conf.d
Additional .ini files parsed: /usr/local/etc/php/7.3/conf.d/ext-opcache.ini
A touch too much:
Using php -i will output an enormous amount of information. It is many pages ... more than you would ever want. If you are looking for specifics, you can grep it for whatever you like: php -i | grep ini or php -i | grep -- '--with' to look for options.
Hiding in plain sight:
Most likely you are checking, testing, and upgrading the wrong installation of php or apache. macOS is infamous for having standard versions of many programs and it will likely break something if you upgrade the 'system' version of any of them.
Ruby and Python are the most common ones to cause problems for me. I have never had any issue with php, but there and many workarounds available for many programs (e.g. coreutils for gnu).
Homebrew!
The easiest way I have found is to use Homebrew to install a separate version that you can manage and upgrade as you like and link it somewhere early in your path so it is always the first version found.
$ brew install php
It does everything for you and keeps it updated. It also allows php to always be running as a service using brew services start php. This reduces startup time and prevents some multiple version issues. A list of all brew services and status info is, as you might expect, found with brew services list. If you update any config or ini files, you should restart php (and apache) with brew services restart php. You can also still use launchctl and apachectl if you choose.
Apache!
The other handy thing about homebrew is that you can use it to install and manage apache2, also. Try this:
$ brew install httpd
$ brew services start httpd
$ httpd
Non-alcoholic recipe:
If you prefer to abstain and not use homebrew, you can install any version you wish from php.net and make a link in a directory early in your PATH. Patches and upgrades are regular and everything is extremely professional and well (over?) documented.
Download a php binary, check it with the provided signatures, and link it somewhere on your path: ln -s /path/to/new/php ~/bin/php or somewhere else if you don't use your /home/bin. Homebrew puts the link in /usr/local/bin by default.
No matter which method you choose, after you install the programs you will definitely have to adjust a few settings. There are several great posts online about this. This one is a multi-part series and is updated for Mojave. The main information to get you started should be available as shown in the screenshot below.

FFMPEG on Fedora but PHP Compilation confliction

I have running Xampp with PHP5.5 on Fedora from Apache Friend, with default settings what the installer package do on Linux.
When I install FFMPEG successfully and try to load from php.ini it always says:
*
11-Oct-2013 14:05:51 Europe/Berlin] PHP Warning: PHP Startup: ffmpeg: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20121212
These options need to match
in Unknown on line 0
*
The only thing which is confusing me is that when I did phpize even that I already installed xampp server which means I have PHP running. FFMPEG phpize did not work and I had to install php-devel. Does that mean that FFMPEG is configured with PHP, other than the installed with XAMPP? I am not sure what is happening. Whatever I do I always receive this error message in php_error_log file.
It is amazing :) that I just run below command to see what version of PHP is, I have and below are the results which are shocking one because I am in a feeling that I have PHP 5.5 installed and running from XAMMP.
[root#localhost ~]# php -v
PHP 5.2.6 (cli) (built: May 8 2008 08:53:44)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
How can I get this covered that if I simple install XAMPP server on linux and want to install and configure FFMPEG along with?
My guess would be that the versions of php and the module you installed do not match. So run make sure both packages are installed from the same source and are both current.
EDIT: According to the XAMPP site, Fedora is not supported, they specify Ubuntu, SuSE, RedHat, Mandrake and Debian. So I would make sure you do not use the php package provided by Fedora. Or (if you have the liberty), choose a different OS.

No php.ini after installing php5.1 on debian 7.0

Lately i've been struggling with installing zend optimizer on my machine (since i needed that for irrelevant purposes), but i found out that it works best on php 5.1. So i get one from HERE and zend optimizer i had stored from my backup disk. Both tar.gz files. I installed php, so now php -v returns with:
PHP 5.1.4 (cgi) (built: Jun 10 2013 13:38:28)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
Which indicates that it works quite well. However, to install zend optimizer, i need to edit php.ini file, which is basically nowhere.
I tried looking for it with where is php.ini , got:
php: /usr/lib/php /usr/local/bin/php /usr/local/lib/php
but obviously in none of those i can find any.
then i tried
sudo find / -name "php.ini"
and got nothing.
I'm running Debian 7 Wheezy, with apache2, mysql 5.1 and php5.1 - any ideas?
Linux sklep 3.2.0-4-686-pae #1 SMP Debian 3.2.41-2+deb7u2 i686 GNU/Linux
I'll provide any needed information, to help you help me solve the problem.
Make a PHP script with phpinfo(); in it.
Run it, and it will show you where the .ini file is.

Problem of different PHP versions reported

I have upgraded to PHP 5.3 on a development machine (Windows 7 box).
php-v shows
PHP 5.3.3 (cli) (built: Jul 21 2010 20:36:55)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
However, phpinfo.php shows that the version on the machine is: 5.2.14 as shown
The loaded configuration file rightly loads the correct php.ini file for 5.3
The configuration file (php.ini) Path wrongly reads: C:\Windows - I don't install PHP on the said path. I have however done a recursive search of PHP folders and files within that file but the search turned up nothing.
Applications seem to use the settings reported by the phpinfo and not by php -v or php -m or php -i (or else).
Apart from deleting the PHP folder and starting from scratch (which I have done), and ensuring that Apache points to the right PHP dir using PHPINIDir, what could I possibly do to solve this? Thanks.
Hello
You should also update apache php
module
#soju - that fixed it, thanks, but I thought I'd make this a little clearer for others.
Apache requires the php module to serve php files. On Windows it comes as a .dll file. This would be called: php5apache2_2.dll - located within your php folder. Strangely though, during upgrading the php folder with a newer version, you may find out that apache still uses the old php module file. So while php -v correctly reports the new version, Apache still looks at the old php module (reported by phpinfo). To find out what module version you have, you could: right-click on the .dll file > select properties -> view the details tab. Or just hover on the file.
If this version is not what you want, you might want to hunt for a newer version and replace it. Good idea to back up first. Also, the php5apache.dll file works with and requires the file: php5ts.dll - so ensure these files are the same versions.
With your httpd.conf file with the directive:
LoadModule php5_module "\path to\php5apache2_2.dll"
You may restart apache and smile!
Your command line (CLI) php is an other version than the one used for Apache. Check also that both use the same php.ini. When you call on your Windows machine
c:\path\to\php\php.exe -v
or
c:\path\to\php\php-win.exe -v
and
c:\path\to\php\php-cli.exe -v
They all can return different versions. Often this happens when upgrading to a new WAMP version and forgetting to delete the old versions. I'm sure you will find the executable PHP binary which matches the same version. It is also save to use the php.exe or php-win.exe instead the php-cli.exe on Windows.

Categories