linux实训第一天--Centos7基础配置(ip,本地yum源,yum安装httpd,配置虚拟主机)
案例一
1.0配置ip为192.168.147.20/24
1.1配置Yum
1.2设置主机名为svr.tedu.cn
1.3安装httpd软件
案例1.0-->配置IP
[[email protected] ~]#nmcli connection modify ens33 ipv4.method manual ipv4.addresses
192.168.147.2.20/24 connection.autoconnect yes ##红色为网卡名,蓝色为ip地址。根据实际情况修改
[[email protected] ~]#nmcli connection up ens33 ##启动网卡
注意:有的可能不是ens33 这时可以ifconfig进行查看即可
##出现seccessfuly即可
案例1.1-->配置本地yum
[[email protected] ~]#mkdir /mnt/cdrom
[[email protected] ~]#mount /dev/cdrom /mnt/cdrom //挂载光盘
[[email protected] ~]#rm -rf /etc/yum.repos.d/*.repo
[[email protected] ~]#vim /etc/yum.repos.d/Redhat.repo !!注意一点是以”.repo”结尾
[Redhat] //仓库标识
name=This is Rehat.iso //描述信息
baseurl=/mnt/cdrom //路径
enabled=1 //开机自启动
gpgcheck=0 //是否检测信息
[[email protected] ~]yum repolist
案例1.3-->设置主机名
[[email protected] ~]#echo svr7.tedu.cn > /etc/hostname //永久配置
案例1.4-->下载httpd软件包
[[email protected] ~]#yum -y install httpd
- 案例二-->yum软件包以及趣玩额外rpm
下载tools.tar.gz
boxes格式:
[[email protected]~]#echo “This is a test ” | boxes -d “dog”
Oneko格式:
[[email protected]~]#oneko -fg green -speed 10
sl格式:
[[email protected]~]#sl
- 案例三-->搭建httpd服务
[[email protected] ~]#yum -y install httpd
[[email protected] ~]#echo test > /var/www/html/index.html
[[email protected] ~]#systemctl restart httpd
[[email protected] ~]#firefox http://127.0.0.1
- 案例四:搭建基于域名的web主机
[[email protected] ~]#vim /etc/hosts //设置映射ip
127.0.0.1 www.a.com
127.0.0.1 www.b.com
[[email protected] ~]#vim /etc/httpd/conf.d/httpd.conf
<VirtualHost *:80> //*指ip,80为端口
ServerName www.a.com //域名
DmentRoot /var/www/html //网页目录文件
</VirtualHost>
<VirtualHost *:80>
ServerName www.b.com
DmentRoot /var/www/private
</VirtualHost>
[[email protected] ~]#mkdir /var/www/private | echo private1 > /var/www/html/index.html
[[email protected] ~]#echo html1 > /var/www/html/index.html
[[email protected] ~]#systemctl restart httpd
[[email protected] ~]#firefox www.a.com
[[email protected] ~]#firefox www.b.com
补充:
常见的linux目录的作用
/ linux系统的开始
/etc 配置文件
/boot 引导文件
/var 容易变化的文件
##考虑是否装图形界面时,注意在此时的配置。GUI则是带图形界面的操作系统。