1, download file
wget https://download.samba.org/pub/samba/stable/samba-4.2.0.tar.gz
2,解压文件
tar -xzvf samba-4.2.0.tar.gz
3,编译安装Samba
cd samba-4.2.0./configure --prefix=/usr/local/samba/make;make install
4,编译过程及状态
* 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.3pmWaf: Leaving directory `/opt/samba-4.2.0/bin''install' finished successfully (22.193s)
5,动态加载Samba 库文件
[root@localhost samba]# cat /etc/ld.so.confinclude ld.so.conf.d/*.conf/usr/local/openssl/lib/usr/local/samba/lib[root@localhost samba]# ldconfig
6,samba 服务配置
[global]workgroup = MYGROUPserver string = Samba Server Version %vlog file = /var/log/samba/log.%mmax log size = 50security = usermap to guest = Bad Passwordpassdb backend = tdbsamload printers = yescups options = raw[homes]comment = Home Directoriesbrowseable = nowritable = yes[printers]comment = All Printerspath = /var/spool/sambabrowseable = noguest ok = nowritable = noprintable = yes[ris]path=/data/tftpbootbrowsable=trueread only=yeswritable=yesguest ok=yes[win2k8_x64_r2_en]path=/data/tftpboot/win2k8_x64_r2_enbrowsable=trueread only=yeswritable=yesguest ok=yes[win2k8_x64_r2_cn]path=/data/tftpboot/win2k8_x64_r2_cnbrowsable=trueread only=yeswritable=yesguest ok=yes
7,启动相关服务
在启动服务之前需要添加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
Samba 文件语法检查[root@localhost bin]# ./te Load smb config files from /usr/local/samba/etc/smb.confWARNING: 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 ,改成以下配置即可完成!
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
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 protocolyum -y install gnutls*
4,如遇到其他各种依赖库文件,放大招 yum groupinstall "Development Tools" "Development Libraries"
5,acl 库依赖building on linux2Checking 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
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 sufficientChecking 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,再次检查
bin]# ./testparm Load smb config files from /usr/local/samba/etc/smb.confProcessing 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,配置完成