2019年12月25日 星期三

php xmlrpc decode bug for large size and solution

1. When the response is large than 10MB the xmlrpc decode will return null

https://www.php.net/manual/en/function.xmlrpc-decode.php

Note that from libxml 2.7.9+ there is a limit of 10MB for the XML-RPC response.

If the response is larger, xmlrpc_decode will simply return NULL.

There is currently no way to override this limit like we can with the other xml functions (LIBXML_PARSEHUGE)


2.  solution parse using the

SimpleXML


example:
<?php
        //Enter your code here, enjoy
    $xmlString = <<<EOF
<?xml version='1.0'?>
<methodResponse>
        <params>
            <param>
                <value>
                    <array>
                        <data>
                            <value>
                                <string>Hello</string>
                            </value>
                            <value>
                                <string>Andy</string>
                            </value>
                        </data>
                    </array>
                </value>
            </param>
        </params>
</methodResponse>
EOF;

$xml = new SimpleXMLElement($xmlString);

if ($xml===null || !is_object($xml))
    die('Failed to load xml file.');
    

echo "ok";    

//print_r($xml);
echo $xml->params->param->value->array->data->value->string;
echo $xml->params->param->value->array->data->value[1]->string;

2019年12月23日 星期一

php unicode to utf8

<?php
        //Enter your code here, enjoy!


print_r(json_decode('{"t":"\u00ed"}'));

$str = "\u9060\u50b3\u96fb\u4fe1";
echo unicode2utf8($str);

function unicode2utf8($str){
        if(!$str) return $str;
       
        $decode = json_decode($str);
        if($decode) return $decode;

        $str = '["' . $str . '"]';
        $decode = json_decode($str);
        if(count($decode) == 1){
                return $decode[0];
        }
        return $str;
}

2019年12月4日 星期三

C# all other

1. route

a. https://dotblogs.com.tw/brooke/2014/12/10/147597

b.https://medium.com/quick-code/routing-in-asp-net-core-c433bff3f1a4

c. https://dotblogs.com.tw/lastsecret/2010/02/27/13798


Reference
https://blog.johnwu.cc/categories/asp-net-core/

2019年12月2日 星期一

C# new class

1. code

using System;

public class HowToObjectInitializers
{
    public static void Main()
    {
        // Declare a StudentName by using the constructor that has two parameters.
        StudentName student1 = new StudentName("new1", "Playstead");

        // Make the same declaration by using an object initializer and sending
        // arguments for the first and last names. The default constructor is
        // invoked in processing this declaration, not the constructor that has
        // two parameters.
        StudentName student2 = new StudentName
        {
            FirstName = "new2",
            LastName = "Playstead",
        };

        // Declare a StudentName by using an object initializer and sending
        // an argument for only the ID property. No corresponding constructor is
        // necessary. Only the default constructor is used to process object
        // initializers.
        StudentName student3 = new StudentName
        {
            ID = 183
        };

        // Declare a StudentName by using an object initializer and sending
        // arguments for all three properties. No corresponding constructor is
        // defined in the class.
        StudentName student4 = new StudentName
        {
            FirstName = "new4",
            LastName = "Playstead",
            ID = 116
        };

        Console.WriteLine(student1.ToString());
        Console.WriteLine(student2.ToString());
        Console.WriteLine(student3.ToString());
        Console.WriteLine(student4.ToString());
    }
    // Output:
    // Craig  0
    // Craig  0
    //   183
    // Craig  116

    public class StudentName
    {
        // The default constructor has no parameters. The default constructor
        // is invoked in the processing of object initializers.
        // You can test this by changing the access modifier from public to
        // private. The declarations in Main that use object initializers will
        // fail.
        public StudentName() { }

        // The following constructor has parameters for two of the three
        // properties.
        public StudentName(string first, string last)
        {
            FirstName = first;
            LastName = last;
        }

        // Properties.
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int ID { get; set; }

        public override string ToString()
{
return FirstName + "  " + ID;
}
    }
}

2. Refrence
https://docs.microsoft.com/zh-tw/dotnet/csharp/programming-guide/classes-and-structs/how-to-initialize-objects-by-using-an-object-initializer


https://dotnetfiddle.net/

2019年12月1日 星期日

C# async/await

1. Expalin
https://blog.darkthread.net/blog/async-aspnet/


2. code
https://docs.microsoft.com/zh-tw/dotnet/csharp/language-reference/operators/await


---
using System;
using System.Net.Http;
using System.Threading.Tasks;

public class AwaitOperator
{
    public static async Task Main()
    {
        Task<int> downloading = DownloadDocsMainPageAsync();
        Console.WriteLine($"{nameof(Main)}: Launched downloading.....1\n");

        int bytesLoaded = await downloading;
        Console.WriteLine($"{nameof(Main)}: Downloaded {bytesLoaded} bytes.....4\n");

    }

    private static async Task<int> DownloadDocsMainPageAsync()
    {
        Console.WriteLine($"{nameof(DownloadDocsMainPageAsync)}: About to start downloading.....2\n");
     
        var client = new HttpClient();
        byte[] content = await client.GetByteArrayAsync("https://docs.microsoft.com/en-us/");
     
        Console.WriteLine($"{nameof(DownloadDocsMainPageAsync)}: Finished downloading.....3");
        return content.Length;
    }
}

---


3. online c#
https://dotnetfiddle.net/

dotnet fileter choose .netcore3.0


4.
https://stackoverflow.com/questions/19335451/async-and-await-are-not-working


5. Very goodd
https://www.huanlintalk.com/2016/01/async-and-await.html

2019年11月21日 星期四

alpine linux

1. security
https://alpinelinux.org/posts/Docker-image-vulnerability-CVE-2019-5021.html


2. ngix docker
https://5xruby.tw/posts/deploying-your-docker-rails-app/

https://www.docker.com/blog/tips-for-deploying-nginx-official-image-with-docker/

https://takacsmark.com/copying-files-from-host-to-docker-container/

#
glibc
https://www.linuxquestions.org/questions/linux-general-1/what-are-libc-glibc-49709/

