当时第一次对着敲对指令理解不完全,总体感觉脑子很乱,所以这里整理一下
ftp的搭建操作
[usera@centos79 yum.repos.d]$ sudo -i
[sudo] usera 的密码: // 输入的密码不显示 Pwd@123.com
[root@centos79 ~] mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup//备份
[root@centos79yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo//使用阿里云镜像站
[root@centos79 ~]# yum install -y vsftpd
如果不行 rm -f /var/run/yum.pid
[root@centos79 ~]# yum install -y vsftpd
[root@centos79 ~]# systemctl start vsftpd
[root@centos79 ~]# systemctl status vsftpd//检查
[root@centos79 ~]# firewall-config // 打开防火墙配置项
打钩,勾选ftp
[root@centos79 ~]# cd /var/ftp
[root@centos79 ftp]# ls
pub
[root@centos79 ftp]# mkdir new
[root@centos79 ftp]# ls
new pub
到此为止,windows可以访问linux中的ftp服务器了。
[root@centos79 ftp]# cd new
[root@centos79 new]# ls
[root@centos79 new]# echo "123" > ./a.txt
[root@centos79 new]# cat a.txt
123
[root@centos79 new]#
在window中可以下载文件a.txt了
但是不能上传文件。
[root@centos79new]# cd /etc/vsftpd
[root@centos79vsftpd]# vim vsftpd.conf :set nu 29行 删除一个字符# anon_upload_enable=YES
i插入 shift+: 使用set nu shift+: 29 找到行 yy复制 p粘贴
先按键盘左上角的退出(Esc)键,然后在vim中输入:wq保存退出,如果想不保存退出,需要键入:q!
[root@centos79vsftpd]# systemctl restart vsftpd
[root@centos79vsftpd]# cd /var/ftp
[root@centos79ftp]# ll
[root@centos79ftp]# chmod o+w ./new
[root@centos79ftp]# ll
[root@centos79ftp]# setenforce 0
[root@centos79 new]# cd /etc/vsftpd
[root@centos79 vsftpd]# ls
[root@centos79 vsftpd]# vim vsftpd.conf
anon_mkdir_write_enable=YES 33
anon_other_write_enable=YES // 自己添加 34
[root@centos79 vsftpd]# systemctl restart vsftpd
anon_umask=022 添加一句,放在哪一行都行
[root@centos79 vsftpd]# systemctl restart vsftpd此电脑中ftp://ip进行验证,new文件里可实现删除复制
web的搭建操作
1.1. 安装httpd
[root@centos79 vsftpd]# yum install -y httpd
[root@centos79 vsftpd]# systemctl start httpd
[root@centos79 vsftpd]# systemctl status httpd
[root@centos79 ~]# firewall-config // http打个勾
此时应该可以从windows访问Linux中的web服务器
[root@centos79 ~]# cd /var/www/html
[root@centos79 html]# echo hello! Apache > index.html
//网站上输入ip地址查看
再次从windows访问Linux中的web服务器,看下主页是否发生变化。
1.2. 改配置文件,实现虚拟主机
[root@centos79 ~]# cd /etc/httpd/conf
[root@centos79 conf]# ls
httpd.conf magic
[root@centos79 conf]# cat httpd.conf
[root@centos79 conf]# vim /etc/httpd/conf/httpd.conf // 改配置文件
(:set nu :42)
#Listen 12.34.56.78:80
Listen 80
Listen 8055 //新加一行 42
<VirtualHost 自己虚拟机的ip:8055> //新加3行 114
DocumentRoot /var/www/html2
</VirtualHost>
#
# DocumentRoot: The directory out of whichyou will serve your
# documents. By default, all requests aretaken from this directory, but
# symbolic links and aliases may be used topoint to other locations.
#
DocumentRoot /var/www/html
(:wq)
[root@centos79 conf]# systemctl restart httpd
[root@centos79 conf]#
[root@centos79 conf]# firewall-config 处理8055端口,新加一个端口
[root@centos79 conf]# cd /var/www
[root@centos79 www]# mkdir html2
[root@centos79 www]# ls
cgi-bin html html2
[root@centos79 www]# cd html2
[root@centos79 html2]# echo "This ismy second website" > index.html
[root@centos79 html2]# ls
index.html
[root@centos79 html2]#
2. 修改ftp的配置文件,将默认路径更改到http服务的默认目录
[root@centos79 html2]# cd /etc/vsftpd
[root@centos79 vsftpd]# vim vsftpd.conf
添加一行(放哪里都可以,可以放在25行): anon_root=/var/www
[root@centos79 vsftpd]# systemctl restart vsftpd
[root@centos79vsftpd]# cd /var/www
[root@centos79 www]#ll
总用量 0
drwxr-xr-x. 2 rootroot 6 3月 24 22:58 cgi-bin
drwxr-xr-x. 2 rootroot 24 5月 25 16:55 html
drwxr-xr-x. 2 rootroot 24 5月 25 17:01 html2
[root@centos79 www]#chmod o+w ./html2
[root@centos79 www]#
//http:/ቦ.22.126.139:8055//使用自己虚拟机的ip
查看第二个网页