Different php versions - php

Apache and my terminal are using two different php versions. The one that I installed via macports and the other is the one that comes with the mac.
My phpconfig tells me is using the mac one:
Configuration File (php.ini) Path /etc
Loaded Configuration File /etc/php.ini
And the Terminal version is using the one installed via macports:
php --ini
Configuration File (php.ini) Path: /opt/local/etc/php5
Loaded Configuration File: (none)
Scan for additional .ini files in: /opt/local/var/db/php5
Additional .ini files parsed: /opt/local/var/db/php5/intl.ini
How can I say to apache to load the macports version of php, and how can I change the "Loaded Configuration File" which is actually none?
UPDATE:
I solved how to Load the Conf file:
Copy the mac php.ini into /opt/local/etc/php5 (the "Configuration File (php.ini) Path") :
sudo cp /etc/php.ini /opt/local/etc/php5/
and how to change the php.ini that Apache is reading:
sudo nano /etc/apache2/httpd.conf
Just after the LoadModule php5_module add the line:
PHPINIDir "/opt/local/etc/php5/php.ini"
But I still have two different php running. So the question is how to say to apache to load my macports php?
UPDATE 2:
I've been reading for a solution and this is changing the path of the LoadModule php5 in the http.conf:
LoadModule php5_module /opt/local/apache2/modules/mod_php54.so
But actually I have no mod_php54.so in that folder.

The MacPorts documentation has a good step-by-step for setting up a MAMP install. I found it really useful when I went through the process.
https://trac.macports.org/wiki/howto/MAMP
Jump down to step four and look at the 'Register PHP with Apache' section. There are also quite a few other steps that you might need to study. It looks like you've gotten some of them already.

Related

Symfony WARNING: No configuration file (php.ini) used by PHP

I downloaded PHP using brew on Mac
# Update homebrew
brew update
# Add the tap
brew tap shivammathur/php
# Install PHP 8.0
brew install shivammathur/php/php#8.0
But when I run
symfony check:req
I get
> PHP is using the following php.ini file:
WARNING: No configuration file (php.ini) used by PHP!
Why Symfony doesn't access php.ini file?
Even though php.ini file exists, I checked that by:
php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/8.0
Loaded Configuration File: /usr/local/etc/php/8.0/php.ini
Scan for additional .ini files in: /usr/local/etc/php/8.0/conf.d
Additional .ini files parsed: /usr/local/etc/php/8.0/conf.d/ext-opcache.ini
Please consider that I am an absolute beginner in PHP
Thank You
I had the same problem as you and i solved it by changing the name of this file.
When i installed php, i created a file php.ini. (a copy of php.ini-development that i renamed in php.ini). I modified a few lines and i installed "Composer".
But when i checked symfony requirements, i saw this problem as you.
When i opened it with VSC i noticed the file was called php.ini.ini.
I think it was "Composer" who changed the name when i installed it.
I renamed it to php.ini and I no longer had this problem.

How to install PHP Opcache on MacOS High Sierra?

I'm using the standard Apache and PHP 7.1 (not Homebrew) that comes with Mac High Sierra. However, it appears that this version doesn't have Opcache enabled even though it should come as standard with PHP 7. It's even listed in phpinfo() under "Module Authors", but no section showing it's actually installed. Calling opcache_get_status gives a fatal error.
I've installed the extension via Homebrew, and linked the opcache.so file. It appears to be working on the CLI but not in Apache. For some reason the CLI and web are using different ini files:
/usr/local/etc/php/7.1/php.ini for CLI
/etc/php.ini for web
The CLI is parsing the addition files including /usr/local/etc/php/7.1/conf.d/ext-opcache.ini, and php -i shows Opcache. But phpinfo() in the browser does not - no additional ini files are parsed.
I currently have this in /etc/php.ini:
[opcache]
zend_extension="/usr/local/opt/php71-opcache/opcache.so"
opcache.enable=1
But still nothing. I followed the exact same process for xdebug and it worked fine. What am I missing?
I wonder if it would be easier to use the Homebrew version of PHP. But I don't appear to have the required .so file. Various tutorials say to put this in Apache's httpd.conf:
LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so
But the libexec directory does not exist. There is lib but neither this nor any other directory has any .so file.
For me it worked by these steps:
Search extension_dir in "phpinfo()" page, I got a path
/usr/lib/php/extensions/no-debug-non-zts-20160303
By execute ls -lh /usr/lib/php/extensions/no-debug-non-zts-20160303, I found "opcache.so" , I guess it's installed when upgraded to "High Sierra"
Create "/etc/php.ini" (by copy "/etc/php.ini.default"), and modify:
[opcache]
zend_extension = opcache.so
opcache.enable = 1
Restart apache, module "opcache" is enabled
EDIT / CONCLUSION
Since "opcache extension" is installed on Mac OS High Sierra by default, the solution of enabling opcahe on Mac OS High Sierra is:
Create "/etc/php.ini" if you don't have one, by simply copy the default configuration: sudo cp /etc/php.ini.default /etc/php.ini
Add zend_extension = opcache.so to /etc/php.ini and set "opcache" enable:
php.ini opcache section looks like:
[opcache]
zend_extension = opcache.so
opcache.enable = 1