https://stackoverflow.com/questions/11372872/what-is-the-role-of-libcglibc-in-our-linux-app

#musl
https://www.musl-libc.org/how.html


#nginx
https://nginx.org/en/docs/ngx_core_module.html#worker_processes

https://blog.hellojcc.tw/2015/12/07/nginx-beginner-tutorial/

https://serverfault.com/questions/706694/use-nginx-as-reverse-proxy-for-multiple-servers

https://stackoverflow.com/questions/18861300/how-to-run-nginx-within-a-docker-container-without-halting

# gcc
https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html

https://www.ibm.com/developerworks/cn/linux/l-cn-linklib/gcc.pdf

https://gcc.gnu.org/onlinedocs/gcc.pdf

# kernel
http://index-of.es/EBooks/O'Reilly%20-%20Understanding%20The%20Linux%20Kernel.pdf

https://bootlin.com/doc/training/linux-kernel/linux-kernel-slides.pdf

https://cse.yeditepe.edu.tr/~kserdaroglu/spring2014/cse331/termproject/BOOKS/ProfessionalLinuxKernelArchitecture-WolfgangMauerer.pdf

# clanguage
https://www.tutorialspoint.com/cprogramming/c_data_types.htm

# compose3
https://docs.docker.com/compose/compose-file/

# bridge netwok
https://godleon.github.io/blog/Docker/docker-network-bridge/


Linux kernel

1.
Linux makes system and kernel information available in user space through pseudo filesystems, sometimes also called virtual filesystems

▶ proc, usually mounted on /proc: Operating system related information (processes, memory management parameters...)
▶ sysfs, usually mounted on /sys: Representation of the system as a set of devices and buses. Information about these devices.

glibc

1.
https://stackoverflow.com/questions/10412684/how-to-compile-my-own-glibc-c-standard-library-from-source-and-use-it

2
https://stackoverflow.com/questions/5925678/location-of-c-standard-library

2019年11月20日 星期三

zip source code and compiler

https://github.com/kuba--/zip/blob/master/src/zip.c

http://www.linuxfromscratch.org/blfs/view/8.0/general/zip.html

https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Markov_chain_algorithm

2019年11月11日 星期一

docker asp net


https://gitlab.alpinelinux.org/alpine/aports/issues/8603


https://github.com/microsoft/DockerTools/issues/131


https://github.com/microsoft/DockerTools/issues/131

https://hub.docker.com/_/microsoft-dotnet-core-sdk


https://www.cnblogs.com/redpod/p/dotnet_core_alpine_linux.html

https://dotnet.microsoft.com/download/dotnet-core/3.0

https://tatmingstudio.blogspot.com/2017/07/aspnet-core-centos-7-apache.html

https://linuxhint.com/install_dot_net_core_centos7/

https://hub.docker.com/_/microsoft-dotnet-core/

https://docs.microsoft.com/zh-tw/dotnet/architecture/microservices/net-core-net-framework-containers/official-net-docker-images

https://hub.docker.com/_/microsoft-dotnet-core-sdk/


https://ithelp.ithome.com.tw/articles/10204760

https://docs.microsoft.com/zh-tw/dotnet/core/linux-prerequisites?tabs=netcore21


https://stackoverflow.com/questions/51354868/run-asp-net-core-app-under-linux-on-startup

https://hub.docker.com/_/microsoft-dotnet-core-sdk/

# centos 7
https://dotnet.microsoft.com/learn/aspnet/hello-world-tutorial/install

# deotnet 2.2
https://knative.dev/v0.4-docs/serving/samples/hello-world/helloworld-csharp/

# Hello world
https://riptutorial.com/dot-net-core/example/19361/building-a-hello-world-sample-application

# .net
https://medium.com/wolox-driving-innovation/how-to-create-your-first-net-e2223dedb74f

# publis
https://docs.microsoft.com/zh-tw/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-3.0

# asp.net
https://ithelp.ithome.com.tw/articles/10204760

https://blog.darkthread.net/blog/is-aspnetcore-worth-learning/

# run with  hello
https://subscription.packtpub.com/book/application_development/9781785886751/1/ch01lvl1sec15/creating-an-asp-net-core-mvc-application-on-linux

#kestrel
https://docs.microsoft.com/zh-tw/aspnet/core/fundamentals/servers/?view=aspnetcore-3.0&tabs=linux

https://blog.darkthread.net/blog/set-kestrel-port/

https://blog.darkthread.net/blog/aspnetcore-with-nginx/

https://stackify.com/what-is-kestrel-web-server/


# asp.net image
https://docs.microsoft.com/zh-tw/dotnet/architecture/microservices/net-core-net-framework-containers/net-container-os-targets
# asp.net example
https://www.atlascode.com/blog/running-asp-net-core-in-an-alpine-linux-docker-container/

# content
http://www.secretgeek.net/dotnet_run

# example
https://ithelp.ithome.com.tw/articles/10201977

# dotnet sln
https://stackoverflow.com/questions/42730877/net-core-when-to-use-dotnet-new-sln

# dotnet publish
https://docs.microsoft.com/zh-tw/dotnet/core/tools/dotnet-publish?tabs=netcore21


# dotnet alpine and publish
https://github.com/dotnet/core/issues/1689

# alpine pakcge
https://pkgs.alpinelinux.org/contents?file=ld-linux-x86-64.so.2&path=&name=&branch=&repo=&arch=

# dotnet url
https://blog.darkthread.net/blog/set-kestrel-port/

# dotnet centos
https://dotnet.microsoft.com/download/linux-package-manager/centos7/sdk-current


# dotnet https
https://github.com/aspnet/AspNetCore/issues/6011

https://ithelp.ithome.com.tw/articles/10197326


# dotnet publish copy
https://stackoverflow.com/questions/119271/copy-all-files-and-folders-using-msbuild

https://stackoverflow.com/questions/42712055/asp-net-core-exclude-or-include-files-on-publish

https://github.com/dotnet/cli/issues/3833

https://docs.microsoft.com/zh-tw/dotnet/core/tools/project-json-to-csproj

