Table of Contents
PHP Version 7.1.16
Home Backend Development PHP Tutorial Delete the old php version and install the latest php version and Xdebug under mac system

Delete the old php version and install the latest php version and Xdebug under mac system

May 28, 2018 pm 05:07 PM
php Install Version

The content of this article is about deleting the old php version and installing the latest php version and Xdebug under the mac system. It has a certain reference value. Now I share it with everyone. Friends in need can refer to it

My 2015 macpro system has version php5.6.28 installed by default. I installed php7.0 and php7.1 using brew or other online methods. However, when I print phpinfo(), my php5. It happened again on 6.28. I felt like I had obsessive-compulsive disorder and I had to fix it. I wasted more than a day and tried almost every method on the Internet. However, many of them can only be used for reference and are of little use, because everyone's computer environment may be slightly different. Now that it's done, record it here.

My first step is to delete the php version I see. I plan to delete all php on the computer and then reinstall the latest version. This operation is risky and requires caution. This is what the Internet says: ps: It is not recommended to delete the built-in PHP version because some software may depend on the PHP environment. Although you can self-compile or use brew to install a new version of PHP, it is not recommended for novices. Remember to do it before operating. Use TM to back up the system so that files can be restored after a mistake.

But you don’t have to do this. One more version should be fine. During the deletion process, the executable file php in the user/bin directory cannot be deleted. Although there is a way to delete any file in safe mode on Mac, I did not do it. This file is retained, and there is also php. -config, when you open the file with vi, you can see that the php version is the oldest. I guess this may be the cause.

#When I thought the others were deleted, I used brew to reinstall the php7.1 version. At this time, you will find that this directory issue has become a top priority. Many tutorials and paths on the Internet are no longer available. . Then follow this article.

brew After installing php7.1, there will be a paragraph below:

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

/usr/local/etc/php/7.1

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

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

##

## SetHandler application/x-httpd -php

##

Finally, check DirectoryIndex includes index.php

    DirectoryIndex index.php index.html


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

    /usr/local/etc/php/7.1/


This formula is keg-only, which means it was not symlinked into /usr/local,

because this is an alternate version of another formula.


If you need to have this 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 you may need to set:

    LDFLAGS:  -L/usr/local/opt/php@7.1/lib

   CPPFLAGS: -I/usr/local/opt/php@7.1/include

To have 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 you can just run:

php-fpm

This information is very useful, it tells Some methods and installation paths. I only read this information when I was desperate, and realized that I really couldn’t ignore it and couldn’t follow the above tips step by step. You should all be able to understand it, if not you can leave a message. After finishing, don’t forget to restart php-fpm

Let’s talk about the detour I took when restarting npm


There may be two errors when restarting php-fpm, one is that it cannot be found Or open php-fpm. The second is that the error_log cannot be found or opened according to the path.


Solution to the first error

Execute ps aux|grep php-fpm to see php-fpm The process

such as

root     21891  0.0  0.0 112660   960 pts/3    R+   16:18   0:00 grep --color=auto php-fpm
root     42891  0.0  0.1 182796  1220 ?        Ss   4月18   0:19 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
nobody   42892  0.0  0.6 183000  6516 ?        S    4月18   0:07 php-fpm: pool www
nobody   42893  0.0  0.6 183000  6508 ?        S    4月18   0:17 php-fpm: pool www
Copy after login
can see that there is a path above. I copied php-fpm.conf under the brew installation path to the above path using the cp command. If you do not delete the old php, there will be a php-fpm.config.default in this path. You can copy this file directly and change it to php-fpm.conf.


The second error is a log problem. Then find the corresponding php-fpm.conf and open it. There is a log in it and the corresponding address. Find the address of the log under mac. Mine is in the /usr/local/var path and is changed to the real address. The default address is wrong.

Then restart fpm, still no problem.

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

After executing this sentence, I found that as long as the terminal is not closed, php can be used, but if it is closed, it will hang. . .

What’s better, let’s introduce it first.

brew services start php@7.1 This command

Then I run php -v and php-fpm -v

mengdeMacBook in the terminal -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 12 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 displayed the latest version, but php-fpm still executed the old version. Now the explanation is ok

Open the web page and look at phpinfo()

PHP Version 7.1.16

System Darwin mengdeMacBook-Pro.local 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 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-intl' '--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'

坑多,两天了有些我也忘了,谁有遇到问题可以留言。。。

下面说下xdebug 安装

 建议按官方,少走弯路

打开这个xdebug 官方页面

然后command+a 全选,command +v 复制,放到框框里面,运行底部的按钮,会打印出很多我们安装xdebug所需要用到的信息

按步骤走就好了,有一点坑就是,当执行phpsize 的时候报:command cannot find ,这时候找到brew 安装php 的可执行bin目录,直接用那个里面的phpsize 拿来运行,绝对路径运行就可以执行了。还有官方下载的页面有两级目录,而且名字一样,别弄错了,不然运行不了。

  1. Download xdebug-2.6.0.tgz

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

  3. Run: cd xdebug-2.6.0

  4. Run: phpize (See the FAQ if you don't have phpize.

    As part of its output it should show:

    Configuring for:
    ...
    Zend Module Api No:      20160303
    Zend Extension Api No:   320160303
    Copy after login

    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

   然后,刷新pathinfo()  ,command+f 查找xdebug


    看到这样就成功了

  然后就是配置xdebug 了

 相关推荐:

Mac上通过docker配置PHP开发环境

Mac apache php 和CGI 的配置

The above is the detailed content of Delete the old php version and install the latest php version and Xdebug under mac system. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles