2018年7月10日 星期二

SSH登入 + FTP登入 google cloud說明

照這篇做可以使用FTP連線登入
https://sammy197.tw/4061/%E5%9C%A8gcp%EF%BC%88google-cloud-platform%EF%BC%89%E4%B8%8A%E9%80%8F%E9%81%8Eftp%E4%B8%8A%E5%82%B3%E6%AA%94%E6%A1%88/

權限設定請參考這篇
http://xtony77.logdown.com/posts/209067-ubuntu-notes-using-ssh-key-login

如果要用cmder使用密碼連入。

可以在Server上設定 ssh的允許密碼登入方式

cd /ctc/ssh
vi sshd_config

PasswordAuthentication yes 
PermitRootLogin yes
UsePrivilegeSeparation no

重新啟動
service ssh restart

在Server上需要設定root帳號

第一次設定root帳號需要打入密碼

sudo passwd root

輸入密碼,設定完畢。

--------------------------------------------------------------------------------------------------

在本地端的cmder使用
ssh root@ip

輸入root的密碼 就可以登入囉!


PS:如果出現Permission denied (publickey)
P請注意ssh資料夾的權限是否設定正確,不能設定成777

1.
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

2.
home/使用者/.ssh
chmod 600 ~/.ssh/authorized_keys

記得重啟
service ssh restart

2018年6月6日 星期三

Redis 安裝教學

在window下使用Redis
文章:http://www.runoob.com/redis/redis-install.html
文章:https://www.xiabingbao.com/php/2017/08/27/window-php-redis.html


1.到redis下載版本 並解壓縮
https://github.com/MicrosoftArchive/redis/releases

本次下載的是 C:\website\Redis-x64-3.2.100


2.CD到Redis目錄
//利用 Redis Desktop Manager 查看資料
//1.啟動
redis-server.exe redis.windows.conf

開啟另一個服務窗 

//2.連入redis

redis-cli -h host -p port -a password

redis-cli -h 127.0.0.1 -p 6379 -a "mypass"

redis-cli

//3.設定值
set myKey abc


//4.取得值
get myKey

PHP使用Redis擴展方法

一樣使用上面安裝Redis-x64-3.2.100

1.下載php ext擴展dll

php_igbinary.dll和php_redis.dll
(1) php_igbinary.dll: php_igbinary-2.0.1-5.6-ts-vc11-x64.zip
https://windows.php.net/downloads/pecl/releases/igbinary/2.0.1/

(2).php_redis.dll:php_redis-2.2.7-5.6-ts-vc11-x64.zip
https://windows.php.net/downloads/pecl/releases/redis/2.2.7/

2.將兩個dll檔案放到php/ext下,並在php.ini 追加以下兩條

extension=php_igbinary.dll
extension=php_redis.dll

3.重啟apache
c:\Apache24\bin\httpd -k restart

4.創建一個test.php檔案,測試是否擴展成功
phpinfo();

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
echo "Server is running: " . $redis->ping();


畫面上應該會顯示phpinfo()確定是不是有redis資訊且顯示
Connection to server sucessfullyServer is running: +PONG

2018年5月23日 星期三

Laravel呼叫方法

說明:https://stackoverflow.com/questions/28573860/laravel-requestall-should-not-be-called-statically/28574081

輔助方法:https://docs.laravel-dojo.com/laravel/5.2/helpers

1. static方法
use Request;

public static function test(Request $request)
{ 
    $data= Request::all();
}


2.  一般方法
use Illuminate\Http\Request;

public static function test(Request $request)
{
   $age = \Request::input('age');
   $data = $request->all();
}



3.輔助方法

use Illuminate\Http\Request;

public static function test(Request $request)
{
    $data= request()->all();
}



2018年5月21日 星期一

mysql常用指令

Mysql需要啟動服務

cd到mysql bin底下有mysql執行檔的地方

1.安裝
mysqld install

2.啟動服務
net start mysql

3.停止服務
net stop mysql

4.mysql 遠端連線  -u:mysql account   -h:ip   -P:port
mysql -uroot -p -hlocalhost -P33600

進入 mysql> 底下下指令

1.顯示DB
show databases;

2.使用databases mydatabase
use mydatabase;

3.查詢 task 底下的tabel mytable
select * from mytable;

4.顯示資料庫中的所有table
 show tables from mytable;

5.顯示資料表的結構
desc mytable;

6.顯示狀態
status;


2018年5月16日 星期三

cmder 在windows下 中文問題

參考網址:http://www.rehack.cn/techshare/devtools/842.html

1.
在cmder的資料夾底下 cmder/config/user-aliases
追加以下代碼

l=ls --show-control-chars
la=ls -aF --show-control-chars
ll=ls -alF --show-control-chars
ls=ls --show-control-chars -F


2.
Settings > Startup > Environment
追加
set LANG=zh_CN.utf-8


3.
修改cmder資料夾底下 vendor/clink.lua文件
把20行set_prompt_filter這個函數調整成


function set_prompt_filter()
    -- get_cwd() is differently encoded than the clink.prompt.value, so everything other than
    -- pure ASCII will get garbled. So try to parse the current directory from the original prompt
    -- and only if that doesn't work, use get_cwd() directly.
    -- The matching relies on the default prompt which ends in X:\PATH\PATH>
    -- (no network path possible here!)
    local old_prompt = clink.prompt.value
    local cwd = old_prompt:match('.*(.:[^>]*)>')
    if cwd == nil then cwd = clink.get_cwd() end
    
    -- environment systems like pythons virtualenv change the PROMPT and usually
    -- set some variable. But the variables are differently named and we would never
    -- get them all, so try to parse the env name out of the PROMPT.
    -- envs are usually put in round or square parentheses and before the old prompt
    local env = old_prompt:match('.*%(([^%)]+)%).+:')
    -- also check for square brackets
    if env == nil then env = old_prompt:match('.*%[([^%]]+)%].+:') end
    
    -- build our own prompt
    -- orig: $E[1;32;40m$P$S{git}{hg}$S$_$E[1;30;40m{lamb}$S$E[0m
    -- color codes: "\x1b[1;37;40m"
    local cmder_prompt = "\x1b[1;32;40m{cwd} {git}{hg} \n\x1b[1;30;40m{lamb} \x1b[0m"
    cmder_prompt = string.gsub(cmder_prompt, "{cwd}", cwd)
    if env == nil then
        lambda = "λ"
    else
        lambda = "("..env..") λ"
    end
    clink.prompt.value = string.gsub(cmder_prompt, "{lamb}", lambda)
end