https://dotblogs.com.tw/supershowwei/2017/07/26/164153

https://docs.microsoft.com/zh-tw/aspnet/core/client-side/bundling-and-minification?view=aspnetcore-3.0&tabs=visual-studio

https://www.davidhayden.me/blog/asp-net-core-bundle-and-minify-css-and-js

https://blog.johnwu.cc/article/ironman-day05-asp-net-core-static-files.html

https://stackoverflow.com/questions/54970400/wwwroot-folder-in-asp-net-core-2-2

# can test
https://github.com/dotnet/cli/issues/1396

#
https://medium.com/@scottkuhl/updating-your-javascript-libraries-in-asp-net-core-2-2-3c2d985a491e

# msbuild
https://docs.microsoft.com/zh-tw/visualstudio/msbuild/msbuild-concepts?view=vs-2019

https://docs.microsoft.com/zh-tw/visualstudio/msbuild/itemgroup-element-msbuild?view=vs-2019

https://stackoverflow.com/questions/49573010/dotnet-publish-include-extra-files

# urls
https://blog.darkthread.net/blog/set-kestrel-port/



################################
## Learn more
#################################
1.  Books 

2. Middle ware 1

3. Top project
1

4. Learning
1 C#

5. Sample
to-do-list


6. localtion
https://github.com/damienbod/AspNetCoreLocalization

7. dotnoet core cookie with outside
1 2

8. dotnet core static class with log
1




2019年11月6日 星期三

docker program




# simple the envim

 bigred@CVN80:~/wk/spk$ docker run --rm -e my_name="andy" -it alpine
/ # ls
bin    etc    lib    mnt    proc   run    srv    tmp    var
dev    home   media  opt    root   sbin   sys    usr
/ # set
HISTFILE='/root/.ash_history'
HOME='/root'
HOSTNAME='815aa067de89'
IFS='
'
LINENO=''
OPTIND='1'
PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
PPID='0'
PS1='\w \$ '
PS2='> '
PS4='+ '
PWD='/'
SHLVL='1'
TERM='xterm'
_='ls'



#


#
https://docs.docker.com/develop/develop-images/baseimages/

https://hub.docker.com/_/scratch

https://alpinelinux.org/

https://flykof.pixnet.net/blog/post/22995832-ubunto%E4%B8%8B%E5%AE%89%E8%A3%9Dbusybox

https://busybox.net/about.html

https://cizixs.com/2017/11/05/oci-and-runc/

https://www.tutorialspoint.com/unix_commands/nc.htm



# compose
https://titangene.github.io/article/networking-in-docker-compose.html

https://ithelp.ithome.com.tw/articles/10206437

https://docs.docker.com/compose/compose-file/compose-versioning/

https://medium.com/@VisonLi/docker-%E5%85%A5%E9%96%80-%E7%AD%86%E8%A8%98-part-2-91e4dfa2b365


# network
https://k2r2bai.com/2016/01/05/container/docker-network/

https://godleon.github.io/blog/Docker/docker-network-overview/

2019年11月4日 星期一

HAPorxy Install for mysql

PART1 Install the ha pxoy

simple

https://www.haproxy.com/blog/hitless-reloads-with-haproxy-howto/


https://galeracluster.com/library/documentation/ha-proxy.html
https://computingforgeeks.com/galera-cluster-high-availability-with-haproxy-on-ubuntu-18-04-centos-7/

http://benjr.tw/95644


http://random168.blogspot.com/2018/11/linux-haproxy-mariadbmysql.html

https://iter01.com/59486.html

scl

https://pario.no/2018/07/17/install-haproxy-1-8-on-centos-7/

large

https://www.fromdual.com/making-haproxy-high-available-for-mysql-galera-cluster
https://www.jonespaulr.net/ha-mariadbgalera-cluster-w-haproxy-and-keepalived.html

Part2  install the  haproxy log


https://ruilung-notes.blogspot.com/2016/12/haproxylog.html

https://ops.tips/gists/haproxy-docker-container-logs/


part3  install the view


https://www.datadoghq.com/blog/how-to-collect-haproxy-metrics/

https://www.haproxy.com/blog/dynamic-configuration-haproxy-runtime-api/

REF document

ch:

https://www.cnblogs.com/dkblog/archive/2012/03/13/2393321.html

en

https://www.haproxy.org/download/1.4/doc/configuration.txt

https://www.haproxy.com/blog/the-four-essential-sections-of-an-haproxy-configuration/



https://stackshare.io/stackups/haproxy-vs-keepalived

https://codertw.com/%E4%BC%BA%E6%9C%8D%E5%99%A8/382202/

https://ssorc.tw/5937

strange parameter

https://stackoverflow.com/questions/34840176/when-to-use-httpclose-or-http-server-close-in-haproxy
https://ops.tips/gists/making-haproxy-respond-200ok-to-health-checks/
http://wsfdl.com/openstack/2014/12/24/Haproxy%E4%B8%8EOpenStack-API%E5%AE%89%E5%85%A8.html

2019年10月22日 星期二

docker Mariadb

1. install

https://linoxide.com/containers/setup-use-mariadb-docker-container/


2. docker network setting in container
https://philipzheng.gitbooks.io/docker_practice/content/network/linking.html

3. mariadb explain
https://mariadb.com/kb/en/library/installing-and-using-mariadb-via-docker/
https://mariadb.com/kb/en/library/configuring-mariadb-for-remote-client-access/
https://tableplus.com/blog/2018/09/mariadb-how-to-create-new-user-and-grant-privileges.html


4. db with network
http://arder-note.blogspot.com/2018/05/docker-container-link-network.html


5.
http://benjr.tw/95284

https://mariadb.org/get-involved/getting-started-for-developers/get-code-build-test/


6. download data
https://relational.fit.cvut.cz/dataset/NBA


7. testing
sqlslap:
https://www.digitalocean.com/community/tutorials/how-to-measure-mysql-query-performance-with-mysqlslap
https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/187279/

https://dev.mysql.com/doc/refman/8.0/en/mysqlslap.html

