Delete old PHP version under Mac system to install the latest PHP version and Xdebug

Source: Internet
Author: User
Tags derick gettext gmp ldap mcrypt pear phpinfo webp
This article describes the content of the Mac system to remove the old PHP version installed the latest PHP version and Xdebug, with a certain reference value, now share to everyone, the need for friends can refer to

My 2015 version of the MACPRO system is installed by default php5.6.28 version, I use brew or other online way to install php7.0 and php7.1, but when I print phpinfo (), My php5.6.28 again appeared, I feel I have obsessive-compulsive disorder, I have to deal with it not, a whole day to waste a lot of time, online various methods Chabudu tried. However, many can only be used for reference, because everyone's computer environment may be slightly different. Now it's done, here's a note.

My first step was to delete the PHP version I saw, and I was going to erase all of the PHP on my computer and then reinstall the latest version. This operation is risky and requires caution. This is said on the Internet: PS: It is not recommended to delete your own PHP version. Because some software may be dependent on the PHP environment. Although you can install a new version of PHP from your own computer or using brew, it is not recommended to be a novice. Remember to use a TM backup system before you can restore the file.

But you don't need to do that. More than one version should also be no problem. The removal process, the User/bin directory executable PHP can not be deleted, although there is a Mac under the mode in Safe mode can delete any file operation, but I did not do, this file is retained, there is a php-config, vi open file can see the PHP version is the oldest, I guess that could be the cause.

When I think of other deletions, I reinstalled the php7.1 version with Brew. At this point you will find that this directory problem has become a top priority, many tutorials and paths on the Web are now gone. Then follow this article and go.

After the brew installs php7.1, there will be something:

The php.ini and Php-fpm.ini file can is found in:

/usr/local/etc/php/7.1

To enable PHP on Apache add the following to httpd.conf and restart Apache:

LoadModule php7_module/usr/local/opt/php@7.1/lib/httpd/modules/libphp7.so

<filesmatch \.php$>

SetHandler application/x-httpd-php

</FilesMatch>

Finally, check directoryindex includes index.php

DirectoryIndex index.php index.html


The php.ini and Php-fpm.ini file can is found in:

/usr/local/etc/php/7.1/


This formula is keg-only, which means it wasn't symlinked into/usr/local,

Because this was an alternate version of another formula.


If you need to the software first in your PATH run:

echo ' Export path= '/usr/local/opt/php@7.1/bin: $PATH ' >> ~/.bash_profile

echo ' Export path= '/usr/local/opt/php@7.1/sbin: $PATH ' >> ~/.bash_profile


For compilers-to-find this software-need to set:

Ldflags:-l/usr/local/opt/php@7.1/lib

Cppflags:-i/usr/local/opt/php@7.1/include

To has launchd start php@7.1 now and restart at login:

Brew Services Start php@7.1

Or, if you don ' t want/need a background service can just run:

php-fpm

This information is very useful, it tells you some methods and installation path. This information I was cornered when only to see, only to find that really can not ignore, no way to follow the above tips step by step. should be able to read, you can leave a message. Don't forget to restart PHP-FPM when you're done.

Here's the detour that I restarted npm.

There may be two errors when restarting PHP-FPM, one is unable to find or open php-fpm the second is the inability to find or open by Path error_log

Resolve the first error

Perform PS Aux|grep php-fpm to see the PHP-FPM process

Such as

Root     21891  0.0  0.0 112660   960 PTS/3    r+   16:18   0:00 grep--color=auto php-fpmroot     42891  0.0  0.1 182796  1220?        Ss   April   0:19 php-fpm:master process (/usr/local/php/etc/php-fpm.conf) Nobody   42892  0.0  0.6 183000  6516?        S    April   0:07 php-fpm:pool wwwnobody   42893  0.0  0.6 183000  6508?        S    April   0:17 php-fpm:pool www

You can see that there is a path above, I will be the brew installation path under the php-fpm.conf, with the CP command Copy to the above path. If you do not delete the old PHP, this path will have a php-fpm.config.default, you can copy the file directly and then change to php-fpm.conf can also.

The second error is log problem, then find the corresponding php-fpm.conf open, there is log and need the corresponding address, find the Mac log address. My/usr/local/var path, changed to the real address, the default address is wrong.

Then restart FPM, still not good.

PHP-FPM--fpm-config/usr/local/etc/php/5.4/php-fpm.conf--prefix/usr/local/var

Executed this sentence, found that as long as the terminal is not closed, PHP can use, shut down, hung up ...

Well, it's a first-priority introduction. Brew Services start php@7.1 this command

And then I'm at Terminal php-v and Php-fpm-v

