Web服务器

http的请求方法

http通信中,每个http请求报文都包含一个方法,用以告诉web服务器需要执行的动作(获取指定的web页面,提交内容到服务器,删除服务器上的资源文件等)

状态码

1** : 指示信息 —— 请求已接收,继续处理

2** : 成功 —— 请求已被成功接收,理解

3** : 重定向 —— 要完成请求必须进行更进一步的操作

4** : 客户端错误 —— 请求有语法错误或请求无法实现

5** : 服务器端错误 —— 服务器未能实现合法的请求

http的报文

请求报文

WEB服务器的配置

服务器端:此处使用 nginx 提供 web 服务, RPM 包获取: http://nginx.org/packages/

[root@localhost ~]# dnf install nginx -y
[root@localhost ~]# nginx -v
[root@localhost ~]# nginx -V
[root@localhost ~]# rpm -ql nginx
[root@localhost httpd]# tree /etc/nginx
[root@localhost ~]# tree /etc/nginx/
/etc/nginx/
├── conf.d #子配置文件目录
├── default.d
├── fastcgi.conf
├── fastcgi.conf.default
├── fastcgi_params #用以翻译nginx的变量供php识别
├── fastcgi_params.default
├── koi-utf
├── koi-win
├── mime.types #用以配置支持的媒体文件类型
├── mime.types.default
├── nginx.conf #主配置文件
├── nginx.conf.default
├── scgi_params
├── scgi_params.default
├── uwsgi_params #用以配置nginx的变量供python识别
├── uwsgi_params.default
└── win-utf
[root@localhost ~]# tree /usr/share/nginx/html/ #默认的nginx网站根目录
[root@localhost ~]# tree /var/log/nginx/ #nginx的日志文件所在目录

 虚拟主机配置实战

1.搭建静态网站——基于http协议的静态网站

实验一、搭建一个web服务器,访问该服务器时显示“hello world”欢迎页面

 systemctl stop firewalld         #关闭防火墙
 setenforce  0        #设置selinux为允许
 echo hello world > /usr/share/nginx/html/index.html
 systemctl restart nginx         #重启nginx

实验二、建立一个基于10000端口访问的网站,设置网站首页目录为/www/port/10000

新建目录:mkdir -p /www/port/10000

写入文件:echo this is 10000 > /www/port/10000/index.html

编辑conf文件:vim /etc/nginx/conf.d/port.conf

**重启nginx进程:**systemctl restart nginx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值