https://www.techrepublic.com/blog/how-do-i/how-do-i-stress-test-mysql-with-mysqlslap/


sysbech:
https://github.com/akopytov/sysbench
https://severalnines.com/database-blog/how-benchmark-performance-mysql-mariadb-using-sysbench
https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/187279/


linkbech:
https://mariadb.org/performance-evaluation-of-mariadb-10-1-and-mysql-5-7-4-labs-tplc/


8. cluster:
http://benjr.tw/95381

http://benjr.tw/12461

https://abcg5.pixnet.net/blog/post/113914391

http://akuma1.pixnet.net/blog/post/172611248-mariadb-cluster-%E6%9E%B6%E8%A8%AD%EF%BC%8D%EF%BC%8D%EF%BC%88%E4%B8%89%EF%BC%89%E8%A8%AD%E5%AE%9Amariadb-cluster


https://kknews.cc/zh-tw/code/nv8jxaq.html

https://mariadb.com/kb/en/library/what-is-mariadb-galera-cluster/

https://linuxize.com/post/how-to-install-mariadb-on-ubuntu-18-04/

# replicate
https://noter.tw/4508/mariadb-replication-%E8%A8%AD%E5%AE%9A/

https://allen-fjl.blogspot.com/2018/02/centos-7-mysqlmariadb-replication.html

https://www.ithome.com.tw/tech/87416

9.  replicate
https://kknews.cc/zh-tw/code/l3b3eeb.html

https://www.itread01.com/content/1548326306.html

https://www.itread01.com/p/1136578.html

https://abcg5.pixnet.net/blog/post/117473364-%E5%AF%A6%E4%BD%9C%E7%B0%A1%E5%96%AE%E7%9A%84mariadb-replication

https://blog.toright.com/posts/5062/mysql-replication-%E4%B8%BB%E5%BE%9E%E5%BC%8F%E6%9E%B6%E6%A7%8B%E8%A8%AD%E5%AE%9A%E6%95%99%E5%AD%B8.html

https://www.itread01.com/content/1525956033.html

10.
http://benjr.tw/95644

http://benjr.tw/95473

https://mariadb.com/kb/en/library/installing-galera-from-source/

http://random168.blogspot.com/2018/11/mariadbmysql-galera-cluster.html

https://blog.wu-boy.com/2012/11/innodb-as-the-default-mysql-storage-engine/

http://hank20.blogspot.com/2018/04/centos7mariadb103galera-cluster.html

https://www.itread01.com/articles/1494275901.html

http://benjr.tw/95381

https://galeracluster.com/library/documentation/galera-parameters.html

https://galeracluster.com/library/documentation/mysql-wsrep-options.html#wsrep-node-name

https://severalnines.com/database-blog/running-mariadb-galera-cluster-without-container-orchestration-tools-part-one

https://galeracluster.com/library/documentation/quorum-reset.html

https://www.cnblogs.com/nulige/articles/8470001.html

https://galeracluster.com/library/documentation/docker.html

https://codertw.com/%E8%B3%87%E6%96%99%E5%BA%AB/11036/

https://severalnines.com/database-blog/galera-cluster-recovery-101-deep-dive-network-partitioning


11. Galera ok
A. install : 
B. usigin safe start  , start2
C. cluster container
D.  other
E. other 2
F.other 3


12. Other pameter
https://galeracluster.com/library/documentation/mysql-wsrep-options.html#wsrep-cluster-address


https://www.dreamvps.com/tutorials/install-mysql-galera-cluster-centos-7/

http://hank20.blogspot.com/2018/04/centos7mariadb103galera-cluster.html

http://it2record.blogspot.com/2014/07/centos65-mariadb-55-galera-server.html

https://blog.wu-boy.com/2013/03/galera-cluster-for-mysql-multi-master-replication/

https://galeracluster.com/library/documentation/notification-cmd.html

good

https://www.centos.bz/2017/07/centos-7-2-install-mariadb-galera-cluster10-1-21-mariadb-3-master-cluster/


2019年10月20日 星期日

EMC api for isilon

1. login
https://community.emc.com/community/products/isilon/blog/2015/10/29/onefs-api-tutorial-insightiq-performance-metrics

2.  api
http://doc.isilon.com/onefs/8.1.0/api/02-ifs-br-intro-to-onefs-api.htm

3. system api
http://doc.isilon.com/onefs/8.1.0/api/04-ifs-br-file-system-access-apis.htm

2019年10月16日 星期三

unicode and utf8

https://pjchender.blogspot.com/2018/06/guide-unicode-javascript.html


PHP to character


print_r(json_decode('{"t":"\u00ed"}'));

$str = "\u9060\u50b3\u96fb\u4fe1";
echo unicode2utf8($str);

function unicode2utf8($str){
        if(!$str) return $str;
       
        $decode = json_decode($str);
        if($decode) return $decode;

        $str = '["' . $str . '"]';
        $decode = json_decode($str);
        if(count($decode) == 1){
                return $decode[0];
        }
        return $str;
}


ref  1

2019年9月26日 星期四

Docker Concept

1. Example 1
Docker 不是虚拟机,容器中的应用都应该以前台执行,而不是像虚拟机、物理机里面那样,用 systemd去启动后台服务,容器内没有后台服务的概念。
一些初学者将 CMD 写为:
CMD service nginx start
然后发现容器执行后就立即退出了。甚至在容器内去使用 systemctl 命令结果却发现根本执行不了。这就是因为没有搞明白前台、后台的概念,没有区分容器和虚拟机的差异,依旧在以传统虚拟机的角度去理解容器。
正确的做法是直接执行 nginx 可执行文件,并且要求以前台形式运行。比如:
CMD ["nginx", "-g", "daemon off;"]


2.  EXPOSE

EXPOSE
 指令是声明运行时容器提供服务端口,这只是一个声明,
