1, download file
1
<code>wget https:</code><code>//download</code><code>.samba.org</code><code>/pub/samba/stable/samba-4</code><code>.2.0.</code><code>tar</code><code>.gz</code>
2,解压文件
<code>tar</code> <code>-xzvf samba-4.2.0.</code><code>tar</code><code>.gz</code>
3,编译安装Samba
2
3
<code>cd</code> <code>samba-4.2.0</code>
<code>.</code><code>/configure</code> <code>--prefix=</code><code>/usr/local/samba/</code>
<code>make</code><code>;</code><code>make</code> <code>install</code>
4,编译过程及状态
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<code>* installing bin/</code><code>default</code><code>/source4/utils/man/oLschema2ldif.1 as /usr/local/samba/share/man/man1/oLschema2ldif.1</code>
<code>* installing bin/</code><code>default</code><code>/source4/torture/man/smbtorture.1 as /usr/local/samba/share/man/man1/smbtorture.1</code>
<code>* installing bin/</code><code>default</code><code>/source4/torture/man/gentest.1 as /usr/local/samba/share/man/man1/gentest.1</code>
<code>* installing bin/</code><code>default</code><code>/source4/torture/man/masktest.1 as /usr/local/samba/share/man/man1/masktest.1</code>
<code>* installing bin/</code><code>default</code><code>/source4/torture/man/locktest.1 as /usr/local/samba/share/man/man1/locktest.1</code>
<code>* installing bin/</code><code>default</code><code>/pidl/pidl.1 as /usr/local/samba/share/man/man1/pidl.1</code>
<code>* installing bin/</code><code>default</code><code>/pidl/Parse::Pidl::Dump.3pm as /usr/local/samba/share/man/man3/Parse::Pidl::Dump.3pm</code>
<code>* installing bin/</code><code>default</code><code>/pidl/Parse::Pidl::Wireshark::Conformance.3pm as /usr/local/samba/share/man/man3/Parse::Pidl::Wireshark::Conformance.3pm</code>
<code>* installing bin/</code><code>default</code><code>/pidl/Parse::Pidl::Util.3pm as /usr/local/samba/share/man/man3/Parse::Pidl::Util.3pm</code>
<code>* installing bin/</code><code>default</code><code>/pidl/Parse::Pidl::NDR.3pm as /usr/local/samba/share/man/man3/Parse::Pidl::NDR.3pm</code>
<code>* installing bin/</code><code>default</code><code>/pidl/Parse::Pidl::Wireshark::NDR.3pm as /usr/local/samba/share/man/man3/Parse::Pidl::Wireshark::NDR.3pm</code>
<code>Waf: Leaving directory `/opt/samba-4.2.0/bin'</code>
<code>'install'</code> <code>finished successfully (22.193s)</code>
5,动态加载Samba 库文件
<code>[root@localhost samba]</code><code># cat /etc/ld.so.conf</code>
<code>include ld.so.conf.d/*.conf</code>
<code>/usr/local/openssl/lib</code>
<code>/usr/local/samba/lib</code>
<code>[root@localhost samba]</code><code># ldconfig</code>
6,samba 服务配置
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<code>[global]</code>
<code>workgroup = MYGROUP</code>
<code>server string = Samba Server Version %</code><code>v</code>
<code>log </code><code>file</code> <code>= </code><code>/var/log/samba/log</code><code>.%m</code>
<code>max log size = 50</code>
<code>security = user</code>
<code>map to guest = Bad Password</code>
<code>passdb backend = tdbsam</code>
<code>load printers = </code><code>yes</code>
<code>cups options = raw</code>
<code>[homes]</code>
<code>comment = Home Directories</code>
<code>browseable = no</code>
<code>writable = </code><code>yes</code>
<code>[printers]</code>
<code>comment = All Printers</code>
<code>path = </code><code>/var/spool/samba</code>
<code>guest ok = no</code>
<code>writable = no</code>
<code>printable = </code><code>yes</code>
<code>[ris]</code>
<code>path=</code><code>/data/tftpboot</code>
<code>browsable=</code><code>true</code>
<code>read</code> <code>only=</code><code>yes</code>
<code>writable=</code><code>yes</code>
<code>guest ok=</code><code>yes</code>
<code>[win2k8_x64_r2_en]</code>
<code>path=</code><code>/data/tftpboot/win2k8_x64_r2_en</code>
<code>[win2k8_x64_r2_cn]</code>
<code>path=</code><code>/data/tftpboot/win2k8_x64_r2_cn</code>
7,启动相关服务
<code>在启动服务之前需要添加smb.conf 软连接</code>
<code> </code><code>[root@localhost samba]</code><code># ln -s /usr/local/samba/etc/smb.conf /usr/local/samba/lib/smb.conf</code>
<code>[root@localhost etc]</code><code># /usr/local/samba/sbin/smbd -D</code>
<code>[root@localhost etc]</code><code># /usr/local/samba/sbin/nmbd -D</code>
8, FAQ
<code>Samba 文件语法检查</code>
<code>[root@localhost bin]</code><code># ./te Load smb config files from /usr/local/samba/etc/smb.conf</code>
<code>WARNING: Ignoring invalid value </code><code>'share'</code> <code>for</code> <code>parameter </code><code>'security'</code>
<code>Error loading services.</code>
<code>[root@localhost bin]</code><code># </code>
<code>解决办法:</code>
<code># ----------------------- Standalone Server Options ------------------------</code>
<code>#</code>
<code># Scurity can be set to user, share(deprecated) or server(deprecated)</code>
<code># Backend to store user information in. New installations should </code>
<code># use either tdbsam or ldapsam. smbpasswd is available for backwards </code>
<code># compatibility. tdbsam requires no further configuration.</code>
<code> </code><code>#security = share</code>
<code> </code><code>security = user</code>
<code> </code><code>map to guest = Bad Password</code>
<code> </code><code>passdb backend = tdbsam</code>
<code>在samba 4.2.0 版本之后不再兼容3.0 的版本, 该参数无法兼容security=share ,改成以下配置即可完成!</code>
<code>2, Python 库依赖报错</code>
<code> </code><code>Checking </code><code>for</code> <code>Python version >= 2.5.0 : ok 2.6.6 </code>
<code>Checking </code><code>for</code> <code>library python2.6 : not found </code>
<code>Checking </code><code>for</code> <code>library python26 : not found </code>
<code>Checking </code><code>for</code> <code>program python2.6-config : not found </code>
<code>Checking </code><code>for</code> <code>program python-config-2.6 : not found </code>
<code>Checking </code><code>for</code> <code>custom code : Could not </code><code>find</code> <code>the python development headers </code>
<code>/opt/samba-4</code><code>.2.0</code><code>/wscript</code><code>:107: error: the configuration failed (see </code><code>'/opt/samba-4.2.0/bin/config.log'</code><code>)</code>
<code>yum -y </code><code>install</code> <code>python-devel</code>
<code>3, gnutls 库版本问题</code>
<code>Checking </code><code>for</code> <code>com_right_r : ok </code>
<code>Checking </code><code>for</code> <code>gnutls >= 1.4.0 and broken versions : not found </code>
<code>/opt/samba-4</code><code>.2.0</code><code>/source4/lib/tls/wscript</code><code>:30: error: Building the AD DC requires GnuTLS (eg libgnutls-dev, gnutls-devel) </code><code>for</code> <code>ldaps:</code><code>//</code> <code>support and </code><code>for</code> <code>the BackupKey protocol</code>
<code>yum -y </code><code>install</code> <code>gnutls*</code>
<code>4,如遇到其他各种依赖库文件,放大招</code>
<code> </code><code>yum groupinstall </code><code>"Development Tools"</code> <code>"Development Libraries"</code>
<code>5,acl 库依赖</code>
<code>building on linux2</code>
<code>Checking </code><code>for</code> <code>library acl : not found </code>
<code>Checking </code><code>for</code> <code>acl_get_file : not found </code>
<code>Checking </code><code>for</code> <code>POSIX ACL support : not found </code>
<code>Checking </code><code>for</code> <code>library sec : not found </code>
<code>Checking </code><code>for</code> <code>facl : not found </code>
<code>Checking </code><code>for</code> <code>library pacl : not found </code>
<code>Checking </code><code>for</code> <code>acl_get_fd : not found </code>
<code>/opt/samba-4</code><code>.2.0</code><code>/source3/wscript</code><code>: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.</code>
<code>yum -y </code><code>install</code> <code>nfs4-acl-tools libacl-devel acl libacl</code>
<code>6, LDAP support not found 解决</code>
<code>hecking </code><code>for</code> <code>endnetgrent prototype : ok </code>
<code>Checking </code><code>for</code> <code>program cups-config : not found </code>
<code>Checking </code><code>for</code> <code>header cups</code><code>/cups</code><code>.h : no </code>
<code>Checking </code><code>for</code> <code>header cups</code><code>/language</code><code>.h : no </code>
<code>Checking </code><code>for</code> <code>library cups : not found </code>
<code>Checking </code><code>for</code> <code>httpConnect : not found </code>
<code>Checking </code><code>for</code> <code>httpConnectEncrypt : not found </code>
<code>--</code><code>enable</code><code>-iprint=</code><code>yes</code> <code>but cups support not sufficient</code>
<code>Checking </code><code>for</code> <code>header ldap.h : no </code>
<code>Checking </code><code>for</code> <code>header lber.h : no </code>
<code>Checking </code><code>for</code> <code>header ldap_pvt.h : no </code>
<code>Checking </code><code>for</code> <code>ber_tag_t : not found </code>
<code>Checking </code><code>for</code> <code>library lber : not found </code>
<code>Checking </code><code>for</code> <code>ber_scanf : not found </code>
<code>Checking </code><code>for</code> <code>ber_sockbuf_add_io : not found </code>
<code>Checking </code><code>for</code> <code>variable LDAP_OPT_SOCKBUF : not found </code>
<code>Checking </code><code>for</code> <code>variable LBER_OPT_LOG_PRINT_FN : not found </code>
<code>Checking </code><code>for</code> <code>library ldap : not found </code>
<code>Checking </code><code>for</code> <code>ldap_init : not found </code>
<code>Checking </code><code>for</code> <code>ldap_init_fd : not found </code>
<code>Checking </code><code>for</code> <code>ldap_initialize : not found </code>
<code>Checking </code><code>for</code> <code>ldap_set_rebind_proc : not found </code>
<code>Checking </code><code>for</code> <code>ldap_add_result_entry : not found </code>
<code>Checking whether ldap_set_rebind_proc takes 3 arguments : ok </code>
<code>/opt/samba-4</code><code>.2.0</code><code>/source3/wscript</code><code>: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 </code><code>for</code> <code>the LDAP passdb backend, LDAP idmap backends and ADS. ADS support improves communication with Active Directory domain controllers.</code>
<code>yum -y </code><code>install</code> <code>compat-openldap apr-util-ldap openldap-devel python-ldap openldap</code>
9,再次检查
<code> </code><code>bin]</code><code># ./testparm </code>
<code>Load smb config files from </code><code>/usr/local/samba/etc/smb</code><code>.conf</code>
<code>Processing section </code><code>"[homes]"</code>
<code>Processing section </code><code>"[printers]"</code>
<code>Processing section </code><code>"[ris]"</code>
<code>Processing section </code><code>"[win2k8_x64_r2_en]"</code>
<code>Processing section </code><code>"[win2k8_x64_r2_cn]"</code>
<code>Loaded services </code><code>file</code> <code>OK.</code>
10,配置完成
本文转自 swq499809608 51CTO博客,原文链接:http://blog.51cto.com/swq499809608/1618584