enabling opcache on mac catalina, php 7.4 installed with homebrew - macos-catalina

I've modified the php.ini file to enable opcode caching and restarted apache but it is nowhere in sight with phpinfo(). php -v says:
PHP 7.4.1 (cli) (built: Dec 18 2019 14:46:18) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
Most other examples I see form this command say something like "with Zend Opcache".
No other .ini files except the one at /usr/local/etc/php/7.4/php.ini are being used, according to php.
I tried installing zend opcache with pecl but that says it's for versions 5.2.0 thru 5.5.0.
Searched through google for 30 min. but not getting anywhere.

OK, got it. Searched for the opcache.so file in Finder and added it's path to php.ini:
zend_extension=/usr/local/Cellar/php/7.4.1/lib/php/20190902/opcache.so

Related

Installing Sitecore 9, SIF Error on installing SOLR cores

When installing Sitecore with SIF, I experiencing the following error.
These are my modules
who can help thank you
For Sitecore 9.0 (update-x) you need SIF 1.2.1,
Since you already have a newer SIF version, it will uses the latest version and fail.
You can add this on the top of your PowerShell script to force use the 1.2.1 version:
Remove-Module -Name SitecoreInstallFramework
Import-Module -Name SitecoreInstallFramework -RequiredVersion 1.2.1
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Note: If you have already before installed Sitecore with higher SIF version, then you are probably running into a certificate issue when you fix the wrong SIF version error. See Sitecore XP 9.0 Update-2 installation fails when XP 9.1 is installed on the same PC
or you can delete the other Sitecore certificates if you don't need them, (Personal and Trusted Root Certification Authorities) with certmgr
or with PowerShell:
Set-Location Cert:\LocalMachine\Root
#get a list
Get-ChildItem | Format-Table FriendlyName, Thumbprint -AutoSize
#example of remove a certificate
Get-ChildItem Cert:\LocalMachine\Root\301F9A11F82BF45DA853BE573811AFF4ACA3B7CE | Remove-Item
Because your installation failed, it is also possible you have already created a certificates with precisely the same DNS name as the installer try to create than you also need to delete the old not in use certificate.
A while ago, we encountered this issue too. After some research we found out that the casing of the parameter "name" didn't match between the installer scripts and the configuration files (The scripts used "name" while the config files mentioned "Name"). After renaming the parameter in the config files, the installation process could continue.
sitecore-solr.json
xconnect-solr.json

Cakephp : intl extension missing

I am trying to install CakePHP 3.8 in my mac ( macos high sierra version 10.13.6), but i had this problem since yesterday tell me that extension intl is missing from your system
User-iMac:TEST zakaria$ composer create-project --prefer-dist
cakephp/app my_app_name
Installing cakephp/app (3.8.0)
- Installing cakephp/app (3.8.0): Loading from cache
Created project in my_app_name
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of
packages.
Problem 1
- cakephp/cakephp 3.8.1 requires ext-intl * -> the requested PHP
extension intl is missing from your system.
- cakephp/cakephp 3.8.0 requires ext-intl * -> the requested PHP
extension intl is missing from your system.
- Installation request for cakephp/cakephp 3.8.* -> satisfiable
by
cakephp/cakephp[3.8.0, 3.8.1].
To enable extensions, verify that they are enabled in your .ini
files:
- /etc/php.ini
You can also run `php --ini` inside terminal to see which files
are
used by PHP in CLI mode.
User-iMac:TEST User$
i tried to uncomment extension=php_intl.dll in php.ini
i tried to add extension=intl.so
And so many solutions out there but nothing seems to work
Unfortunately, Intl extension is missing on native instalation of PHP 7.1.24 on Mac OS high sierra.
Download PHP 7.1 from php.net, install XCode Command Line Tools, ICU (http://site.icu-project.org/), Autoconf, reinstall the developer tools header files, and finally install Intl extension using phpize.
Important: you'll have to disable SIP.

PHP Parse error: syntax error, unexpected '?' in helpers.php 233

When I create a new Laravel project, the browser displays an error 500. I found this in the log:
PHP Parse error: syntax error, unexpected '?' in vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233
the code in 233 is:
return app('cache')->get($arguments[0], $arguments[1] ?? null);
But as i know, null coalescing operator( ?? ) is supported from PHP 7.0
My PHP Version:
PHP 7.1.8-2+ubuntu14.04.1+deb.sury.org+4 (cli) (built: Aug 4 2017 14:34:05) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.8-2+ubuntu14.04.1+deb.sury.org+4, Copyright (c) 1999-2017, by Zend Technologies
Laravel Version: 5.5.0
Who knows what happened?
If I had to guess, I'd say you installed the PPA 7.1.8 as CLI only (php7-cli). You're getting your version info from that, but your libapache2-mod-php package is still 14.04 main which is 5.6. Check your phpinfo in your browser to confirm the version. You might also consider migrating to Ubuntu 16.04 to get PHP 7.0 in main.
I had approximately the same problem with Laravel 5.5 on ubuntu, finally i've found a solution here to switch between the versions of php used by apache :
sudo a2dismod php5
sudo a2enmod php7.1
sudo service apache2 restart
and it works
If you came across this error while using the command line its because you must be using php 7 to execute whatever it is you are trying to execute. What happened is that the code is trying to use an operator thats only available in php7+ and is causing a syntax error.
If you already have php 7+ on your computer try pointing the command line to the higher version of php you want to use.
export PATH=/usr/local/[php-7-folder]/bin/:$PATH
Here is the exact location that worked based off of my setup for reference:
export PATH=/usr/local/php5-7.1.4-20170506-100436/bin/:$PATH
The operator thats actually caused the break is the "null coalesce operator" you can read more about it here:
php7 New Operators
If you have newly upgraded your php version you might be forget to restart your webserver service.
I had the same error and the problem is that I had not correctly installed Composer.
I am using Windows and I installed Composer-Setup.exe from getcomposer.org and when you have more than one version of PHP installed you must select the version that you are running at this point of the installation
I had the same problem with the laravel initiation. The solution was as follows.
1st - I checked the version of my PHP. That it was 5.6 would soon give problem with the laravel.
2nd - I changed the version of my PHP to PHP 7.1.1. ATTENTION, in my case I changed my environment variable that was getting Xampp's PHP version 5.6 I changed to 7.1.1 for laragon.
3rd - I went to the terminal / console and navigated to my folder where my project was and typed the following command: php artisan serves.
And it worked! In my case it started at the port: 8000 see example below.
C: \ laragon \ www \ first> php artisan serves
Laravel development server started: http://127.0.0.1:8000
I hope I helped someone who has been through the same problem as me.
I had similar kind of problem. It looked like this:
Null coalescing operator( ?? ) is not supported by my version of PHP. As I had no option to upgrade the version, I wrote something like this: {{ $product->price ? $product->price:'' }} instead of {{ $product->price ?? '' }} and it solved the problem.

Drupal 8 - Commerce Module - BC math PHP extension not found

I'm trying to install the commerce module in Drupal 8 however I get the error 'BC math PHP extension not found'.
I've searched for this problem and tried different things such as editing the PHP.ini by adding 'bcmath.scale=2' however I still get the error message.
Any help would be appreciated, thanks.
Just install bcmath plugin for your php version with no need to (re)build php as mentioned on accepted answer
# get php version
php -v
# install bcmath based on your version lets assume php 7.1
# for ubuntu
sudo apt install php7.1-bcmath
# for centos
yum install bcmath
# restart apache
sudo systemctl restart apache2
Above problem appears when installing commerce or commerce kickstart using composer
Update 2020
Please refer to #GiorgosK's answer for installing bcmath via a package manager if you are using a distribution that provides a bcmath package for PHP. I will ask the OP in comments to update the recommended answer, since that solution is probably what most people need.
Three years ago when I answered this question, I suggested that you have to rebuild PHP to get bcmath. That was incorrect. I was using an older distribution of Debian/Ubuntu that provided bcmath as a statically linked extension in the core php package. I determined at the time (incorrectly) that bcmath was a core extension that had to be enabled at build-time (like SPL and PCRE).
For those trying to troubleshoot a missing bcmath extension (such as those building/installing PHP themselves or nevertheless encountering issues), I've corrected and updated my original answer below. It explains in detail how to troubleshoot a missing PHP extension.
Original Answer (Corrected)
The error message indicates that PHP wasn't built with bcmath support or can't find the installed extension. PHP extensions are either built into PHP directly or they are loaded from an external dynamic library file at runtime.
Since PHP obviously doesn't have the extension built-in, it can't find the external library file that provides bcmath. This file on POSIX platforms will be called bcmath.so and php_bcmath.dll on Windows.
Extension files are installed under a directory indicated by the extension_dir property in php.ini. To determine the value of this property, run the following command:
php -r 'echo ini_get("extension_dir").PHP_EOL;'
The default value for this property is configured when PHP is built and may vary from distribution-to-distribution.
Once you verify the extension file is installed in this location, you can then check to see if the extension is enabled in php.ini. You should see a line that enables the extension like so:
# POSIX platforms
extension=bcmath.so
# Windows
extension=php_bcmath.dll
For Linux distributions like Ubuntu/Debian that install extensions via the package manager, the format is somewhat different since Debian employs a distributed configuration. Typically the package manager installs everything correctly, but you can check to see if an ini file exists for bcmath under the corresponding conf.d directory. These small ini files are snippets imported into the larger php.ini file, and they are typically symlinked to /etc/phpX/mods-available, allowing modules to be initially enabled for all PHP SAPIs such as CLI, CGI, Apache Mod PHP, ETC. Make sure a symlink exists for the PHP SAPI you need to use.
To ensure your PHP is loading the extension, run phpinfo(); in a test page and search for bcmath. You can also more easily do this with the CLI using a command like:
$ php -i | grep -i bcmath
# Success output: BCMath support => enabled
# (Another command that works well for checking extensions)
$ php -m | grep -i bcmath
# Success output: bcmath
In order for the CLI to show accurate results, it must target the same php.ini file. If it doesn't, then use the -c option to temporarily point the CLI at the correct php.ini (i.e. the one being used by your Drupal site).
Add BC MATH extension for PHP 7.2
If you are getting this (https://prnt.sc/sehmd5) error then, run below command using vagrant ssh
Run these command in root of vagrant ssh
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.2-bcmath
service apache2 restart
Then open php.ini and search for bcmath
If bcmath scale is 0, Change it to 2
Restart php
Restart Apache
Hard Reload website
Install required modules
Similarly for any version of PHP, you only need to change PHP version in 3rd command.

Jetty 6 from Debain packages with Oracle Java

i try to install jetty from the Debian (wheezy) packages. But instead of default Openjdk i installed Oracle Java.
Download tar.gz. and build a deb package
(https://wiki.debian.org/Java/Sun or http://www.webstimme.de/2013/02/05/linux-java-unter-debian-wheezy-installieren-anleitung/)
$java -v
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
Afterwards i istalled jetty with apt-get, but it also installes the packages
openjdk-6-jre-headless openjdk-6-jre-lib
so Java is then
java -version
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1~deb7u1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
I will give it a second try with installing the Oracle Java version 1.6.
Any Experiences with installing the jetty package repo and use an Oracle Java, will this ever works?
Edit:
It's possible with Oracle Java 6 (1.6) but not with Oracle Java 7 (1.7)
I tried to run it with Oracle Java because of potential better performance for Solr. I somebody has knowledge about the difference in perfomance with Open JDK and Oracle Java it would be nice to post it here :) Thanks
Edit:
I was wrong. It runs also with Oracle JDK 7.
Just download and extract it e.g. to /opt/Oracle_Java and put the path in the /etc/default/jetty as JAVA_HOME
JAVA_HOME="/opt/Oracle_Java"
Which jre is used by default is controlled by alternatives system. Use the command update-java-alternatives -l to list which JREs are installed and then use update-java-alternatives -sto choose which JRE to use.
I have two JDKs on my machine:
# update-java-alternatives -l
j2sdk1.6-oracle 315 /usr/lib/jvm/j2sdk1.6-oracle
jdk-7-oracle-x64 317 /usr/lib/jvm/jdk-7-oracle-x64
To use jdk-7 as my default JDK I would run update-java-alternatives -s jdk-7-oracle-x64
It is possible to run Jetty 6 from Debian or Ubuntu package repository with Oracle Java 6 and Oracle Java 7.