在运行时并不会因为这个声明应用就会开启这个端口的服务。在 Dockerfile 中写入这样的声明有两个好处,一个是帮助镜像使用者理解这个镜像服务的守护端口,以方便配置映射;另一个用处则是在运行时使用随机端口映射时,也就是 docker run -P时,会自动随机映射 EXPOSE 的端口。
要将 EXPOSE 和在运行时使用 -p <宿主端口>:<容器端口> 区分开来。-p,是映射宿主端口和容器端口,换句话说,就是将容器的对应端口服务公开给外界访问,而 EXPOSE 仅仅是声明容器打算使用什么端口而已,并不会自动在宿主进行端口映射



3. WORKDIR 
格式为 WORKDIR <工作目录路径>
使用 WORKDIR 指令可以来指定工作目录(或者称为当前目录),以后各层的当前目录就被改为指定的目录,如该目录不存在,WORKDIR 会帮你建立目录。
之前提到一些初学者常犯的错误是把 Dockerfile 等同于 Shell 脚本来书写,这种错误的理解还可能会导致出现下面这样的错误:
RUN cd /app
RUN echo "hello" > world.txt
如果将这个 Dockerfile 进行构建镜像运行后,会发现找不到 /app/world.txt 文件,或者其内容不是 hello。原因其实很简单,在 Shell 中,连续两行是同一个进程执行环境,因此前一个命令修改的内存状态,会直接影响后一个命令;而在 Dockerfile 中,这两行 RUN 命令的执行环境根本不同,是两个完全不同的容器。这就是对 Dockerfile 构建分层存储的概念不了解所导致的错误。
之前说过每一个 RUN 都是启动一个容器、执行命令、然后提交存储层文件变更。第一层 RUN cd /app 的执行仅仅是当前进程的工作目录变更,一个内存上的变化而已,其结果不会造成任何文件变更。而到第二层的时候,启动的是一个全新的容器,跟第一层的容器更完全没关系,自然不可能继承前一层构建过程中的内存变化。
因此如果需要改变以后各层的工作目录的位置,那么应该使用 WORKDIR 指令



4.  study
https://jeffreyfritz.com/2018/09/deploying-asp-net-core-with-net-framework-using-docker/

https://www.jinnsblog.com/2018/12/docker-dockerfile-guide.html

https://blog.alexellis.io/run-iis-asp-net-on-windows-10-with-docker/

http://www.codedata.com.tw/social-coding/docker-layman-abc/

https://columns.chicken-house.net/2018/05/12/msa-labs2-selfhost/


https://skychang.github.io/2015/07/30/%E8%AE%93-ASP-NET-MVC-%E5%9F%B7%E8%A1%8C%E6%96%BC-Docker/

2019年9月25日 星期三

apache redis guidline



https://blog.gxxsite.com/laravel-redis-cache-clear-session-queue/

https://matomo.org/faq/how-to/faq_20521/


https://github.com/MISP/misp-book/issues/36

https://www.cloudways.com/blog/redis-for-queuing-in-laravel-5/


https://www.objectrocket.com/blog/how-to/top-5-redis-use-cases/


# apache mpm_prefork
https://serverfault.com/questions/269674/why-is-apache-running-so-many-processes-excessive-ram-here

https://stackoverflow.com/questions/15922194/problems-with-apache-servers-and-a-lot-of-httpd-processes

https://serverfault.com/questions/823121/why-is-apache-spawning-so-many-processes

https://serverfault.com/questions/365205/why-are-there-many-httpd-process-on-the-machine-while-i-only-started-one-apache

https://stackoverflow.com/questions/36924952/ah00161-server-reached-maxrequestworkers-setting-consider-raising-the-maxreque

https://serverfault.com/questions/684424/how-to-tune-apache-on-ubuntu-14-04-server

docker apache notice the tmpfs



1.  Problem

Apache 2.4 AH01762 & AH01760: failed to initialize shm (Shared Memory Segment)




2. solution
$ mkdir /run/httpd



3. reason
为了让容器能够访问数据而不需要永久地写入数据,可以使用 tmpfs 挂载,该挂载仅存储在主机的内存中(如果内存不足,则为 swap)。当容器停止时,tmpfs 挂载会被移除。如果提交容器,则不会保存 tmpfs 挂载



4. ref

https://ma.ttias.be/apache-2-4-ah01762-ah01760-failed-to-initialize-shm-shared-memory-segment/
https://bugzilla.redhat.com/show_bug.cgi?id=1215667

# tmpfs
https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html
https://zh.wikipedia.org/zh-tw/Tmpfs
https://adon988.logdown.com/posts/7801999-docker-tmpfs

https://blog.csdn.net/kikajack/article/details/79475168
https://unix.stackexchange.com/questions/13972/what-is-this-new-run-filesystem

2019年9月16日 星期一

docker reference


1. docker good book
https://www.jinnsblog.com/2018/10/docker-container-command.html

https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes

https://philipzheng.gitbooks.io/docker_practice/content/container/run.html

http://www.runoob.com/docker/docker-commit-command.html

http://www.runoob.com/docker/docker-install-apache.html

https://ithelp.ithome.com.tw/articles/10186431

https://skychang.github.io/2015/07/30/%E5%BB%BA%E7%AB%8B%E8%87%AA%E5%B7%B1%E7%9A%84-Docker-image/

https://www.scalyr.com/blog/create-docker-image/

https://joshhu.gitbooks.io/dockercommands/content/DockerImages/CommandArgs.html

# docker paty2
https://medium.com/@VisonLi/docker-%E5%85%A5%E9%96%80-%E7%AD%86%E8%A8%98-part-2-91e4dfa2b365

# simple learn docker
https://philipzheng.gitbooks.io/docker_practice/content/container/daemon.html

https://joshhu.gitbooks.io/dockercommands/content/Parameters/Parameters.html

2. docker php
https://medium.com/@vi1996ash/steps-to-build-apache-web-server-docker-image-1a2f21504a8e
https://medium.com/faun/how-to-build-a-docker-container-from-scratch-docker-basics-a-must-know-395cba82897b
https://www.ibm.com/developerworks/community/blogs/8ff122ba-5fbc-4844-8f62-340d437131ee/entry/How_to_build_your_own_Apache_HTTP_server_on_Docker?lang=en

https://github.com/docker-library/httpd/blob/17166574dea6a8c574443fc3a06bdb5a8bc97743/2.4/httpd-foreground

https://serverfault.com/questions/901810/cant-start-httpd-service-in-docker-image

https://phoenixnap.com/kb/how-to-restart-apache-centos-linux

https://phoenixnap.com/kb/how-to-restart-apache-centos-linux


3. apache centos7
https://blog.yslifes.com/archives/2523
https://www.rosehosting.com/blog/how-to-install-php-7-2-on-centos-7/
http://blog.cspc123.com/?p=168



4.  docker content
https://qiita.com/vc7/items/82863c4bd1f70f102b36

https://stackify.com/docker-performance-improvement-tips-and-tricks/

https://www.ithome.com.tw/news/103247

# docker cenos7 image
https://hub.docker.com/_/centos

# docker hello wold
https://medium.com/@VisonLi/docker-%E5%85%A5%E9%96%80-%E7%AD%86%E8%A8%98-part-2-91e4dfa2b365

# docker compose
http://blog.maxkit.com.tw/2017/03/docker-compose.html

https://stackoverflow.com/questions/34482018/docker-compose-up-does-not-start-a-container

https://yami.io/ubuntu-docker/

https://medium.com/@giorgioto/docker-compose-yml-from-v1-to-v2-3c0f8bb7a48e

https://dev.to/kbariotis/dont-just-docker-compose-up-gff

# docker overivew
https://blog.techbridge.cc/2018/09/07/docker-compose-tutorial-intro/



5. Httpd
https://github.com/hhcordero/docker-centos-apache-dev/blob/master/Dockerfile

http://www.inanzzz.com/index.php/post/rhsb/running-apache-server-as-foreground-on-ubuntu-with-dockerfile

https://github.com/hhcordero/docker-centos-apache-dev/blob/master/httpd-foreground

# httpd security
https://www.tecmint.com/apache-security-tips/



6. http://www2.lssh.tp.edu.tw/~hlf/class-1/linux/file_permission.htm
咦!似乎好像是可以喔!因為有可讀[ r ]存在嘛!『錯!』答案是非 root 這個帳號的其他使用者均不可進入 .ssh 這個目錄,為什麼呢?因為 x 與 目錄 的關係相當的重要,如果您在該目錄底下不能執行任何指令的話,那麼自然也就無法執行 ls, cd 等指令,所以囉,也就無法進入了,因此,請特別留意的是,如果您想要開放某個目錄讓一些人進來的話,請記得將該目錄的 x 屬性給開放呦! 


https://shian420.pixnet.net/blog/post/344938711-%5Blinux%5D-chmod-%E6%AA%94%E6%A1%88%E6%AC%8A%E9%99%90%E5%A4%A7%E7%B5%B1%E6%95%B4%21

https://www.thegeekstuff.com/2016/04/docker-compose-up-stop-rm/



7.

2019年9月5日 星期四

Load balance mech


KeepliveD
1.  https://www.keepalived.org/
2. https://access.redhat.com/documentation/zh-tw/red_hat_enterprise_linux/7/html/load_balancer_administration/ch-initial-setup-vsa


3. https://dawho.tw/
4. http://gcharriere.com/blog/?p=339

5. http://mylinuxcloudnotes.blogspot.com/2015/08/centos7-keepalived.html
6. https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/408407/

7.http://icodding.blogspot.com/2015/08/mysql-replicationmaster-slave.html

8.https://geekflare.com/open-source-load-balancer/
9. https://geekflare.com/open-source-load-balancer/#Pen

10.https://access.redhat.com/documentation/zh-tw/red_hat_enterprise_linux/7/pdf/load_balancer_administration/Red_Hat_Enterprise_Linux-7-Load_Balancer_Administration-zh-TW.pdf


11. https://www.nginx.com/blog/scaling-mysql-tcp-load-balancing-nginx-plus-galera-cluster/

12. https://linuxhandbook.com/load-balancing-setup/

13.https://severalnines.com/blog/using-nginx-database-load-balancer-galera-cluster

14. https://dasunhegoda.com/nginx-reverse-proxying-load-balancing/1248/

15. https://www.manpc.tk/wordpress/2016/06/03/nginx-load-balancer%E5%B9%B3%E8%A1%A1%E8%B2%A0%E8%BC%89for-mysql-or-mariadb-galera-cluster/

16https://www.nginx.com/blog/mysql-high-availability-with-nginx-plus-and-galera-cluster/


2019年8月29日 星期四

underscore_js



1.
https://stackoverflow.com/questions/4778881/how-to-use-underscore-js-as-a-template-engine

2.
https://www.sitepoint.com/getting-started-with-underscore-js/

3.
https://playcode.io/

4.
https://wbkuo.pixnet.net/blog/post/207623383-%5Bjavascript%5D-underscore-%E7%9A%84-template-%E5%8A%9F%E8%83%BD%E6%B8%AC%E8%A9%A6

2019年8月27日 星期二

Backbonejs


https://code.tutsplus.com/tutorials/single-page-todo-application-with-backbonejs--cms-21417

https://github.com/tutsplus/single-page-todo-backbone

https://bocoup.com/blog/organizing-your-backbone-js-application-with-modules


https://github.com/mitsuruog/SPA-with-Backbone


https://github.com/mitsuruog/SPA-with-Backbone/tree/phase-1

https://blog.wu-boy.com/2012/04/backbonejs-framework-tutorial-example-1/

https://codertw.com/%E5%89%8D%E7%AB%AF%E9%96%8B%E7%99%BC/277045/

1
http://icodingtw.blogspot.com/2012/04/backbonejs.html

2
http://icodingtw.blogspot.com/2012/04/backbonejs.html

3
http://icodingtw.blogspot.com/2012/05/backbonejs.html

4.
https://rightson.blogspot.com/2012/05/backbonejs.html

5.
http://rightson.blogspot.com/2012/07/backbonejs.html

