PHP致命错误:未捕获的错误:找不到类'SoapClient'

时间:2019-01-19 06:36:50

标签: php soap soap-client fatal-error ubuntu-18.04

我正在尝试在Ubuntu 18.04.1 LTS VirtualBox服务器上启用SoapClient。
看到我的Soap应用程序因500 HTTP错误而失败后,我参考了php错误日志并找到了以下几行:

>PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_soap.dll' - /usr/lib/php/20151012/php_soap.dll: cannot open shared object file: No such file or directory in Unknown on line 0 

>[Sat Jan 19 10:00:46.349246 2019] [:error] [pid 4211] [client 192.168.2.52:55730] PHP Fatal error:  Uncaught Error: Class 'SoapClient' not found in /var/www/html/sample.php:36\nStack trace:\n#0 {main}\n  thrown in /var/www/html/sample.php on line 36

我已经尝试关注this和其他几个人,这是我注意到的:

phpinfo();中,我的系统使用php7.0,但是没有php7.0-soap软件包

 $ sudo apt-get install php7.0-soap  
Reading package lists... Done  
Building dependency tree  
Reading state information... Done  
E: Unable to locate package php7.0-soap  
E: Couldn't find any package by glob 'php7.0-soap'  
E: Couldn't find any package by regex 'php7.0-soap'  

因此,我安装了php7.2-soap。
我究竟做错了什么?请帮忙!

2 个答案:

答案 0 :(得分:0)

首先请确保您已安装php 7, 输入并运行sudo apt list php7* 否则,您可以运行sudo apt list php*

您的结果应该是这样的:

php7.1-mapi/bionic,bionic 8.5.5-0ubuntu1 all
php7.2/bionic-updates,bionic-updates,bionic-security,bionic-security,now 7.2.10-0ubuntu0.18.04.1 all [installed,automatic]
php7.2-bcmath/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
php7.2-bz2/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
php7.2-cgi/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-cli/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
php7.2-common/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed]
php7.2-curl/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
php7.2-dba/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-dev/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
php7.2-enchant/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-fpm/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-gd/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
php7.2-gmp/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-imap/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
php7.2-interbase/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-intl/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
php7.2-json/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
php7.2-ldap/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-mbstring/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
php7.2-mysql/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
php7.2-odbc/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-opcache/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
php7.2-pgsql/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-phpdbg/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-pspell/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-readline/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
php7.2-recode/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-snmp/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-soap/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
php7.2-sqlite3/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-sybase/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-tidy/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-xml/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
php7.2-xmlrpc/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
php7.2-xsl/bionic-updates,bionic-updates,bionic-security,bionic-security 7.2.10-0ubuntu0.18.04.1 all
php7.2-zip/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]

这将向您显示所有php7软件包。然后找到您的soap软件包并安装它。 在我的情况下,该软件包为php7.2-soap,因此我将使用

进行安装
sudo apt install php7.2-soap

答案 1 :(得分:0)

好吧,经过大量的试验和研究,这是我解决的方法:

sudo a2dismod php7.0
sudo a2enmod php7.2
sudo systemctl restart apache2

基本上,问题是我的系统具有两个有效的PHP版本,并且已配置为使用旧版本,通过这些命令,您可以将PHP7.0(禁用模块)修改为PHP7.2