一、搭建web服务器
1.关闭firewall和selinux
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
停用selinux
setenforce 0
配置文件中让sellinux不再启动
vim /etc/selinux/config
SELINUX=permissive
2.编辑dns配置文件
vim /etc/resolv.conf
nameserver 114.114.114.114
3.下载安装阿里云镜像
安装wget
yum -y install wget
下载镜像
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
编辑yum配置文件
vim /etc/yum.repos.d/nginx.repo
[nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/amzn2/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true priority=9清除缓存
yum clean all
建立缓存
yum makecache
4.安装nginx
下载nginx
yum -y install nginx
找到nginx的资源文件,查看是否安装
rpm -qa|grep nginx
yum list installed |grep nginx
查看资源文件
rpm -ql nginx
直接启动nginx
检查服务是否启动
netstat -lnput|grep nginx
ps -aux|grep nginx
浏览器访问,出现下面页面
此时,我们的web服务器搭建完成!
5.远程访问
向web页面中添加图片和视频
上传图片和视频 到/usr/share/nginx/html/中
vim /usr/share/nginx/html/index.html
在本地物理主机上使用scp上传
scp -P22 111.png root@192.168.1.60
scp -P22 2.mp4 root@192.168.1.60
检查文件是否已经存在
[root@web-server html]# ls
111.png 2.mp4 50x.html index.html
浏览器输入地址访问,可以看到我们上传的图片和视频
但是,视频却是播放不了的
为此,我们只需要在访问时加上视频的名称,再去刷新,我们就能看到视频了!