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