Blog

Blog

PHODAL

大学回想曲三——web开发

突然间让我想起了,首页中的description,一个有趣而又有意思的简介。

"Phodal's博客,个人博客用于软件开发心得分享及SEO优化学习,博客内容主要以计算机方面为主,Powered by Django and Python。狼和凤凰一起追逐龙,龙消失了。。。"

硬盘中有太多关于web开发的资料,以及一些开发过的CMS。在新的硬盘用满一年之际,换了一个固态硬盘,新的硬盘上面已经没有太多的东西。主要还是旧的,用了三年,还算是有些东西,淘一淘还真有不少的东西。如mongoose

Mongoose Web Server

Mongoose简介

Mongoose Web Server是一款易于使用的Web服务器,它可以嵌入到其它应用程序中,为其提供Web接口。

当然原文是这么介绍的。

Mongoose is the most easy to use web server on the planet. A web server of choice for Web developers (PHP, Ruby, Python, etc) and Web designers.

Mongoose is built on top of libmongoose embedded library, which can turn anything into a web server in 5 minutes worth of effort and few lines of code. Libmongoose is used to serve Web GUI on embedded devices, implement RESTful services, RPC frameworks (e.g. JSON-RPC), handle telemetry data exchange, and perform many other tasks in various different industries including aerospace, manufacturing, finance, research, automotive, gaming, IT.

Mongoose是建立在libmongoose嵌入式库之上的,它可以在5分钟内值得的努力和几行代码把任何东西到Web服务器。 Libmongoose是用来提供Web的GUI在嵌入式设备上,实现RESTful服务,RPC框架(如JSON-RPC),处理遥测数据交换,并在各个不同的行业,包括航空航天,制造业,金融,科研,汽车,游戏执行许多其他任务,IT。

简单的一个示例便是我们有需要在内网传一个文件,如某个目录下,那么我们只需要

  cd /path 
  mongoose

这样的话,便会建立一个简单的web服务器,别人也只需要访问你的IP:8080即可。如,192.168.1.1:8080。

当然他提供的版本有Linux、Windows以及Mac OS。记得以前我写东西的时候,都是只写Linux和Windows,现在又要加上Mac OS了。

Python

Python Web Server

当然我们也可以用python来解决上面的问题

  python -m SimpleHTTPServer

如果要加上端口号便是

 python -m SimpleHTTPServer 8080

Django

作为一直在用的框架,Django算是最好的,只是一直很少在后台玩,一直在前端开发。安装玩Django后,便是

   django-admin.py startproject project

去创建一个项目,总得来说没有Ruby On Rails来得方便,但是Rails的生成,总会让人觉得生成得越多,便越难改。只能说各有各的好处吧。

Python的web框架还有很多,如CherryPy,Tornado,web.py*。

CherryPy的hello,world便是

import cherrypy
class HelloWorld(object):
    def index(self):
        return "Hello World!"
    index.exposed = True

cherrypy.quickstart(HelloWorld())

Nginx header修改

1.看到知乎修改了自己的Server header,于是有一次也就修改了自己的。

  vim src/http/ngx_http_header_filter_module.c

默默地将其中的这一行

  static char ngx_http_server_string[] = "Server: nginx" CRLF;

改成了

 static char ngx_http_server_string[] = "Server: phodal" CRLF;

2.另外一个便是nginx.h

 vim src/core/nginx.h

修改

  #define NGINX_VERSION      "0.11"

  #define NGINX_VER          "phodal/" NGINX_VERSION

3.编译

./configure --user=www --group=www --add-module=../nginx-static-etags --add-module=../ngx_pagespeed-1.7.30.4-beta --add-module=../ngx_cache_purge --prefix=/usr/local/nginx --with-pcre --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6 --with-http_spdy_module --with-http_ssl_module

配置2

./configure --user=www --group=www --add-module=../nginx-static-etags --add-module=../ngx_pagespeed-1.8.31.4-beta --add-module=../ngx_cache_purge --prefix=/usr/local/nginx --with-pcre --with-http_spdy_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-ipv6

4.安装

make
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
cp objs/nginx /usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -t
make upgrade
echo "Upgrade completed!"
echo "Program will display Nginx Version......"

5.查看

/usr/local/nginx/sbin/nginx -v

于是

nginx version: phodal/0.11.0

原文大学回想曲三——web开发
这样我们就可以继续玩耍了~~

关于我

Github: @phodal     微博:@phodal     知乎:@phodal    

微信公众号(Phodal)

围观我的Github Idea墙, 也许,你会遇到心仪的项目

QQ技术交流群: 321689806
comment

Feeds

RSS / Atom

最近文章

关于作者

Phodal Huang

Engineer, Consultant, Writer, Designer

ThoughtWorks 技术专家

工程师 / 咨询师 / 作家 / 设计学徒

开源深度爱好者

出版有《前端架构:从入门到微前端》、《自己动手设计物联网》、《全栈应用开发:精益实践》

联系我: h@phodal.com

微信公众号: 最新技术分享

标签