Call to undefined function Illuminate\Encryption\openssl_decrypt()

I am using xampp and windows along with laravel, everything was working fine, but when I finished work and turned of xampp and try to open my work today morning, this is what I get:
FatalThrowableError in Encrypter.php line 100:
Fatal error: Call to undefined function Illuminate\Encryption\openssl_decrypt()
Encrypter.php is a standard laravel file and I have not even touched it. My extension is turned on.
extension=php_openssl.dll
What might be wrong?
Just edit php.ini file and uncomment by removing ";" before this line --extension=openssl. in php.ini file. and it will start working properly.
If you have shut XAMPP down and restarted it, it may be worth running the composer install command again, or simply running composer update to ensure that all dependancies are being loaded correctly.
Modify php.ini and enable openssl extension in you php environment.
To find php installation path, run below command in terminal or cmd
php --ini
Output something like below:
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: C:\php-7.3.8\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
here mine is
Loaded Configuration File is C:\php-7.3.8\php.ini
open php.ini with any editor using vim, nano, notepad++ or any editor.
find extension=openssl remove ;
from ;extension=openssl
to extension=openssl
save and restart server.
composer install
didn't fix the problem, but the following does:
composer update
This problem can also arise if incorrect php.ini file is loaded.
Make sure in your config php_module is defined in the httpd.conf
<IfModule php_module>
PHPINIDir "C:/xampp/php"
</IfModule>

How to set default php.ini to be used, OSX Yosemite

I set up a new environment using OSX Yosemite.
I'm using the built-in PHP.
I'd like to change some config in php.ini such as date.timezone but none of the modifications are working despite restarting the apache server (sudo apachectl restart).
phpinfo() is giving a different path than php --ini command.
phpinfo():
Configuration File (php.ini) Path /usr/local/php5/lib
Loaded Configuration File /usr/local/php5/lib/php.ini
Via commands :
which php
/usr/bin/php
php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /Library/Server/Web/Config/php
Additional .ini files parsed: (none)
So I guess I have to tell somewhere where I should set the default php.ini to be used.
Any ideas, hints?
move the configuration file to the right spot and update the timezone.
$ sudo cp /etc/php.ini.default /etc/php.ini
Open the config file /etc/php.ini, find the line that sets your timezone and update it correspondingly.
date.timezone = Europe/Berlin
Do not forget to remove the ; at the beginning.
Restart the Apache server to have PHP load the new .ini file.
sudo apachectl restart
SAPI module specific location (PHPIniDir directive in Apache 2, -c command line option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH environment variable in THTTPD)
http://php.net/manual/en/configuration.file.php
Try changing PHPIniDir in httpd.conf.
On mac sierra with php7.1, edit /usr/local/etc/php/7.1/php.ini won't work, you can edit like this:
1) cp /etc/php.ini.default php.ini
2) edit php.ini to add
date.timezone = Europe/Berlin
then restart your apache,
Short answer: If you're on mac and you have the file /usr/local/php5/php.d/99-liip-developer.ini then edit timezone there and it will effect php-cgi (web-browser)
Long answer:
n mac system for few settings like timezone php.ini file (showing loaded in phpinfo) don't work. Because sometimes we unknowingly install php packaged by Liip. That's why apache picks up few settings from liip-developer.ini config file which is usually located at /usr/local/php5/php.d/99-liip-developer.ini

Enable php5-curl on OpenSuse with Nginx

I have OpenSuse Server 10.3 with nginx for web server.
I need to enable php5-curl. Installed it successfully. Then restarted web server, but nothing changed.
Any ideas?
Thank you
You probably didn't actually load the extension yet. Look at your phpinfo() to find out where PHP is looking for .ini files. If you have a section labelled something like "Scan this dir for additional .ini files", then make a new file in that directory ('curl.ini') with the single line:
extension=curl.so
If you don't have a 'Scan' dir, look for 'Loaded Configuration File' and append the same line to the end of that file.

Categories