6.
http://ozzysun.blogspot.com/2012/02/backbonejs-model-04fetch.html

7.
http://jamestw.logdown.com/posts/166159-backbonejs

8.
http://jamestw.logdown.com/posts/166159-backbonejs


9.
https://github.com/jashkenas/backbone/wiki/Tutorials%2C-blog-posts-and-example-sites

2019年8月26日 星期一

Good web design


http://www.eikospartners.com/blog/single-page-applications-a-powerful-design-pattern-for-modern-web-apps

https://medium.com/a-lady-dev/single-page-applications-a-powerful-design-pattern-for-modern-web-apps-ec3590bb7e7a

https://purpleorangepr.com/

https://www.intechnic.com/blog/60-beautiful-examples-of-one-page-website-design-inspirations/


https://www.awwwards.com/practical-uses-of-angularjs-create-a-single-page-application-spa-or-a-website-menu-in-an-instant.html

good
http://www.jollen.org/blog/2014/09/single-page-application.html


https://stackoverflow.com/questions/10040297/how-exactly-can-i-replace-an-iframe-with-a-div-and-javascript


https://codepen.io/ettrics/full/ogRaRv/

https://tympanus.net/Blueprints/MultiLevelMenu/

https://colorlib.com/wp/free-website-menu-templates/

PHP Security



#set up response header
<IfModule mod_headers.c>
Header set X-Frame-Options "SAMEORIGIN"
Header set Content-Security-Policy "default-src 'self'"
</IfModule>


https://adamschen9921.pixnet.net/blog/post/116879044-apache%E7%A7%BB%E9%99%A4%E9%87%8D%E8%A6%81%E8%B3%87%E8%A8%8Aheader

https://gist.github.com/phpdave/24d879514e7411047267

Net craft website

https://toolbar.netcraft.com/site_report?url=tympanus.net%2FBlueprints%2FMultiLevelMenu%2F

https://toolbar.netcraft.com/stats/topsites?c=JP&submit=Refresh

2019年8月22日 星期四

SSH web log tunnel, no need install browser in server

1. SSH
  • ssh -L 8080:remoteMachine.me:80 user@remoteMachine
Local port: 8080
remote port: 80


ref 1 2 3

2019年8月15日 星期四

php centos7 install mysql and pdo

1. install mysql package for php
ref  https://www.opencli.com/php/php-use-mysqlnd-replace-libmysql


libmysql 是 PHP 沿用已久的 MySQL driver, 而在 PHP 5.3 開始, PHP 內建了 PHP 專用連接 MySQL 的 Driver — mysqlnd, 而從 PHP 5.4 之後的版本, mysqlnd 更被 PHP 作為預設安裝選項。
如果在 RHEL / CentOS 下要安裝 mysqlnd, 可以用 yum 指令完成, 但由於 php-mysqlnd (mysqlnd) 與 php-mysql (libmysql) 不能共存, 所以安裝前要先移除 php-mysql.

# yum install php-mysqlnd



2 PHP7 install phpmyadmin


Ref 1









2019年8月14日 星期三

php install oracle connect

1.  Oracle Instant Client

Oracle Instant Client enables applications to connect to a local or remote Oracle Database for development and production deployment. The Instant Client libraries provide the necessary network connectivity, as well as basic and high end data features, to make full use of Oracle Database. It underlies the Oracle APIs of popular languages and environments including Node.js, Python and PHP, as well as providing access for OCI, OCCI, JDBC, ODBC and Pro*C applications. Tools included in Instant Client, such as SQL*Plus and Oracle Data Pump, provide quick and convenient data access.




2.  install




3 Step:
package: oci8-2.2.0
package: oracle-instantclient19.3-basic-19.3.0.0.0.0-1,
oracle-instantclient19.3-devel-19.3.0.0.0.1.x86_64.rpm,
oracle-instantclient19.3-sqlplus-193.30.0.01.x84_64.rpm


1. install rpm  for basic and develop, 
2. install oci8, 透過OCI8連到Oracle之範例說明
3. install php.d for oci8.ini
4. resta server

4. Good reference
linux centos centos7 安装oci8
CentOS下,裝Oci8
Oci_connect function is undefined in CentOS with Oracle


5. explain PHP INI
php ini chinese




2019年8月13日 星期二

Linux bash loop Problem

1. Problem:
This will cause the fork bomb if you in bashrc write
scl enable XXX

bash fork retry: no child processes

2. solution Logout
killall -KILL -u user1

Install apache and php

1. 安裝 1

Simple install 1
https://dywang.csie.cyut.edu.tw/dywang/rhce7/node71.html



2. Bird and detail content Install 2

http://linux.vbird.org/linux_server/0360apache.php#www_basic_basic



3. Quick install 

https://www.opencli.com/linux/redhat-centos-7-setup-apache-mariadb-php

php 7

1. reference

https://tecadmin.net/nstall-php7-on-centos6/
https://www.tecmint.com/install-php-7-in-centos-6/
https://tecadmin.net/nstall-php7-on-centos6/

