39

We have VPS with CentOS. I have installed SOAp using the following command:

$ yum install php-soap

Then I went to the php.ini file to uncomment the SOAP extension. It was not there, so I added the following line:

extension=soap.so

Then I restarted the server by running

$ service httpd restart

But SOAP is still not enabled. I get the Fatal error: Class 'SoapClient' message.

If I try to install it again, I get following message:

Package php-soap-5.3.3-27.el6_5.x86_64 already installed and latest version

I tried to reconfigure PHP with following command as well:

$ php-config '--disable-fileinfo' '--disable-pdo' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-libxml' '--enable-sockets' '--prefix=/usr/local' '--with-apxs2=/usr/local/apache/bin/apxs' '--with-curl=/opt/curlssl/' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-kerberos' '--with-libdir=lib64' '--with-libxml-dir=/opt/xml2/' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-openssl=/usr' '--with-openssl-dir=/usr' '--with-pcre-regex=/opt/pcre' '--with-pic' '--with-zlib' '--with-zlib-dir=/usr' '--enable-soap'

Any help?

ib.
  • 27,830
  • 11
  • 80
  • 100
user3241013
  • 409
  • 1
  • 4
  • 6
  • I also had to restart my FastCGI service. Because I'm using nginx, the relevant command was `sudo systemctl restart php-fpm` – Heath Raftery Jul 18 '18 at 21:29

5 Answers5

49

For my point of view, First thing is to install soap into Centos

yum install php-soap


Second, see if the soap package exist or not

yum search php-soap

third, thus you must see some result of soap package you installed, now type a command in your terminal in the root folder for searching the location of soap for specific path

find -name soap.so

fourth, you will see the exact path where its installed/located, simply copy the path and find the php.ini to add the extension path,

usually the path of php.ini file in centos 6 is in

/etc/php.ini

fifth, add a line of code from below into php.ini file

extension='/usr/lib/php/modules/soap.so'

and then save the file and exit.

sixth run apache restart command in Centos. I think there is two command that can restart your apache ( whichever is easier for you )

service httpd restart

OR

apachectl restart

Lastly, check phpinfo() output in browser, you should see SOAP section where SOAP CLIENT, SOAP SERVER etc are listed and shown Enabled.

Anil Prz
  • 1,099
  • 10
  • 14
  • 6
    In recent versions of CentOS, the PHP config for extensions is in /etc/php.d, with a separate .ini file for each extension. But in my case, after I ran yum install php-soap, all I had to do was restart Apache; the soap.ini file was already there. – Matt Browne Feb 03 '15 at 22:55
  • @Anil after run this command find -name soap.so in root folder i see this is soap path ./usr/lib64/php/modules/soap.so i set this line in my extension='./usr/lib64/php/modules/soap.so' /etc/php.ini file and restart httpd services in cent os 6. but still it couldn't enable soap service. any idea? – Maulik patel Apr 27 '16 at 07:06
  • @mattBrowne for me restarting apache didn't help I had to restart php-fpm service. – bhu1st Apr 09 '20 at 07:11
13

On CentOS 7, the following works:

yum install php-soap

This will automatically create a soap.ini under /etc/php.d.

The extension itself for me lives in /usr/lib64/php/modules. You can confirm your extension directory by doing:

php -i | grep extension_dir

Once this has been installed, you can simply restart Apache using the new service manager like so:

systemctl restart httpd

Thanks to Matt Browne for the info about /etc/php.d.

Evan Donovan
  • 748
  • 9
  • 18
  • 2
    I tried this. But I have an error trying to install php-soap so I searched and found this: [http://stackoverflow.com/questions/23919341/error-php55w-common-conflicts-with-php-common-on-centos-6-5](http://stackoverflow.com/questions/23919341/error-php55w-common-conflicts-with-php-common-on-centos-6-5) long story short. This solved my problem: `yum install php55w-soap` – Gabo Nov 03 '16 at 17:00
  • 1
    For a 2018 update - I had an `Error: php56w-common conflicts with ...` and so just modified the install command which @GaboLato mentioned with the number from my error: `yum install php56w-soap` and everything worked fine! – MrLewk May 10 '18 at 10:57
9

I installed php-soap to CentOS Linux release 7.1.1503 (Core) using following way.

1) yum install php-soap

