1, download file

1
wget https: //download .samba.org /pub/samba/stable/samba-4 .2.0. tar .gz

2,解压文件

1
tar  -xzvf samba-4.2.0. tar .gz

3,编译安装Samba

1
2
3
cd  samba-4.2.0
. /configure  --prefix= /usr/local/samba/
make ; make  install

4,编译过程及状态

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
* installing bin/ default /source4/utils/man/oLschema2ldif.1 as /usr/local/samba/share/man/man1/oLschema2ldif.1
 
* installing bin/ default /source4/torture/man/smbtorture.1 as /usr/local/samba/share/man/man1/smbtorture.1
 
* installing bin/ default /source4/torture/man/gentest.1 as /usr/local/samba/share/man/man1/gentest.1
 
* installing bin/ default /source4/torture/man/masktest.1 as /usr/local/samba/share/man/man1/masktest.1
 
* installing bin/ default /source4/torture/man/locktest.1 as /usr/local/samba/share/man/man1/locktest.1
 
* installing bin/ default /pidl/pidl.1 as /usr/local/samba/share/man/man1/pidl.1
 
* installing bin/ default /pidl/Parse::Pidl::Dump.3pm as /usr/local/samba/share/man/man3/Parse::Pidl::Dump.3pm
 
* installing bin/ default /pidl/Parse::Pidl::Wireshark::Conformance.3pm as /usr/local/samba/share/man/man3/Parse::Pidl::Wireshark::Conformance.3pm
 
* installing bin/ default /pidl/Parse::Pidl::Util.3pm as /usr/local/samba/share/man/man3/Parse::Pidl::Util.3pm
 
* installing bin/ default /pidl/Parse::Pidl::NDR.3pm as /usr/local/samba/share/man/man3/Parse::Pidl::NDR.3pm
 
* installing bin/ default /pidl/Parse::Pidl::Wireshark::NDR.3pm as /usr/local/samba/share/man/man3/Parse::Pidl::Wireshark::NDR.3pm
 
