更新版本的脚本


#!/bin/bash

# Used for publish new version.
# @auth: Fred.
# @date: 2016/06/26

set -e

if [ "$#" -ne 1 ]; then
echo "Deploy a new version of branch dscapi/develop_master."
echo "Usage: $0 DIRECTORY" >&2
echo ""
echo ""
exit 1
fi

TARGETDIR=$1

git clone -b develop_master git@git.local.ybzf.com:api_service/dscapi.git "$TARGETDIR"

rm connection
ln -s "$TARGETDIR" connection

cd connection
git branch
cd ..

Nginx支持二级目录

下面是一个server配置实例,支持/和/wordpress/俩个独立的网站。


server {
    listen       80 default_server;
    server_name   liungkejin.wang;

    # Default root and index.
    root   /var/www/monbook;
    index  index.php;

    location / {
        root   /var/www/monbook;
        index  index.php;

        if (!-e $request_filename) {
            rewrite ^/(.*)  /index.php last;
        }
    }

    location /wordpress/ {
        root   /var/www;
        index  index.php;

        # rewrite ^/wordpress/(.*)$ /wordpress/$1 break;

        location ~ \.php {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}


主要有两点需要关注:

  1. location代表匹配规则:匹配分两种:前缀式、正则式。按最长匹配原则,先匹配前缀式。然后,按定义的顺序匹配正则式。location可以嵌套。
  2. rewrite规则匹配到之后,会重新location匹配,不会超过10次。break flag,则表示不再location匹配;last flag,不再实行当前的序列。

也很好理解:首先,根据请求的URI匹配一个location,当location内定义的rewrite改变了uri,则需要重新匹配。

Flask框架初探

Python的Flask框架依赖于两个库:Jinja2和模板引擎和 Werkzeug WSGI 工具集。前者是html模板,用于生成html页面;后者提供WSGI的Server功能。WSGI教程参考这里

我们先看下Hello World程序

# -*- coding: utf-8 -*-
from flask import Flask
app = Flask(__name__)


@app.route("/")
def hello():
    return "Hello World! 欢迎,世界!"

if __name__ == "__main__":
    app.run()

注意看第6行,这一句是先生成装饰器函数,再在加载main定义hello函数的时候调用装饰器函数。此时,会向Flask对象注册url和url处理函数之间的映射关系(路由)。

在Flask框架里,Flask类代表了app,Werkzeug包提供了server的支持。网站服务端实际上就是处理HTTP请求,并给予响应。而server则是仅仅处理分发和响应,不处理应用逻辑。所有的应用逻辑都交给application来完成。Flask的作用只是方便我们写这个application。

下一步请参考:网站框架功能要点。按照这个思路去研究Flask。

Apache配置文件代码段

配置DocumentRoot

# 定义变量
Define WEB_ROOT "E:\workspace\php\MonBook\website"

DocumentRoot ${WEB_ROOT}
<Directory ${WEB_ROOT}>
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks Includes ExecCGI

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

二级目录解析

Alias /simple_blog "E:\workspace\php\simple_blog"
<Directory "E:\workspace\php\simple_blog">
	Options Indexes FollowSymLinks Includes ExecCGI
	AllowOverride All
	Require all granted
</Directory>

二级域名解析

<VirtualHost local-wxadm-test.dymfilm.com:80>
    ServerName local-wxadm-test.dymfilm.com
    ErrorLog "D:\web_root\tmp\local-wxadm-test.dymfilm.com.log"
    CustomLog "D:\web_root\tmp\local-wxadm-test.dymfilm.com-custom.log" combined
    
    DocumentRoot "E:\workspace\php\weixin_backend\wxadm"
    <Directory "E:\workspace\php\weixin_backend\wxadm">
        # AllowOverride All      # Deprecated
        # Order Allow,Deny       # Deprecated
        # Allow from all         # Deprecated

        # --New way of doing it
        
        #Options Indexes FollowSymLinks Includes ExecCGI
        Options All
        AllowOverride All
        Require all granted
        
        # 定义URL重定向规则,不是文件,则指向index.php,源自Php的Yaf框架
        # 也可以配置到网站源码的.htaccess文件中
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule .* index.php
    </Directory>
</VirtualHost>

为什么坚持,想一想当初!

截屏2024-11-05 22.14.36

标题是周星驰说过的比较著名和深刻的一句话。我认为至少表达了两点:坚持、理想。

坚持是目前这个浮躁的社会所欠缺的,你所有的犹豫、观望、试图走捷径,都是在浪费时间,能做到坚持的人,少之又少。

理想对你而言,并不稀缺,关键是你行动了吗,你让自己觉得不堵了吗,没有。有理想很容易,实现起来就太现实了。

生活中有很多坚持理想的人,无论他们最终的结果如何,我们都应改尊敬他们,因为坚持这件事情不是普通人干的事,但实际上又是普通人能干的事。

2024年11月5日,更新:

没想到这次更新在9年之后,回头看看自己走的路,还是想对自己说,再坚持一下,你可以的!!!