Mengdemacbook-pro:var ghm$ Php-fpm-v
PHP 7.1.16 (fpm-fcgi) (built:apr 12 2018 03:25:57)
Copyright (c) 1997-2018 the PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
With Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
With Zend Opcache v7.1.16, Copyright (c) 1999-2018, by Zend Technologies
Mengdemacbook-pro:var ghm$ Php-v
PHP 7.1.16 (CLI) (BUILT:APR 2018 03:25:50) (NTS)
Copyright (c) 1997-2018 the PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
With Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
With Zend Opcache v7.1.16, Copyright (c) 1999-2018, by Zend Technologies

At first my php-v shows the latest, PHP-FPM, or the old version. Now that means OK.

Then open the Web page to see the Phpinfo ()

PHP Version 7.1.16

System Darwin mengdemacbook-pro.local 16.4.0 Darwin Kernel Version 16.4.0:thu Dec 22:53:21 PST 2016; Root:xnu-3789.41.3~3/release_x86_64 x86_64
Build Date APR 12 2018 03:24:25
Configure Command './configure '--prefix=/usr/local/cellar/php@7.1/7.1.16_1 '--localstatedir=/usr/local/var '--sysconfdir=/usr/ local/etc/php/7.1 '--with-config-file-path=/usr/local/etc/php/7.1 '--with-config-file-scan-dir=/usr/local/etc/ Php/7.1/conf.d '--with-pear=/usr/local/cellar/php@7.1/7.1.16_1/share/php@7.1/pear '--enable-bcmath '-- Enable-calendar '--enable-dba '--enable-dtrace '--enable-exif '--enable-ftp '--enable-fpm '-- Enable-mbregex '--enable-mbstring '--enable-mysqlnd '--enable-opcache-file '--enable-pcntl '--enable-phpdbg '- -enable-phpdbg-webhelper '--enable-shmop '--enable-soap '--enable-sockets '--enable-sysvmsg '--enable-sysvsem ' '--enable-sysvshm '--enable-wddx '--enable-zip '--with-apxs2=/usr/local/opt/httpd/bin/apxs '--with-bz2 '-- With-fpm-user=_www '--with-fpm-group=_www '--with-freetype-dir=/usr/local/opt/freetype '--with-gd '-- With-gettext=/usr/local/opt/gettext '--with-gmp=/usr/local/opt/gmp '--with-icu-dir=/usr/local/opt/icu4c '--with-jpeg-dir=/usr/local/opt/jpeg '--with-kerberos '--with-layout=gnu '--with-ldap '--WITH-LDAP-SASL '-- With-libedit '--with-libzip '--with-mcrypt=/usr/local/opt/mcrypt '--with-mhash '--with-mysql-sock=/tmp/ Mysql.sock '--with-mysqli=mysqlnd '--with-ndbm '--with-openssl=/usr/local/opt/openssl '--with-pdo-dblib=/usr/ Local/opt/freetds '--with-pdo-mysql=mysqlnd '--with-pdo-odbc=unixodbc,/usr/local/opt/unixodbc '-- With-pdo-pgsql=/usr/local/opt/libpq '--with-pgsql=/usr/local/opt/libpq '--with-pic '--with-png-dir=/usr/local/ Opt/libpng '--with-pspell=/usr/local/opt/aspell '--with-unixodbc=/usr/local/opt/unixodbc '--with-webp-dir=/usr /local/opt/webp '--with-xmlrpc '--with-xsl '--with-zlib '--with-curl '

Pit more, two days some I also forget, who has encountered problems can leave a message ...

Next Xdebug Installation

Recommended by official, less detours

Open this Xdebug official page

Then command+a Select all, command +v copy, put in the box, run the button at the bottom, will print out a lot of the information we need to install Xdebug

Follow the steps to go on, a little pit is, when the execution of phpsize: command cannot find, this time found the brew installed PHP executable bin directory, directly with the inside of the phpsize to run, the absolute path can be executed. There are official downloads of the page has a level two directory, and the same name, do not make a mistake, or can not run.

    1. Download xdebug-2.6.0.tgz

    2. Unpack The downloaded file with the Code>tar-xvzf xdebug-2.6.0.tgz

    3. Run: cd xdebug-2.6.0

    4. Run: Phpize (see the FAQ if you do not have phpize .

      As part of the IT output it should show:

      configuring for: ... Zend Module API no:20160303zend Extension API no:320160303 

      If It does not, you are using the wrong Phpize . Please followthis FAQ entry and skip the next step.

    5. Run: ./configure

    6. Run: make

    7. Run: cp modules/xdebug.so/usr/local/lib/php/pecl/20160303

    8. Edit /usr/local/etc/php/7.1/php.ini and add the line
      zend_extension =/usr/local/lib/php /pecl/20160303/xdebug.so

    9. Restart the webserver

Then, refresh PathInfo (), command+f find Xdebug


See, it worked.

And then it's configuration xdebug.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.