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

2019年7月31日 星期三

centos 7

1. Change ssh Port 22

https://www.opencli.com/linux/centos-7-change-ssh-port-selinux-enable

2019年7月16日 星期二

hyper V

1. NetWork
https://dotblogs.com.tw/acelee/2018/07/18/191122

https://channel9.msdn.com/Series/Windows-Server-2012-Entry-Level/Windows-Server-2012-Entry-Level-5

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

2019年7月15日 星期一

Ruby

0. Ruby install On windows

0-1 下載安裝exe,地址:http://rubyinstaller.org/downloads/
原文網址:https://kknews.cc/tech/pg3lx8.html


下載 DEvKit 表示可擴充的套件



ref:1 2


0-1 RubyGems簡介

RubyGemsRuby的套件管理系統,讓你輕易安裝及管理Ruby函式庫。你可以在RubyGems上找到所有的Ruby開源套件。另外,讀者如果想找RubyRails有哪些好用的套件,也可以瀏覽看看The Ruby Toolbox,這個站依照套件的熱門程度排序,非常方便。

常用指令

gem -v 告訴你 RubyGems 的版本
gem update --system 升級RubyGems的版本
gem install gem_name 安裝某個套件
gem list 列出安裝的套件
gem update gem_name 更新最新版本
gem update 更新所有你安裝的Gems
gem install -v x.x.x gemname 安裝特定版本
gem uninstall gem_name 反安裝

ref 1

0-2 Require Method

https://kaochenlong.com/2016/05/01/require/

Notice
require 'rubygems' will adjust the Ruby loadpath allowing you to successfully require the gems you installed through rubygems, without getting a LoadError: no such file to load -- sinatra.

In Ruby 1.9 'require "rubygems"' happens automatically. In previous Rubies rubygems is not automatically required and you will get the error. Your best bet is to automatically type it in unless you are sure you are running always in 1.9+. 


0-3 Install test
gem install mail
gem install win32-service






1. Ruby  totorail

https://railsbook.tw/chapters/02-environment-setup.html
https://ourcodeworld.com/articles/read/270/how-to-create-an-executable-exe-from-a-ruby-script-in-windows-using-ocra
http://ruby-for-beginners.rubymonstas.org/built_in_classes/symbols.html
https://openhome.cc/Gossip/Ruby/index.html


2. Data structure

Array:
["A string", 1, true, :symbol, 2]

Hash
{ "one" => "eins", "two" => "zwei", "three" => "drei" }


3. Class



4. Block

ref 1

block是用來暫存及傳遞程式碼的地方
它本身不是物件(但有方法可以讓它變物件,最後說明)所以必須掛在別人身上(可能是別的方法、別的物件


@users.each do |u|
...
end