如何在 Ubuntu 上安装 Xdebug?
How to install Xdebug on Ubuntu?
我正在尝试在 Ubuntu 上安装 xdebug
:
sudo apt-get install php-xdebug
并出现以下错误:
Need to get 806 kB of archives. After this operation, 4.423 kB of
additional disk space will be used. Err:1
http://ppa.launchpad.net/ondrej/php/ubuntu artful/main amd64
php-xdebug amd64 2.5.5-3+ubuntu17.10.1+deb.sury.org+1 404 Not Found
E: Failed to fetch
http://ppa.launchpad.net/ondrej/php/ubuntu/pool/main/x/xdebug/php-xdebug_2.5.5-3+ubuntu17.10.1+deb.sury.org+1_amd64.deb
404 Not Found E: Unable to fetch some archives, maybe run apt-get
update or try with --fix-missing?
我该如何解决这个问题?
首先,您需要使用以下命令更新本地包:
sudo apt update
# OR
sudo apt-get update
现在您可以使用以下命令安装 xdebug
:
sudo apt install php-xdebug
并将其配置为:
sudo nano /etc/php/7.0/mods-available/xdebug.ini
在其中添加以下代码:
zend_extension=/usr/lib/php/20151012/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9005 #if you want to change the port you can change
注意:目录 20151012
很可能与您不同。 cd
到 /usr/lib/php
并检查此格式的哪个目录中有 xdebug.so
文件并使用该路径。
然后重启服务:
sudo systemctl restart php7.0-fpm
sudo systemctl restart nginx # If you are using nginx server
sudo systemctl restart apache2 # If you are using apache server
我认为您应该先输入以下命令,用存储库中所做的最新更改更新本地包索引:
sudo apt update
或者
sudo apt-get update
APT 包索引本质上是一个数据库,其中包含来自 /etc/apt/sources.list 文件和 /etc/apt/sources.list.d 目录中定义的存储库中的可用包。
我用了下面的方法,很管用
从 php 信息
检索内容
$ php -i> info.txt
复制 info.txt 文件中的所有文本,然后输入 xdebug installation wizard
并按照那里的排名。
看起来像这样
Download xdebug-2.7.2.tgz
Install the pre-requisites for compiling PHP extensions.
On your Ubuntu system, install them with: apt-get install php-dev autoconf automake
Unpack the downloaded file with tar -xvzf xdebug-2.7.2.tgz
Run: cd xdebug-2.7.2
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: 20170718
Zend Extension Api No: 320170718
If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.
Run: ./configure
Run: make
Run: cp modules/xdebug.so /usr/lib/php/20170718
Update /etc/php/7.2/cli/php.ini and change the line
zend_extension = /usr/lib/php/20170718/xdebug.so
请禁用 ppa/php 和 运行 sudo apt install php-xdebug
php7.4.8 的更新:在 Xdebug 配置文件中
/etc/php/7.4/mods-available/xdebug.ini
我必须添加以下行:
xdebug.force_display_errors = 1
因为 Xdebug 无法正常工作。
如何在 Ubuntu
上安装 Xdebug
如果上述解决方案中的 none 适合您,那么您最后的选择可能是使用 pecl
如果您还没有安装 pecl
:
sudo apt -y install php7.3-dev php-pear // replace php7.3 with your version
运行 pecl
安装 xdebug
:
sudo pecl install xdebug
安装结束时,您可能会看到以下输出:
Build process completed successfully
Installing '/usr/lib/php/20180731/xdebug.so'
install ok: channel://pecl.php.net/xdebug-3.0.2
configuration option "php_ini" is not set to php.ini location
You should add "zend_extension=/usr/lib/php/20180731/xdebug.so" to php.ini
打开你的 php.ini 文件,在最底部添加 zend_exntension 行(如果 pecl 已经能够放置它则跳过):
sudo vim /etc/php/7.3/apache2/php.ini // again replace 7.3 with your version
最后,重新启动您的网络服务器,或 PHP-FPM,具体取决于您使用的是什么。
对于找到此答案的任何人,请记住 xdebug 2 和 xdebug 3 之间存在重大变化。这里有 XDebug 提供的升级指南:http://xdebug.org/docs/upgrade_guide
我正在尝试在 Ubuntu 上安装 xdebug
:
sudo apt-get install php-xdebug
并出现以下错误:
Need to get 806 kB of archives. After this operation, 4.423 kB of additional disk space will be used. Err:1 http://ppa.launchpad.net/ondrej/php/ubuntu artful/main amd64 php-xdebug amd64 2.5.5-3+ubuntu17.10.1+deb.sury.org+1 404 Not Found E: Failed to fetch http://ppa.launchpad.net/ondrej/php/ubuntu/pool/main/x/xdebug/php-xdebug_2.5.5-3+ubuntu17.10.1+deb.sury.org+1_amd64.deb 404 Not Found E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
我该如何解决这个问题?
首先,您需要使用以下命令更新本地包:
sudo apt update
# OR
sudo apt-get update
现在您可以使用以下命令安装 xdebug
:
sudo apt install php-xdebug
并将其配置为:
sudo nano /etc/php/7.0/mods-available/xdebug.ini
在其中添加以下代码:
zend_extension=/usr/lib/php/20151012/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9005 #if you want to change the port you can change
注意:目录 20151012
很可能与您不同。 cd
到 /usr/lib/php
并检查此格式的哪个目录中有 xdebug.so
文件并使用该路径。
然后重启服务:
sudo systemctl restart php7.0-fpm
sudo systemctl restart nginx # If you are using nginx server
sudo systemctl restart apache2 # If you are using apache server
我认为您应该先输入以下命令,用存储库中所做的最新更改更新本地包索引:
sudo apt update
或者
sudo apt-get update
APT 包索引本质上是一个数据库,其中包含来自 /etc/apt/sources.list 文件和 /etc/apt/sources.list.d 目录中定义的存储库中的可用包。
我用了下面的方法,很管用 从 php 信息
检索内容$ php -i> info.txt
复制 info.txt 文件中的所有文本,然后输入 xdebug installation wizard 并按照那里的排名。
看起来像这样
Download xdebug-2.7.2.tgz
Install the pre-requisites for compiling PHP extensions.
On your Ubuntu system, install them with: apt-get install php-dev autoconf automake
Unpack the downloaded file with tar -xvzf xdebug-2.7.2.tgz
Run: cd xdebug-2.7.2
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: 20170718
Zend Extension Api No: 320170718
If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.
Run: ./configure
Run: make
Run: cp modules/xdebug.so /usr/lib/php/20170718
Update /etc/php/7.2/cli/php.ini and change the line
zend_extension = /usr/lib/php/20170718/xdebug.so
请禁用 ppa/php 和 运行 sudo apt install php-xdebug
php7.4.8 的更新:在 Xdebug 配置文件中
/etc/php/7.4/mods-available/xdebug.ini
我必须添加以下行:
xdebug.force_display_errors = 1
因为 Xdebug 无法正常工作。
如何在 Ubuntu
上安装 Xdebug如果上述解决方案中的 none 适合您,那么您最后的选择可能是使用 pecl
如果您还没有安装 pecl
:
sudo apt -y install php7.3-dev php-pear // replace php7.3 with your version
运行 pecl
安装 xdebug
:
sudo pecl install xdebug
安装结束时,您可能会看到以下输出:
Build process completed successfully
Installing '/usr/lib/php/20180731/xdebug.so'
install ok: channel://pecl.php.net/xdebug-3.0.2
configuration option "php_ini" is not set to php.ini location
You should add "zend_extension=/usr/lib/php/20180731/xdebug.so" to php.ini
打开你的 php.ini 文件,在最底部添加 zend_exntension 行(如果 pecl 已经能够放置它则跳过):
sudo vim /etc/php/7.3/apache2/php.ini // again replace 7.3 with your version
最后,重新启动您的网络服务器,或 PHP-FPM,具体取决于您使用的是什么。
对于找到此答案的任何人,请记住 xdebug 2 和 xdebug 3 之间存在重大变化。这里有 XDebug 提供的升级指南:http://xdebug.org/docs/upgrade_guide