How to configure PHP Intl extension on MacOS Mojave? [duplicate] - php

I followed a guide which used home-brew to install the lastest version of php (5.4.8) on OSX Mountain Lion.
I then followed a guide which showed me how to setup and use the pre-installed apache on OSX.
However when I try running up a base Symfony 2 project I get a bunch of errors relating to missing date.timezone in the php.ini.
However I have this correctly setup the php.ini but doing a quick phpinfo() in the Symfony project shows that its using the old preinstalled version of php (5.3) rather than the new one.
In terminal if I type which php & php -v, It shows the correct new version is being used.
But the phpinfo() shows

Did you follow all the instructions provided in the Caveats?
Run brew info php54 to see them again.
Especially the line:
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php5_module /usr/local/Cellar/php54/5.4.8/libexec/apache2/libphp5.so

Apache is not aware of the homebrew version of PHP (i.e. /usr/bin/php). You see it on the command line because you've likely modified your PATH (i.e. /usr/local/bin/php).
You can modify this in your httpd.conf file.
I am not a fan of homebrew or other package libraries. Primarily because Mac OS X is built atop Unix. Furthermore, all but MySQL are installed natively. Here's an article on installing Apache, MySQL, and PHP on Mac OS X.
Disclaimer: I wrote that article.

Today I have same issue for updating php 7.2 to 7.3 as requirement of Laravel 6. Here is my solution.
Open your httpd.conf file in "/etc/apache2/http.conf"
Search (Ctrl + w) for "LoadModule php"
Uncomment that row
Restart your apache with "sudo apachectl restart"
Then, your php version in local web server (apache2) will be updated

Related

Install phalcon on osx

I did everything described here (for OS X)
https://docs.phalconphp.com/en/latest/reference/install.html#mac-os-x
https://phalconphp.com/en/download
I also added extension=phalcon.so to the php.ini and restarted the webserver.
I copied the compiled lib to /Applications/XAMPP/xamppfiles/lib/php/extensions
But when I search for "phalcon" in phpinfo there is no entry, so phalocn was not installed.
Has anyone an idea what I can do to fix this problem?
PS: I use xampp as web server (PHP Version 5.5).

PHP extensions on MAMP 3.5

I have installed MAMP 3.5 with Apache 2.4.16 on Yosemite 10.10.5 and have run into some obstacles that I find hard to solve.
The first issue was that virtual host settings have changed in Apache but that I managed to fix.
The remaining problem is with extensions. I use gettext in an application and it can not be found.
php -v says PHP 5.6.10 (cli)
phpinfo() says PHP 5.5.27
php --ini says /Applications/MAMP/bin/php/php5.6.10/conf/php.ini
The php.ini path seems to be correct although phpinfo() says that extension_dir is /usr/lib/php/extensions/no-debug-non-zts-20121212
This seems very strange to me? The gettext extension is not in this directory but is found along with all other relevant extensions in the directory listed in the php.ini file for PHP 5.6.10 which is the one that should be used...
Any ideas what has gone wrong and how I can make PHP use the correct ini file?
CLI uses the installed version of OSX, MAMP uses it's own version.
The easiest way to use same version for both is to add the MAMP version first in your path in ~/.bash_profile.
export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php/php7.0.0/bin/:~/bin:$JAVA_HOME/bin:$PATH
of course you need to replace the php7.0.0 part with the version you want to use.
Quit your terminal app and reopen it, and try php -v again.

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.

OS X 10.10 - apache will not run PHP from homebrew

I have installed php55 with homebrew to get postgresql support and linked the php module in apache.
LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so
Still my phpinfo() - shows PHP 5.5.20 (the built in OS X). But from terminal I get PHP 5.5.26.
What can I do to fix this and force apache to use PHP 5.5.26?
I solved this. I solved this with removing PHP55 (brew uninstall php55 and related php pdo_psql) and reinstalling (brew install php55 --with-postgresql) since I needed postgresql support. I then made sure apache was stopped and started it again. I needed to edit the php.ini file that is now at
/usr/local/etc/php/5.5/php.ini
Everything seems fine now and using the new PHP55 I installed with homebrew.

PHP extensions not loading in phpinfo

So I'm running MAMP on Mountain Lion and I've installed gmagick and imagick using pecl, both are relase candidates (mainly because gmagick doesn't have a stable release and imagick 3.0.0 doesn't install, it gives a make error). The modules appear when I run php -i in the terminal but not in phpinfo(), I have checked the php.ini it is the same for both so that is not the issue.However I have installed bitset(which is a stable release) and it appears in phpinfo() and php -i. So my question is does PHP have any configuration option that does not load extensions if they are not stable? Btw, I did restart my server after the changes to the ini file.
You will probably now have two php installations on your machine. Mountain Lion ships with a preinstalled php version. Trylocate php.ini in Terminal to find out how many php.inis are installed.
In your phpinfo() page there is also noted which php.ini is in use. You might want to open the exact php.ini which is used for your phpinfo() and make sure the extentions are loaded.
There should be two lines like
extension=/path/to/gemagicext/gmagic.so
extension=/path/to/imagick/imagick.so
I faced a similar problem with php-fpm and nginx server. The problem was due to the fact that the updated php configuration was not reflected in the current active php-fpm worker processes. I have to manually kill the fpm process and restart it again to have the updated extensions info.
Steps that worked for me:
1) Look for active php-fpm process
ps ax | grep "fpm"
mostly this will list more than one process
2) kill process manually
kill -9 [pid_got_from_previous_command]
3) restart php-fpm process
sudo service php5-fpm start
Note: Trying something like sudo service php-fpm reload or sudo service php-fpm restart didn't work since the old child processes retained the old configuration. Killing the active processes and restarting php fpm what updated the phpinfo for me.
I had the same problem CentOS 6.6 x64, php 5.5.27 and I followed the steps from
http://php.net/manual/en/imagick.installation.php
First of all download a tar image of the ImageMagick install from here:
sourceforge.net/projects/imagemagick/files/
Unpack it and then from terminal issue the following commands:
1. "cd ImageMagick-6.9.1-10" - go where you placed the folder
2. ./configure
3. make
4. make install
5. make check
6. install imagick extension from pecl.php.net/package/imagick/download 3.1.2
7. cd imagick-3.1.2
8. phpize
9. ./configure --with-imagick=/opt/local
10. make
11. make install
12. Copy imagick.so in your PHP extensions folder and add extension=imagick.so in php.ini
Restart apache: service httpd restart
I am sure this problem is related to your extension and PHP server compatibility. I encountered such problems when I created my own extensions. Your extension should compatible with your PHP server in three main attributes:
1- The Zend API number which your PHP server is configured with ( in phpinfo() you can find this number), this number should be the same with your extension header file at build time.
2- The compiler version on your PHP server and your extension must be the same.
3- Thread safety in your PHP server is important. If you use thread-safe server then your extension must be built with php thread-safe library and if you use non-thread safe server you should build your extension with PHP-nts library.

Categories