Smbclient is not installed

Hi all!

Im a newbee in Linux but learned a lot with googling my answers. NextCloud is running really well but I can’t get my NC to connect to a samba share. I installed on a clean server with ContOS 7, Direct Admin, Apache & PHP 7.2. smbclient is installed but i’m not sure I need to do some extra configuring.

I tried to install php-smbclient but yum install php-smbclient gives a “No package php-smbclient available.” Is there anyone who can help me in the right direction?

Many thanks in advance!

Make sure that you’re installing and configuring the right package for the right PHP version. You will find many reports on this forum where users have installed a package for e.g. PHP 7.0 and wondering why it couldn’t be loaded using PHP 7.2. Please use the search function to find related postings.

Thanks for your quick reply! Will check that again.

Just for me to learn a bit more…
If I get the PHP version with:

php-v

it gives:
PHP 7.2.29 (cli) (built: Mar 23 2020 16:40:03) ( NTS )

Then i assume i need https://centos.pkgs.org/7/remi-testing-x86_64/php72-php-smbclient-0.9.0-2.el7.remi.x86_64.rpm.html for php-smbclient?

Please keep in mind, that you need to check the PHP web and cli component. Best would be to keep the both versions in sync. You can check the loaded modules for the PHP cli component executing php -m, for the PHP web component you have to create a php file which contains <?php phpinfo() ?>and load it using a browser.

Ok, im trying to folow you. Do you mean I have to check if the components of PHP web and the PHP CLI components are the same? In that case, yes they are. But on both i don’t see smbclient. Only in the webpage I see smb and smbs as a protocol under Curl.

Ok, you have to make sure that the smbclient module is correctly activated to be loaded.

https://www.google.com/search?q=php+smbclient+install

Thnx for your help so far!

I tried to install smbclient with help of a lot tutorials but none of them work in my situation. I get stranded every time. Tried it with info from https://github.com/eduardok/libsmbclient-php but (one of the search results from your google link):

pecl install pecl_http --> pecl: command not found

RPM for Fedora / RHEL / CentOS: php-smbclient --> 0 results

cd libsmbclient-php ; phpize --> phpize: command not found

I definitely lost track (or haven’t even found the right Linux track yet)

Just to be clear, you are running the “manual” installation of NC (unzipped into web folder), not the Docker or snap packages, correct?

Yes, that’s correct

Ok, took me another day of trying and learning… But still no luck.

Now I do understand there is a difference between PHP web and CLI components.

Samba is working but i just cant get it installed in PHP. Also I noticed i have kind of the same problem with OPcache. It is working, but not in PHP.

Anyone who can guide me in the right direction?

I think you meant “CentOS”, therefore you should search for it:

I had this very same problem and this is what I did to solve it.

Firstly my server is running CentOS Linux release 7.6.1810 (Core)
I’m using Nextcloud 18.03
PHP 7.2w
and Nginx as the webserver

Now if you don’t already have it you’ll need the gcc compiler -
yum install gcc -y

Next you need to use pecl to install the smbclient
pecl install smbclient

Once this compiles correctly it will tell you to add in the extensions=smbclient.so in your php.ini file

For me this file was located in /etc/php.ini

Open up this file and find the section for extensions and add in a new line -
extensions=smbclient.so

Restart php and nginx -
systemctl restart php-fpm
systemctl restart nginx

Now after that you should be able to add an SMB/CIFS share.

If your planning to have the permissions set in windows take effect for different users on the share you need to enable the LDAP Users and Groups Backend app in nextcloud (yum install php72w-ldap) and when creating your SMB/CIFS share globally in Nextcloud make sure you set the authentication to “Login Credentials, Save in Session”. That way when a user logs in and clicks into the share they will only be granted the permissions that the Windows file server allows. This works best with Access Based Enumeration enabled on the Windows File Share.

Hope this helps someone else. I’ve been at this for about 2 weeks and only just figured it out yesterday. Been working perfectly for me since.

I’ve over a 1000 very happy users now. :slight_smile:

2 Likes

Thanks so much! Just a small add for those who use CentOS 8 and PHP7.3:

Add a file named smbclient.ini to /etc/php.d containing one line:

extension="smbclient.so"

After restart php and nginx it works really smooth.

Glad I could help

Did you get collaboration working ?
My users can access the SMB share in Nextcloud, but instant collaboration is impossible (through NextCloud Text, OnlyOffice…) as the file changes are not propagated.
Sharing the folders could help but that would bypass the existing SMB share file permissions…

Yeah working perfectly.

Have you installed the Community Document Server and Only Office? You need both to enable Collaborative Document Editing.

I found that I wasn’t able to install the Community Document Server via the GUI as it’s a very large install and PHP or Nginx was timing out. I had to install it using the OCC CLI.

Well that baffles me… OnlyOffice and Document Server are installed and collaboration is only working from local Nextcloud storage, not from SMB.
I installed everything through UCS (Univention), which uses Docker.

Even worse, the only way for me to be able to open a document with OnlyOffice from the SMB share is to set the authentication to « save in database » and not « save in session » (or else I get an error from OnlyOffice that cannot load the document, I guess because it doesn’t have access to the credentials).