Waf: Leaving directory `/opt/samba-4.2.0/bin'
 
'install'  finished successfully (22.193s)

5,动态加载Samba 库文件

1
2
3
4
5
6
7
8
9
[root@localhost samba] # cat /etc/ld.so.conf
 
include ld.so.conf.d/*.conf
 
/usr/local/openssl/lib
 
/usr/local/samba/lib
 
[root@localhost samba] # ldconfig

6,samba 服务配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
[global]
workgroup = MYGROUP
server string = Samba Server Version % v
log  file  /var/log/samba/log .%m
max log size = 50
security = user
map to guest = Bad Password
passdb backend = tdbsam
load printers =  yes
cups options = raw
[homes]
comment = Home Directories
browseable = no
writable =  yes
[printers]
comment = All Printers
path =  /var/spool/samba
browseable = no
guest ok = no
writable = no
printable =  yes
[ris]
path= /data/tftpboot
browsable= true
read  only= yes
writable= yes
guest ok= yes
[win2k8_x64_r2_en]
path= /data/tftpboot/win2k8_x64_r2_en
browsable= true
read  only= yes
writable= yes
guest ok= yes
[win2k8_x64_r2_cn]
path= /data/tftpboot/win2k8_x64_r2_cn
browsable= true
read  only= yes
writable= yes
guest ok= yes

7,启动相关服务

1
2
3
4
5
在启动服务之前需要添加smb.conf 软连接
  [root@localhost samba] # ln -s /usr/local/samba/etc/smb.conf  /usr/local/samba/lib/smb.conf
[root@localhost etc] # /usr/local/samba/sbin/smbd -D
 
[root@localhost etc] # /usr/local/samba/sbin/nmbd -D

8, FAQ

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Samba 文件语法检查
[root@localhost bin] # ./te Load smb config files from /usr/local/samba/etc/smb.conf
 
WARNING: Ignoring invalid value  'share'  for  parameter  'security'
 
Error loading services.
 
[root@localhost bin] #  
 
解决办法:
# ----------------------- Standalone Server Options ------------------------
#
# Scurity can be set to user, share(deprecated) or server(deprecated)
#
# Backend to store user information in. New installations should 
# use either tdbsam or ldapsam. smbpasswd is available for backwards 
# compatibility. tdbsam requires no further configuration.
         #security = share
         security = user
         map to guest = Bad Password
         passdb backend = tdbsam
 
在samba 4.2.0 版本之后不再兼容3.0 的版本, 该参数无法兼容security=share ,改成以下配置即可完成!
1
2
3
4
5
6
7
8
9
10
11
2, Python 库依赖报错
     Checking  for  Python version >= 2.5.0                                              : ok 2.6.6 
Checking  for  library python2.6                                                    : not found 
Checking  for  library python2.6                                                    : not found 
Checking  for  library python26                                                     : not found 
Checking  for  program python2.6-config                                             : not found 
Checking  for  program python-config-2.6                                            : not found 
Checking  for  custom code                                                          : Could not  find  the python development headers 
/opt/samba-4 .2.0 /wscript :107: error: the configuration failed (see  '/opt/samba-4.2.0/bin/config.log' )
 
yum -y  install  python-devel
1
2
3
4
5
6
3, gnutls 库版本问题
Checking  for  com_right_r                                                                        : ok 
Checking  for  gnutls >= 1.4.0 and broken versions                                                : not found 
/opt/samba-4 .2.0 /source4/lib/tls/wscript :30: error: Building the AD DC requires GnuTLS (eg libgnutls-dev, gnutls-devel)  for  ldaps: //  support and  for  the BackupKey protocol
 
yum -y  install  gnutls*
1
2
4,如遇到其他各种依赖库文件,放大招
     yum groupinstall  "Development Tools"  "Development Libraries"
1
2
3
4
5
6
7
8
9
10
11
5,acl 库依赖
building on linux2
Checking  for  library acl                                                                        : not found 
Checking  for  acl_get_file                                                                       : not found 
Checking  for  POSIX ACL support                                                                  : not found 
Checking  for  library sec                                                                        : not found 
Checking  for  facl                                                                               : not found 
Checking  for  library pacl                                                                       : not found 
Checking  for  acl_get_fd                                                                         : not found 
/opt/samba-4 .2.0 /source3/wscript :481: error: ACL support not found. Try installing libacl1-dev or libacl-devel.  Otherwise, use --without-acl-support to build without ACL support. ACL support is required to change permissions from Windows clients.
yum -y  install  nfs4-acl-tools libacl-devel acl libacl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
6,  LDAP support not found 解决
hecking  for  endnetgrent prototype                                                              : ok 
Checking  for  program cups-config                                                                : not found 
Checking  for  header cups /cups .h                                                                 : no 
Checking  for  header cups /language .h                                                             : no 
Checking  for  library cups                                                                       : not found 
Checking  for  httpConnect                                                                        : not found 
Checking  for  httpConnectEncrypt                                                                 : not found 
-- enable -iprint= yes  but cups support not sufficient
Checking  for  header ldap.h                                                                      : no 
Checking  for  header lber.h                                                                      : no 
Checking  for  header ldap_pvt.h                                                                  : no 
Checking  for  ber_tag_t                                                                          : not found 
Checking  for  library lber                                                                       : not found 
Checking  for  ber_scanf                                                                          : not found 
Checking  for  ber_sockbuf_add_io                                                                 : not found 
Checking  for  variable LDAP_OPT_SOCKBUF                                                          : not found 
Checking  for  variable LBER_OPT_LOG_PRINT_FN                                                     : not found 
Checking  for  library ldap                                                                       : not found 
Checking  for  ldap_init                                                                          : not found 
Checking  for  ldap_init_fd                                                                       : not found 
Checking  for  ldap_initialize                                                                    : not found 
Checking  for  ldap_set_rebind_proc                                                               : not found 
Checking  for  library ldap                                                                       : not found 
Checking  for  ldap_add_result_entry                                                              : not found 
Checking whether ldap_set_rebind_proc takes 3 arguments                                         : ok 
/opt/samba-4 .2.0 /source3/wscript :685: error: LDAP support not found. Try installing libldap2-dev or openldap-devel. Otherwise, use --without-ldap to build without LDAP support. LDAP support is required  for  the LDAP passdb backend, LDAP idmap backends and ADS. ADS support improves communication with Active Directory domain controllers.
 
yum -y  install  compat-openldap apr-util-ldap openldap-devel python-ldap openldap

9,再次检查

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  bin] # ./testparm 
 
Load smb config files from  /usr/local/samba/etc/smb .conf
 
Processing section  "[homes]"
 
Processing section  "[printers]"
 
Processing section  "[ris]"
 
Processing section  "[win2k8_x64_r2_en]"
 
Processing section  "[win2k8_x64_r2_cn]"
 
Loaded services  file  OK.

10,配置完成