Skip to content

497025126/Tiny-Web-Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1、准备工作

进入httpdocs,给.html.cgi文件权限

xm@xmServer:~/WebServer$ cd httpdocs/
xm@xmServer:~/WebServer/httpdocs$ sudo chmod 600 test.html 
[sudo] password for xm: 
xm@xmServer:~/WebServer/httpdocs$ sudo chmod 600 post.html 
xm@xmServer:~/WebServer/httpdocs$ sudo chmod +X post.cgi 

回到根目录,make,然后运行编译好的可执行文件开启服务,./myhttp

xm@xmServer:~/WebServer/httpdocs$ cd ..
xm@xmServer:~/WebServer$ ls
httpd.c  httpdocs  image  Makefile  README.md
xm@xmServer:~/WebServer$ make
gcc -W -Wall -o myhttp httpd.c -lpthread
xm@xmServer:~/WebServer$ ls
httpd.c  httpdocs  image  Makefile  myhttp  README.md
xm@xmServer:~/WebServer$ ./myhttp 

2、文件目录及操作过程

httpdocs中的test.html,在访问默认路径时会跳转过来,如下图: 1625573718446

请求post.html如下: 1625573695578

点击提交后,会向服务器请求post.cgi页面,服务器接到请求,解析报文之后,调用execute_cgi文件处理接收到的数据,在post.cgi脚本中把接收到的数据拼接起来,最后html给浏览器显示。 1625575501859

3、整体框架图

4、参考

参考阿秀的项目:https://github.com/forthespada/MyPoorWebServer

About

学习Linux多线程服务器编程

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published