跳转到正文
YK Liu
返回

Road To Pi

Bug#1: A deploy question

Pi engine, just like Wordpress, must be installed for get the initial developing environment. When I use git to clone cms from github, there were a few files changed and the DB had been built with a series of personal infomation. Therefore, the road start from deploying the changed project to suit local environment.

Firstly, I modified three main config files, include host.php, service.database.php, engine.php which totally in /var/config category,

host.php中的uri即其主机名要修改成和nginx所建立的虚拟主机名 我通过在nginx建立cms.local,所以该文件对应的也要修改

service.database.php中修改connection中的dsn, username, password,和table_prefix的值

修改nginx的配置,增加虚拟主机

server {
        listen       80;
        server_name  cms.local;

        location / {
            root   html/qcms/www;
            index  index.php index.html index.htm;
             if ($host ~* ^admin\.(.*)$) {
                rewrite ^(.*)$      /admin.php   last;
                break;
            }
            # API subdoamin
            if ($host ~* ^api\.(.*)$) {
                rewrite ^(.*)$      /api.php   last;
                break;
            }
            # Feed subdomain
            if ($host ~* ^feed\.(.*)$) {
                rewrite ^(.*)$      /feed.php   last;
                break;
            }
            # Widget subdoamin
            if ($host ~* ^widget\.(.*)$) {
                rewrite ^(.*)$      /widget.php   last;
                break;
            }
            if (!-e $request_filename) {
                # Admin route
                rewrite ^/admin(/(.*)?)?$   /admin.php   last;
                # API route
                rewrite ^/api(/(.*)?)?$     /api.php    last;
                # Feed route
                rewrite ^/feed(/(.*)?)?$    /feed.php   last;
                # Widget route
                rewrite ^/widget(/(.*)?)?$  /widget.php last;
                # Default app route
                rewrite ^/(.+)$             /app.php    last;
                break;
                }
            }

		error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html/qcms/www;
        }

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

        }
    }

修改C:\Windows\System32\drivers\etc下的hosts文件,在文件的最后一行添加

127.0.0.1 cms.local

这表明:在浏览器里输入url之后,该地址首先遭遇该文件的堵截,如果hosts文件中有该域名,那么直接进行跳转到127.0.0.1,进而通过nginx进行解析,而不是通过DNS进入Internet

自建pwd

管理员的账号信息存储在数据库的core_user_account表中

lib/Pi/Application/Model/User/RowGateway/Account.php,这个文件实现的类Account是上一个表的实例化,其中方法transformCredential是实现密码的方法,$credential是用户设置的自己的密码,Pi::config('salt')对应着engine.php中设置的salt,offsetGet('salt')是该用户在数据库中对应的salt字段的值

这样的话就可以通过这种方法创建某一个用户的pwd



上一篇
My understanding of php source code
下一篇
A line of funny JS code