================================================================================
 Package              Arch           Version                 Repository    Size
================================================================================
Installing:
 php-soap             x86_64         5.4.16-36.el7_1         base         157 k
Updating for dependencies:
 php                  x86_64         5.4.16-36.el7_1         base         1.4 M
 php-cli              x86_64         5.4.16-36.el7_1         base         2.7 M
 php-common           x86_64         5.4.16-36.el7_1         base         563 k
 php-devel            x86_64         5.4.16-36.el7_1         base         600 k
 php-gd               x86_64         5.4.16-36.el7_1         base         126 k
 php-mbstring         x86_64         5.4.16-36.el7_1         base         503 k
 php-mysql            x86_64         5.4.16-36.el7_1         base          99 k
 php-pdo              x86_64         5.4.16-36.el7_1         base          97 k
 php-xml              x86_64         5.4.16-36.el7_1         base         124 k

Transaction Summary
================================================================================
Install  1 Package
Upgrade             ( 9 Dependent packages)

Total download size: 6.3 M
Is this ok [y/d/N]: y
Downloading packages:
------
------
------

Installed:
  php-soap.x86_64 0:5.4.16-36.el7_1

Dependency Updated:
  php.x86_64 0:5.4.16-36.el7_1          php-cli.x86_64 0:5.4.16-36.el7_1
  php-common.x86_64 0:5.4.16-36.el7_1   php-devel.x86_64 0:5.4.16-36.el7_1
  php-gd.x86_64 0:5.4.16-36.el7_1       php-mbstring.x86_64 0:5.4.16-36.el7_1
  php-mysql.x86_64 0:5.4.16-36.el7_1    php-pdo.x86_64 0:5.4.16-36.el7_1
  php-xml.x86_64 0:5.4.16-36.el7_1

Complete!

2) yum search php-soap

============================ N/S matched: php-soap =============================
php-soap.x86_64 : A module for PHP applications that use the SOAP protocol

3) service httpd restart

To verify run following

4) php -m | grep -i soap

soap

Mukesh
  • 7,630
  • 21
  • 105
  • 159
  • after run this command `find -name soap.so` in root folder i see this is soap path `./usr/lib64/php/modules/soap.so` i set this line `extension='./usr/lib64/php/modules/soap.so'` `/etc/php.ini` file and restart httpd services in cent os 6. but still it couldn't enable soap service. any idea? – Maulik patel Apr 27 '16 at 13:55
  • I need a help.Will installing soap also upgrade other dependencies version ?? It is showing the same display as you described above. – Munish Chechi Jul 19 '17 at 14:43
  • 1
    @MunishChechi I don't think so, but may be for compatibility you might need to upgrade other dependencies. – Mukesh Jul 20 '17 at 06:07
5

The yum install php-soap command will install the Soap module for php 5.x

For installing the correct version for your environment I recommend to create a file info.php and put this code: <?php echo phpinfo(); ?>

In the header you'll see the version you're using:

enter image description here

Now that you know the correct version you can run this command: yum search php-soap

This command will return the avaliable versions:

php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php54-php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php55-php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php56-php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php70-php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php71-php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php72-php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php73-php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php74-php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
rh-php70-php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
rh-php71-php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
rh-php72-php-soap.x86_64 : A module for PHP applications that use the SOAP protocol

Now you just need to choose the correct module to your php version.

For this example, you should run this command php72-php-soap.x86_64

carmolim
  • 137
  • 2
  • 11
1

After hours of searching I think my problem was that command yum install php-soap installs the latest version of soap for the latest php version.

My php version was 7.027, but latest php version is 7.2 so I had to search for the right soap version and finaly found it HERE!

yum install rh-php70-php-soap

Now php -m | grep -i soap works, Output: soap

Do not forget to restart httpd service.

Ahmad Mobaraki
  • 7,426
  • 5
  • 48
  • 69