简体   繁体   English

如何在 Ubuntu 上安装 Xdebug?

[英]How to install Xdebug on Ubuntu?

I'm trying to install xdebug on Ubuntu:我正在尝试在 Ubuntu 上安装xdebug

sudo apt-get install php-xdebug

and getting following error:并收到以下错误:

Need to get 806 kB of archives.需要获得 806 kB 的档案。 After this operation, 4.423 kB of additional disk space will be used.此操作后,将使用 4.423 kB 的额外磁盘空间。 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? 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获取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 未找到 E :无法获取一些档案,也许运行 apt-get update 或尝试使用 --fix-missing?

How can I solve this problem ?我怎么解决这个问题 ?

I think that you should update the local package index with the latest changes made in the repositories first by typing the following command : 我认为您应该首先通过键入以下命令,使用存储库中进行的最新更改来更新本地软件包索引:

sudo apt update

Or 要么

sudo apt-get update

The APT package index is essentially a database of available packages from the repositories defined in the /etc/apt/sources.list file and in the /etc/apt/sources.list.d directory. APT软件包索引本质上是来自/etc/apt/sources.list文件和/etc/apt/sources.list.d目录中定义的存储库中可用软件包的数据库。

Credits 学分

How to install Xdebug on Ubuntu如何在 Ubuntu 上安装 Xdebug

If none of the above solutions worked for you, then your last resort might be to use pecl如果上述解决方案都不适合您,那么您的最后手段可能是使用pecl

If you don't have pecl installed already:如果您还没有安装pecl

sudo apt -y install php7.3-dev php-pear // replace php7.3 with your version

Run pecl to install xdebug :运行pecl安装xdebug

sudo pecl install xdebug

At the end of the installation, you may see this output:在安装结束时,您可能会看到以下输出:

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

Open your php.ini file, add the zend_exntension line at the very bottom (skip if pecl was able to place it already):打开你的 php.ini 文件,在最底部添加 zend_exntension 行(如果 pecl 已经能够放置它,请跳过):

sudo vim /etc/php/7.3/apache2/php.ini // again replace 7.3 with your version

Finally, restart your webserver, or PHP-FPM, depending on what you are using.最后,根据您使用的内容,重新启动您的网络服务器或 PHP-FPM。

请禁用 ppa/php 并运行sudo apt install php-xdebug

Update for php 7.4.8: In the Xdebug configuration file php 7.4.8 更新:在 Xdebug 配置文件中

/etc/php/7.4/mods-available/xdebug.ini

I had to add the line:我不得不添加这一行:

xdebug.force_display_errors = 1

As Xdebug wouldn't work instead.因为 Xdebug 将无法正常工作。

Install xdebug with the following command: 使用以下命令安装xdebug

sudo apt install php-xdebug

and configure it as: 并将其配置为:

sudo nano /etc/php/7.0/mods-available/xdebug.ini

Add the following code into it: 将以下代码添加到其中:

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 

and then restart the services: 然后重新启动服务:

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

I use the following method and it works retrieve content from php info 我使用以下方法,并且可以从php信息中检索内容

$ php -i> info.txt

copy all the text in the info.txt file then enter the xdebug installation wizard and follow the ranks available there. 复制info.txt文件中的所有文本,然后进入xdebug 安装向导并按照那里可用的等级进行操作。

will look like this 看起来像这样

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM