centos7 环境搭建
centos7 环境搭建
CentOS-7-x86_64-DVD-1511.iso
vmware12
1. 安装
使用iso安装系统;
2. 修改yum源到光盘
先把光盘CentOS-7-x86_64-DVD-1511.iso挂到vmware上,
to.dir yum.repo.d
vi CentOs-Media.repo
{
看到这么一行: file:///media/cdrom
}
mkdir -p /media/cdrom
lsblk
{
看到 sr0 4G ,知道是光盘
}
3. centos 7 默认开始没有配置网络,需要先安装基础工具
yum --disablerepo=\* --enablerepo=c7-media -y install vim net-tools
然后service network restart
ifconfig看网卡的ip还没出来。
cp /etc/sysconfig/network-scripts/ifcfg-eno16777736 /etc/sysconfig/network-scripts/ifcfg-eno16777736
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eno16777736
++ HWADDR=00:0c:29:e1:dc:4f
TYPE=Ethernet
-+ BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=2b520f7d-5fbe-42c7-9a77-7d090a837aa6
DEVICE=eno16777736
-+ ONBOOT=yes
++ IPADDR0=192.168.2.109
++ PREFIXO0=24
++ GATEWAY0=192.168.2.1
++ DNS1=61.139.2.69
重启网络:
service network restart
或者systemctl restart network
GATEWAY0是路由器ip,设错了ping不通外网。
4. ssh远程登录ok,安装其他软件
yum --disablerepo=\* --enablerepo=c7-media -y install python ntp wget tree dos2unix
5. #关闭selinux和firewalld,配置网络
getenforce
setenforce 0
vi /etc/selinux/config
SELINUX=disabled
systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld
#重启network服务
systemctl restart network
6.使用阿里云repo
vi /etc/yum.repos.d/aliyun.repo
{
[base]
name=aliyun
baseurl=http://mirrors.aliyun.com/centos/7/os/x86_64/
enable=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
}
yum clean all
yum update
7.配置时区和时间同步
tzselect
yum install -y ntpdate
#和服务器的时间差不能超过1天
ntpdate -d lin01.example.local
vi /etc/crontab
00 */1 * * * root /usr/sbin/ntpdate lin01.example.local;/sbin/hwclock -w
#手动设置时间
date -s 11/16/2015
date -s 18:28:00
hwclock -w
8.安装net-tools,查看启动的服务和端口
yum install -y net-tools
netstat -ntupl
9.关机,重启,取消操作
shutdown -P
shutdown -r
shutdown -c
reboot
10.关机前把数据从buffer写到磁盘确保完整性
sync
==================================================================
从11开始是开发使用一些扩展工具
yum install wget
11. samba
(1) install
yum --disablerepo=\* --enablerepo=c7-media -y install samba samba-client samba-common
service smb start
设置开机自启动
# chkconfig --level 35 smb on
(2)save config file
[root@localhost ~]# cp /etc/samba/smb.conf /etc/samba/smb.conf.origin
(3)modify config file
[root@localhost ~]# vi /etc/samba/smb.conf
[global]
workgroup = WORKGROUP
netbios name = CentOS7
server string = Samba Server
security = user
encrypt passwords = yes
max connections = 0
security = user
smb passwd file = /etc/samba/smbpasswd
username map = /etc/samba/smbusers
[jz2440]
path = /root/jz2440
writable = yes
guest ok = yes
write list = @root
validusers = @root
display charset = UTF-8
unix charset = UTF-8
dos charset = cp936
(4)modify remote user name and passwd
[root@localhost ~]# touch /etc/samba/smbpasswd
[root@localhost ~]# smbpasswd -a root
(5) restart samba
[root@localhost ~]# service smb restart
(6) test samba on linux host
[root@localhost ~]# smbclient //127.0.0.1/jz2440
(7) some other command may be used
[root@localhost ~]# testparm ; 查看samba配置项
[root@localhost ~]# testparm -v -s | grep usershare ;查看samba详细的配置项, grep过滤字段.
[root@localhost ~]# systemctl stop firewalld.service ; 关闭防火墙
[root@localhost ~]# vi /etc/security/limits.conf ;设置用户可以同时打开的最大文件数, 等等等
[root@localhost ~]# ulimit -n 16384 ; 设置用户可以同时打开的最大文件数
#12. tftp
CentOS7 中TFTP配置 http://www.cnblogs.com/lion382/p/4266886.html
安装:
yum --disablerepo=\* --enablerepo=c7-media -y install tftp xinetd tftp-server
配置:
mkdir -p /root/jz2440/tftpboot
vi /etc/default/tftpd-hpa
{
server_args = -s /root/jz2440/tftpboot
}
启动:
service xinetd restart
13. nfs
Setting Up NFS Server And Client On CentOS 7
https://www.unixmen.com/setting-nfs-server-client-centos-7/
安装:
yum --disablerepo=\* --enablerepo=c7-media -y install nfs-utils
配置nfs:
mkdir -p /root/jz2440/nfs/fs_qtopia /root/jz2440/nfs/fs_mini_mdev
vi /etc/exports
{
/root/jz2440/nfs/fs_mini_mdev *(rw,sync,no_root_squash,no_subtree_check)
/root/jz2440/nfs/fs_qtopia *(rw,sync,no_root_squash,no_subtree_check)
}
启动nfs:
systemctl enable rpcbind
systemctl enable nfs-server
systemctl start rpcbind
systemctl start nfs-server
systemctl restart nfs.service
测试nfs:
{
showmount -e
mkdir /var/nfs_share
mount -t nfs 192.168.2.109:/root/jz2440/nfs /var/nfs_share
ls /var/nfs_share/
fs_mini_mdev fs_qtopia
}
#14. vsftpd
centos7下配置vsftpd虚拟用户教程 http://www.cnblogs.com/mylinux/p/5621942.html
Linux中FTP的使用 http://blog.163.com/fankb222@126/blog/static/7117402320124743024279/
cmds:
service vsftpd restart
chkconfig --level 35 vsftpd on
steps:
安装:
yum -y install libdb-utils vsftpd ftp
chkconfig --level 35 vsftpd on
准备:
创建ftp各个虚拟server账户的目录:
mkdir -p /ftpserverdir/ocj /ftpserverdir/hl
chown -R ftpadmin:ocean /ftpserverdir/
chmod 775 -R /ftpserverdir
创建实际的ftp主用户:
#/usr/sbin/useradd -d /ftpserverdir -s /sbin/nologin ftpadmin
#passwd ftpadmin
为ftpadmin添加组属性:
usermod -G ocean ftpadmin //usermod -G <group> <usr_account>
配置vsftpd:
{
cd /etc/vsftpd/
[root@localhost vsftpd]# vi /etc/vsftpd/chroot_list
ftpadmin
[root@localhost vsftpd]# vi /etc/vsftpd/vftpuser.txt
ocj
1
hl
1
[root@localhost vsftpd]# cat /etc/vsftpd/vuser_conf/ocj
local_root=/ftpserverdir/ocj
write_enable=YES
download_enable=YES
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
local_umask=022
listen_port=21
[root@localhost vsftpd]# cat /etc/vsftpd/vuser_conf/hl
local_root=/ftpserverdir/hl
write_enable=YES
download_enable=YES
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
local_umask=022
listen_port=21
[root@localhost vsftpd]# cat /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
chroot_local_user=YES
guest_enable=YES
guest_username=ftpadmin
virtual_use_local_privs=YES
chmod_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
chroot_list_enable=YES
user_config_dir=/etc/vsftpd/vuser_conf
allow_writeable_chroot=YES
}
配置好了之后:
setsebool ftpd_disable_trans 1 或 setsebool -P ftp_home_dir on 或 setsebool -P ftpd_disable_trans on
service vsftpd restart
abnormal:
ftp服务 500 OOPS:cannot change directory:/root
{
1、setsebool -P ftp_home_dir on 或 setsebool -P ftpd_disable_trans on
service vsftpd restart
2、关闭 selinux
修改/etc/selinux/config文件
设置SELINUX= disabled
}
vsftp 无法启动,500 OOPS: bad bool value in config file for: anonymous_enable
{
http://www.cnblogs.com/chen110xi/p/3717652.html
可能原因是配置文件格式不对
解决方法: 配置文件转码dos2unix /etc/vsftpd/vsftpd.conf
}
==================================================================
参考:
centos 7安装后初始化配置
http://www.aichengxu.com/view/10933283