Linux web服务:
apache
nginx
python:
django
flask
webpy
java:
jetty
windows:
IIS
浏览器---地址栏-----主机名(域名)
----->dns
IP<----dns
REQUEST----->IP
RESPONSE<---IP
www.baidu.com
--->dns
->>>>>>IP---->request<------->response
HTTP:
超文本传输协议
HTTP:1.1
HTML:超文本标记语言
<html><h1></h1></html>
B/S-------->浏览器/服务端
C/S-------->客户端/服务端
URI:为了识别在全球上不同的文件的一种方式,同一资源标识符
统一:路径格式上的统一
子对象:URL:统一资源定位符专门用于互联网资源标识
protocol://HOST:port/path/to/file
http://www.uplooking.com:80/download/1.jpg
WEB:
状态代码:
1XX:纯信息
2XX:成功类
3XX:重定向
4XX:客户端错误
5XX:服务端错误
WEB服务器的主要操作:
1.建立链接:接受或拒绝客户端请求
2.接收请求:通过网络读取HTTP请求
3.处理请求:
4.访问资源
5.构建响应
6.发送响应
7.记录日志
linux---->apache:
软件:httpd
http://httpd.apache.org/
端口:
FTP:20/21
SMTP:25
SSH:22
WEB:80
一般来说1024以下的端口都是被标准组织定义的
可以去查看/etc/services端口定义
例子:
家目录:
SECTION 1
DocumetRoot "/path"--->存放网页代码(html)的路径
默认首页文件:
DirectoryIndex index.html index.html.var index.php
指定默认的首页文件
http://127.0.0.1/==========http://127.0.0.1/index.html
别名:
Alias /icons/ "/var/www/icons/"
<Directory "/var/www/icons">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
指定访问别名作用:隐藏真实访问路径,减少多级目录的情况
http://127.0.0.1/icons========http://127.0.0.1/var/www/icons
用户家目录访问:
<IfModule mod_userdir.c>
#UserDir disabled
UserDir public_html
</IfModule>
指定不同用户访问网站的不同家目录
http://127.0.0.1/~username
实际是访问username家目录下的public_html目录
虚拟主机:
基于域名虚拟主机
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html/ecshop
ServerName shop.up.com
ErrorLog logs/shop.up.com-error_log
CustomLog logs/shop.up.com-access_log common
</VirtualHost>
不同的域名得到不同网页家目录下的应用
基于端口虚拟主机
<VirtualHost *:81>
DocumentRoot /var/www/html/ecshop
ServerName localhost
ErrorLog logs/shop.up.com_port-error_log
CustomLog logs/shop.up.com_port-access_log common
</VirtualHost>
相同ip地址(域名)的不同端口得到不同的应用
安全:
限制ip访问
<Directory "/var/www/html">
Order allow,deny
Allow from 172.16.11.1/24
Allow from 172.16.11.0/24
</Directory>
用户名:密码
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride ALL
AuthType basic
AuthName "Auth....."
AuthUserFile /etc/httpd/.htaccess
require valid-user
#require username
#AuthGroupFile /etc/httpd/.htgroup
#require group myusers
Order allow,deny
Allow from all
</Directory>
htpasswd -c -m /etc/http/usepw username 第一次添加
htpasswd -m /etc/http/usepw username
目录属性:
Indexes列出文件,FollowSymLinks显示链接文件
扩展:
LAMP:linux,apache,Mysql,Php
LNMP:linux,nginx,Mysql,php
练习:
1.安装后直接重启使用默认网站
2.取消默认页面并且对主配置文件进行修改
3.修改默认首页文件
4.修改默认根目录
5.修改目录权限
用户名密码
限制ip
6.虚拟主机
基于域名
基于端口
7.建立用户以及个人空间目录
以下练习为扩展知识点
8.源码编译apache 指定安装目录
./configure --help
make
make install
9.支持ssl https