2.  說明

 PHP 是 Apache 當中的一個模組,那在談了 Apache 的 httpd.conf 之後,『我們怎麼沒有講到 PHP 這個模組的設定啊?』不是不講啦!而是因為目前 Apache 很聰明的將一些重要模組給他拆出來放置到 /etc/httpd/conf.d/*.conf 檔案中了,所以我們必須要到該目錄下才能瞭解到某些模組是否有被加入啊!底下先來瞧瞧吧!

https://stackoverflow.com/questions/2772400/how-does-php-interface-with-apache


3. 設定檔案



4  php array are call by value
https://stackoverflow.com/questions/879/are-php-variables-passed-by-value-or-by-reference


5. PHP PDO
https://www.slideshare.net/ryerryer/phpdb-72324578


6. php 7 news
https://www.php.net/manual/en/migration70.new-features.php#migration70.new-features.unicode-codepoint-escape-syntax







Apache 2.4

1. Setting File 

Position: conf/httpd.conf 


2. Seting Example 

2-1 

----------------------------- https://www.itread01.com/content/1546777631.html

Apache2.2升級到Apache2.4後httpd.conf的配置差別總結。


1、Listen設定的差別
設定監聽埠需指定IP
如Listen 88
需要改成
Listen 192.168.0.1:88


2、日誌紀錄設定的差別


RewriteLogLevel 改為 logLevel


LOGLEVEL設定第一個值是針對整個Apache的預設等級,後面對指定的模組修改此模組的日誌記錄等級


3、需載入更多的模組
開啟Gzip在apache2.4中需額外載入mod_filter
開啟SSL在apache2.4中需額外載入mod_socache_shmcb


4、許可權設定的差別


Apache2.2用Order Deny / Allow的方式,2.4用Require


apache2.2:
Order deny,allow
Deny from all


apache2.4:
Require local


此處比較常用的有如下幾種:
Require all denied
Require all granted
Require host domain
Require ip 192.168.1.1
Require local


要注意的是:如果在htaccess檔案中有設定的也要相應修改


5、Namevirtualhost 2.4中已經被刪除



2-2 Example

在 AWS EC2 裝好基本的 LAMP 環境之後,想設一下 Apache Virtual Host 設定
結果居然無法運作,查了一下才發現在 Apache 2.4.6 (或更之前) 有對這部份的設定做了一些調整
以下是簡易的筆記

1. NameVirtualHost*:80 這行已經廢除,不用再寫了
2. 原本的 http.conf 已經預設加上 IncludeOptional conf.d/*.conf
    所以可以把 Virtual Host 的設定獨立成另一隻檔案,我習慣命名為 vhosts.conf,放在 /etc/httpd/conf.d/vhosts.conf
3. <VirtualHost> 的調整
由原本的
<VirtualHost sample.com>
        DocumentRoot  /var/www/www_sample
        ServerName sample.com
        CustomLog logs/access_log combined
        DirectoryIndex  index.php index.html index.htm index.shtml
        <Directory "/var/www/www_sample">
            Options FollowSymLinks
            AllowOverride All
        </Directory>
</VirtualHost>

改為 
<VirtualHost *:80>
        DocumentRoot  /var/www/www_sample
        ServerName sample.com
        CustomLog logs/access_log combined
        DirectoryIndex  index.php index.html index.htm index.shtml
        <Directory "/var/www/www_sample">
            Options FollowSymLinks
            AllowOverride All
        </Directory>
</VirtualHost>



2-3  Remove  welcome page

https://linuxconfig.org/how-to-disable-default-apache-welcome-page-on-redhat-linux




2-4 Default Parameters  Ref https://kknews.cc/zh-tw/other/qorvg6b.html

配置文件位於:
[root@www ~]# vim /usr/local/http-2.4.23/conf/extra/httpd-default.conf

Timeout 5
推薦5 這個是 apache接受請求或者發出相應的時間超過這個時間斷開
KeepAlive On/Off KeepAlive
指的是保持連接活躍,換一句話說,如果將KeepAlive設置為On,那麼來自同一客戶端的請求就不 需要再一次連接,避免每次請求都要新建一個連接而加重伺服器的負擔。一般情況下,圖片較多的網站應該把 KeepAlive設為On。


原文網址:https://kknews.cc/other/qorvg6b.html







2-5 Virtual host ref ref

在 Apache 上設定 VirtualHost 是牙齒掉下來然後又腐化掉的問題,但這問題又久久才會處理一次,剛不小心出了一點小問題,於是稍微記錄一下提醒自己。
設定 VirtualHost 目的是使用同一個伺服器架設多個網站,當使用者以不同網域名稱連到該主機時, web server 會依據不同的目的網頁需求,回應不同的網頁內容



2-6 https://httpd.apache.org/docs/2.4/mod/core.html#directory
Office Document


2-7 2.4 New document

Core Enhancements

Run-time Loadable MPMs
Multiple MPMs can now be built as loadable modules at compile time. The MPM of choice can be configured at run time via LoadModule directive.
Event MPM
The Event MPM is no longer experimental but is now fully supported.
Asynchronous support
Better support for asynchronous read/write for supporting MPMs and platforms.
Per-module and per-directory LogLevel configuration
The LogLevel can now be configured per module and per directory. New levels trace1 to trace8 have been added above the debuglog level.
Per-request configuration sections
<If><ElseIf>, and <Else> sections can be used to set the configuration based on per-request criteria.
General-purpose expression parser
A new expression parser allows to specify complex conditions using a common syntax in directives like SetEnvIfExprRewriteCond,Header<If>, and others.
KeepAliveTimeout in milliseconds
It is now possible to specify KeepAliveTimeout in milliseconds.
NameVirtualHost directive
No longer needed and is now deprecated.
Override Configuration
The new AllowOverrideList directive allows more fine grained control which directives are allowed in .htaccess files.
Config file variables
It is now possible to Define variables in the configuration, allowing a clearer representation if the same value is used at many places in the configuration.
Reduced memory usage
Despite many new features, 2.4.x tends to use less memory than 2.2.x


2-8  Remove Index browser index 
https://www.itread01.com/content/1549475658.html
more clarn
https://www.tekfansworld.com/how-to-disable-apache-2-4-directory-browsing-on-ubuntu-16-04.html


2-9 Simple apach4 manipuate
http://igt.com.tw/5/linset/www1.htm


2-10 Scl apache 4
http://igofun.net/wordpress/2017/12/28/%E3%80%90centos-6%E3%80%91%E9%80%8F%E9%81%8E-scl-%E5%B0%87-apachehttpd-%E5%8D%87%E7%B4%9A%E5%88%B0-2-4-%E7%89%88/


2-11 Vshot 2

https://dywang.csie.cyut.edu.tw/dywang/rhce7/node78.html


2-12 apache management

https://blog.xuite.net/towns/hc/80213406-Apache%E5%AE%89%E8%A3%9D%E3%80%81%E8%A8%AD%E5%AE%9A%E8%88%87%E7%AE%A1%E7%90%86


2-13

https://dotblogs.com.tw/maplenote/2012/07/20/apache24_httpd_conf