WordPress 免裝外掛,啟用https SSL 保證成功!

WordPress 免裝外掛,啟用https SSL 保證成功!

很簡單卻搞了我很久的一個功能!

最近GOOGLE大興旗鼓的呼籲網站站長使用SSL安全連線,就連Chrome都參一腳,把非SSL的網站增加「不安全」標章…

上網查了很多Wordpress啟用ssl的相關教學,不是用外掛就是改一堆,最後還是失敗,不是首頁進不去,就是只能進去控制台。

研究了幾天,做了幾次測試,發現,原來Wordpress啟用SSL這麼簡單?!

最重要的步驟就是在wp-config.php 最上面加上「$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
$_SERVER['HTTPS'] = 'on';

然後他就好了…………………………!!!

接下來就是進控制台進行檔案資料修改。

沒錯就是這麼簡單= =

Nginx Access-Control-Allow-Origin 問題

Nginx Access-Control-Allow-Origin 問題

遇到了把bootstarp 放到別的主機時,會使用不了glyphicons圖示的問題,
解決方法如下: 以Nginx為例


location / {
if ($request_method = 'OPTIONS') {
        add_header 'Access-Control-Allow-Origin' '*';
        #
        # Om nom nom cookies
        #
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        #
        # Custom headers and headers various browsers *should* be OK with but aren't
        #
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
        #
        # Tell client that this pre-flight info is valid for 20 days
        #
        add_header 'Access-Control-Max-Age' 1728000;
        add_header 'Content-Type' 'text/plain charset=UTF-8';
        add_header 'Content-Length' 0;
        return 204;
     }
     if ($request_method = 'POST') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
     }
     if ($request_method = 'GET') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
     }
}
WordPress MultiUser MultiSite 多用戶部落格使用multi-db 將資料庫分開

WordPress MultiUser MultiSite 多用戶部落格使用multi-db 將資料庫分開

有在使用WordPress MultiSite (WP多用戶站點) 的站長都知道,其資料庫是一個痛!
因為他把用戶的資料表全部塞在同一個資料庫裏面,會造成管理時,光等phpmyadmin列出全部資料表,電腦就當機了!

以我來說,手上有大概一千多位用戶,但資料表加起來竟然有一萬三千八百多個!光是磁碟尋找檔案就耗很多時間了,更別談效率。
wpmulti-db

上圖13858是未使用multi-db之前通通擠在一起的資料表,經過multi-db有系統的規劃後,可以看到下面的列表他拆成256個資料庫,在分門別類把每個資料表移過去。
multi-db允許我們建立16/256/4096個資料庫,用戶建立時資料時會被散列納入相應的資料庫中,這樣就實現了用戶數量級的躍升。

譬如原先我們的是在一個資料庫擠好幾萬個資料表,幾千個用戶,但multi-db之後其承載能力,理論上獲得了×16、×256、×4096的倍率。
當然我們知道其實這不是簡單的乘數效應,因為系統的短板會在不同時期出現在不同的環節,比如blogs.dir的文件數理論極限,比如單一台主機不做負載均衡時單機的負載能力上限,
比如靜態文件請求產生的資源消耗等等。

但是,通過multi-db,我們就可以輕鬆跨越一個資料庫的海量資料表!
此外,對於有特殊需求的用戶,從資料庫穩定性考慮也可以為他們單獨建個別的資料庫。因為不同的資料可以存在於不同的資料庫內,這一切都是可設置的。

不過目前multi-db並非免費,必須至https://premium.wpmudev.org/project/multi-db/ 購買。

以下是安裝心得。

1.不需使用WP普通外掛的方式安裝,他是採檔案上傳後即可運行。
2.先建立你要的資料庫,舉例我這次採用切割成256個資料庫,所以先透過phpmyadmin建好256個資料庫,其建立規則為
CREATE DATABASE `資料庫名稱_00` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
一直到
CREATE DATABASE `資料庫名稱_ff` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
大概會長得像這樣
CREATE DATABASE `wpmudb_ff` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

由於是16進位,所以00(零零)~ff為256,可以自己寫個php 迴圈快速產生指令
for ($i=0;$i<=255;$i++){
echo “CREATE DATABASE `資料庫名稱_”.dechex($i).”` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
“;
}
還要加上主要網誌的資料庫
CREATE DATABASE `資料庫名稱_global` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

※注意,上述語法 0~e 只有一位,前面自行補上0

3.建立好資料庫後,開始要修改檔案了,先產生資料庫的管理權限,一樣產生256個
add_db_server(‘編號’, ‘dc1′, 1, 1,”,’網站IP’, ‘資料庫名稱_編號’, ‘資料庫帳號’, ‘資料庫密碼’);
大概會長得像這樣
add_db_server(’00’, ‘dc1′, 1, 1,”,’111.111.111.111’, ‘wpmudb_00’, ‘admin’, ‘123456’);
別忘了幫主要網誌資料庫也加上密碼
add_db_server(‘global’, ‘dc1′, 1, 1,”,’111.111.111.111’, ‘wpmudb_global’,  ‘admin’, ‘123456’);

將產生出來的add_db_server複製貼上至db-config.php
貼到
//————————————————————————//
//—DB Servers———————————————————–//
//————————————————————————//
// Database servers grouped by dataset.
// R can be 0 (no reads) or a positive integer indicating the order
// in which to attempt communication (all locals, then all remotes)
//
// Usage: add_db_server(DS, DC, READ, WRITE, HOST, LAN_HOST, NAME, USER, PASS)
// EX: add_db_server(‘global’, ‘dc1′, 1, 1,’global.mysql.example.com:3509′,’global.mysql.example.lan:3509’, ‘global-db’, ‘globaluser’, ‘globalpassword’);
//
// Note: you can also place this section in a file called db-list.php in wp-content
// EX: add_db_server(‘global’, ‘dc1′, 1, 1,’global.mysql.example.com:3509′,’global.mysql.example.lan:3509’, ‘global-db’, ‘globaluser’, ‘globalpassword’);
這排下面

————-
4.其他細項修改
//—DB Scaling———————————————————–//
//————————————————————————//
// 16,256,4096
define (‘DB_SCALING’, ‘256’); #因為我用256 所以填256

//————————————————————————//
//—DC IPs—————————————————————//
//————————————————————————//
// Usage: add_dc_ip(IP, DC)
// EX: add_dc_ip(‘123.123.123.’, ‘dc1’);
add_dc_ip(‘111.111.111.111.’, ‘dc1’); #改成網站IP

//————————————————————————//
//—Global Tables——————————————————–//
//————————————————————————//
// Do not include default global tables
// Leave off base prefix (eg: wp_)
// You don’t really have to register these, they will work fine without.
// However registering at least your busiest ones might shave a few milliseconds off by avoiding some regexes.
//
// Usage: add_global_table(TABLE_NAME)
// EX: add_global_table(‘something’);
add_global_table(‘wpmudb_global’); #設定主要網站的資料庫名稱

5.修改move-blogs.php
//————————————————————————//
//—Config—————————————————————//
//————————————————————————//

///DB Settings
$dbname = “原本WP的資料庫名稱”; //This is your current database
$blog_table_prefix = ‘wp_’; //Prefix of your wpmu blog tables, most likely this won’t need to be changed
$newdb_prefix = ‘新的資料庫名稱_’; //本範例應填上 wpmudb

//We need info to connect to the databases
$dbhost = ‘localhost’;
$dbuname = ‘資料庫帳號’;
$dbpass = ‘資料庫密碼’;

//How many db’s are you moving into (16, 256, or 4096)?
$db_scaling = ‘256’; #我建立256個

到這邊就改完了!!

開始準備上傳,
把db.php、db-config.php 上傳至/wp-content/裡面
把move-blogs.php、fix-db-encoding.php 上傳至/wp-content/script/裡面 script資料夾自己建

執行http://網址/wp-content/script/move-blogs.php 會看到下圖,因為我已經完成轉換所以右邊是顯示table in new db
wpmulti-db2

如果設定正確,前面的資料庫也建立正確,此頁面不會出現任何ERROR,如果有ERROR的話 就照他的ERROR去解。
接著按最上面的5.To start the copy process click here 他就會開始跑了!我一萬三千八百多個大概要10分鐘才會結束。

6.最後
做完上述動作,以後系統都會以多資料庫的方式運行,即使增加新用戶也會自動歸類,不需要再做其他設定!非常簡單方便。
——————————————————————————————–

There are using WordPress MultiSite (WP multi-user site) owners are aware that their library is a pain!
Because when he stuffed all the user table in the same database which will cause management, light, etc. phpmyadmin all the information listed in the table, the computer crashed!

I, for one, have got probably more than a thousand users, but add up table yet there are more than thirteen thousand eight hundred! Find files on disk alone consume a lot of time, let alone efficient.

wpmulti-db

The figure 13858 is not used before the multi-db table all crowded together, after a multi-db systematic planning, you can see the list below him split into 256 databases in different categories each table move past.
multi-db allows us to establish 16/256/4096 a database, the user profile will be established when the hash included in the corresponding database, thus achieving the level of the number of users jumped.

For example, originally we are tens of thousands crowded table, thousands of users in a database, but after a multi-db its carrying capacity, theoretically gained × 16, × 256, × 4096 magnification.
Of course, we know that in fact this is not a simple multiplier effect, because the short-board system will appear at different times in different areas, such as the number of files blogs.dir theoretical limit, such as single hosts do load balancing load capacity stand-alone ceiling
For example, the static file requests generated resource consumption and so on.

However, by multi-db, we can easily span a massive database table!
In addition, for users with special needs, from the library to be built in consideration of the stability of individual repository for them separately. Because different materials can exist in different data library, all this can be set.

But the current multi-db is not free, you must purchase to https://premium.wpmudev.org/project/multi-db/.

The following are the installation experience.

1. WP without using ordinary plug mounted, he was taken to run after the file is uploaded.
2. First you have to establish a repository, for example I use this cut 256 database, so the first built 256 database through phpmyadmin, which establish rules
CREATE DATABASE `library name _00` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
until
CREATE DATABASE `library name _ff` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Probably it would look like this
CREATE DATABASE `wpmudb_ff` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

Because it is hexadecimal, so 00 (2003) ~ ff 256, can write a php loop quickly generate instruction
for ($ i = 0; $ i <= 255; $ i ++) {
echo “CREATE DATABASE` library name _ “dechex ($ i)” `DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci..;
“;
}
Plus major blog repository
CREATE DATABASE `library name _global` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

※ Note that the above grammar 0 ~ e only one, in front of their own make up 0

3. After the establishment of a good database, start to modify the file, the first generation of database administrative privileges, the same generation 256
add_db_server ( ‘No’, ‘dc1’, 1, 1, ”, ‘site IP’, ‘Database name _ Number’, ‘database account’, ‘Database Password’);
Probably it would look like this
add_db_server (’00 ‘,’ dc1 ‘, 1, 1,’ ‘,’ 111.111.111.111 ‘,’ wpmudb_00 ‘,’ admin ‘,’ 123456 ‘);
Do not forget to help the main blog database also add password
add_db_server ( ‘global’, ‘dc1’, 1, 1, ”, ‘111.111.111.111’, ‘wpmudb_global’, ‘admin’, ‘123456’);

Will have to copy and paste out of add_db_server db-config.php
Paste
// ———————————————— ———————— //
// — DB Servers ——————————————- // —————-
// ———————————————— ———————— //
// Database servers grouped by dataset.
// R can be 0 (no reads) or a positive integer indicating the order
// In which to attempt communication (all locals, then all remotes)
//
// Usage: add_db_server (DS, DC, READ, WRITE, HOST, LAN_HOST, NAME, USER, PASS)
// EX: add_db_server ( ‘global’, ‘dc1’, 1, 1, ‘global.mysql.example.com: 3509’, ‘global.mysql.example.lan: 3509’, ‘global-db’, ‘globaluser ‘,’ globalpassword ‘);
//
// Note: you can also place this section in a file called db-list.php in wp-content
// EX: add_db_server ( ‘global’, ‘dc1’, 1, 1, ‘global.mysql.example.com: 3509’, ‘global.mysql.example.lan: 3509’, ‘global-db’, ‘globaluser ‘,’ globalpassword ‘);
This row below

————-
4. Other modifications breakdown
// — DB Scaling ——————————————- // —————-
// ———————————————— ———————— //
// 16,256,4096
define ( ‘DB_SCALING’, ‘256’); # 256 because I used it to fill 256

// ———————————————— ———————— //
// — DC IPs ——————————————- ——————– //
// ———————————————— ———————— //
// Usage: add_dc_ip (IP, DC)
// EX: add_dc_ip ( ‘123.123.123.’, ‘Dc1’);
add_dc_ip ( ‘111.111.111.111.’, ‘dc1’); # change website IP

// ———————————————— ———————— //
// — Global Tables ——————————————- ————- //
// ———————————————— ———————— //
// Do not include default global tables
// Leave off base prefix (eg: wp_)
// You do not really have to register these, they will work fine without.
// However registering at least your busiest ones might shave a few milliseconds off by avoiding some regexes.
//
// Usage: add_global_table (TABLE_NAME)
// EX: add_global_table ( ‘something’);
add_global_table ( ‘wpmudb_global’); # set the main site database name

5. Modify the move-blogs.php
// ———————————————— ———————— //
// — Config ——————————————– ——————- //
// ———————————————— ———————— //

/// DB Settings
$ Dbname = “original WP repository name”; // This is your current database
$ Blog_table_prefix = ‘wp_’; // Prefix of your wpmu blog tables, most likely this will not need to be changed
$ Newdb_prefix = ‘_ new database name’; // This example should fill wpmudb

// We need info to connect to the databases
$ Dbhost = ‘localhost’;
$ Dbuname = ‘database account’;
$ Dbpass = ‘Database Password’;

// How many db’s are you moving into (16, 256, or 4096)?
$ Db_scaling = ‘256’; # I created 256

To change over to the side !!

Begin uploading,
The db.php, db-config.php uploaded to / wp-content / inside
The move-blogs.php, fix-db-encoding.php uploaded to / wp-content / script / folder inside the script to build their own

Executive http: // URL /wp-content/script/move-blogs.php will see the following figure, because I have done so on the right is a graph showing the conversion table in new db

wpmulti-db2

If set up properly, the front of the library also established correctly, this page will not be any ERROR, if ERROR, then did as he had gone to ERROR.
Followed by the top 5.To start the copy process click here he’ll start running! I was more than thirteen thousand eight hundred take about 10 minutes before the end.

6. Finally
To complete the operation, after the system will be in multi-mode operation of the database, even if the increase in new users will automatically categorize not need to do other settings! Very simple and convenient.

CheapSSL COMODO 購買心得

CheapSSL COMODO 購買心得

1.產生CSR
openssl req -nodes -newkey rsa:2048 -keyout domin.key -out domin.csr

2.收到四個憑證,分別將其中三個打開,複製內容後另存 domin.ca-bundle
複製貼上的順序是
www_START_com.crt
COMODORSADomainValidationSecureServerCA.crt
COMODORSAAddTrustCA.crt
AddTrustExternalCARoot.crt

3.在httpd-ssl.conf修改
SSLEngine on
SSLCertificateKeyFile 自己產生的domin.key的位置
SSLCertificateFile STAR_domin.crt
SSLCertificateChainFile domin.ca-bundle

打完收工。

補充:RapidSSL 收到後的準備
不需要做合併,只要修改如下
SSLEngine on
SSLCertificateKeyFile 自己產生的domin.key的位置
SSLCertificateFile ServerCertificate.cer
SSLCertificateChainFile /CACertificate-1.cer

搞定!

Apache SSL + SNI 一個IP,多個SSL證書

Apache SSL + SNI 一個IP,多個SSL證書

OpenSSL_logo

這是一周血和淚換來的心得分享..
工作背景:CentOS、Apache2(自編及內建都測試過)
OpenSSL is not built with support for TLS extensions

普通的Apache+mod_ssl+openssl 即可完成網站的SSL加密作業。
但如果主機內有虛擬主機,安裝第二張SSL證書時,會發現怎樣裝都是錯的,主機無法識別第二張以後的證書!
這是因為OpenSSL預設的認證方式是IP-BASE,一個IP就一個證書。

想要解決這個方式為有更新OpenSSL 到0.9.8J 以後的版本,有支援SNI模式(Server Name Indication) 白話文就是用網址來識別証書。

介紹
早期的 SSLv2 根據經典的公鑰基礎設施 PKI(Public Key Infrastructure) 設計,它默認認為:一台服務器(或者說一個IP)只會提供一個服務,所以在 SSL 握手時,服務器端可以確信客戶端申請的是哪張證書。
但是讓人萬萬沒有想到的是,虛擬主機大力發展起來了,這就造成了一個 IP 會對應多個域名的情況。解決辦法有一些,例如申請泛域名證書,對所有 *.yourdomain.com 的域名都可以認證,但如果你還有一個 yourdomain.net 的域名,那就不行了。
在 HTTP 協議中,請求的域名作為主機頭(Host)放在 HTTP Header 中,所以服務器端知道應該把請求引向哪個域名,但是早期的 SSL 做不到這一點,因為在 SSL 握手的過程中,根本不會有 Host 的信息,所以服務器端通常返回的是配置中的第一個可用證書。因而一些較老的環境,可能會產生多域名分別配好了證書,但返回的始終是同一個。
既然問題的原因是在 SSL 握手時缺少主機頭信息,那麼補上就是了。
SNI(Server Name Indication,意為“服務器名稱指示”) 定義在 RFC 4366,是一項用於改善 SSL/TLS 的技術,在 SSLv3/TLSv1 中被啟用。它允許客戶端在發起 SSL 握手請求時(具體說來,是客戶端發出 SSL 請求中的 ClientHello 階段),就提交請求的 Host 信息,使得服務器能夠切換到正確的域並返回相應的證書。
要使用 SNI,需要客戶端和服務器端同時滿足條件,幸好對於現代瀏覽器來說,大部分都支持 SSLv3/TLSv1,所以都可以享受 SNI 帶來的便利。

重點
簡單的介紹完畢,這邊我直接白話文講。
Q1.如何讓Apache進行HTTPS加密作業?
A1:安裝openssl並且啟用mod_ssl (網路上教學一堆)
Q2.主機內有很多虛擬網站,每個網站都想要有SSL認證,但怎麼裝都失敗,點解?
A2.因為你主機沒有啟用openssl的SNI功能

好啦,看到這邊就是知道,只裝完openssl和mod_ssl是不夠的,還要啟用SNI的功能才可以讓主機支援多個SSL!
一般CentOS5.X內建的openssl版本大概在0.9.8e,但很抱歉,最少要到0.9.8J 以後的版本才有SNI。

所以步驟如下
1.更新Openssl至0.9.8j以後或最新
2.啟用SSL虛擬網站,在httpd-ssl.conf 設定NameVirtualHost
3.在httpd-ssl.conf SSLStrictSNIVHostCheck off ←這段要自己加

基本上這樣就完工前置作業了,剩下比照一般SSL網站新增即可!

慢著… 有這麼簡單的話,我還需要一周的血和淚測試嗎?當然沒有,因為你八成會遇到下列一個問題!
Q3.yum update openssl 只到0.9.8e 如何手動更新到最新?
Q4.就算openssl更新到最新了,apache也設定完了,重新啟動apache時出現「OpenSSL is not built with support for TLS extensions」 一樣GG?

這兩個問題是相對關係的,openssl沒有更新到最新的話,設定完apache會出現Q4的問題,就算更新到最新如果依然出現Q4的問題就表示opensll更新不確實。
若是自編的Apache則請在更新完OPENSSL後再重新編譯一次Apache

手動更新OpenSSL教學 (這邊是精華,一周換來心得,你看到這邊文章真的賺到,網路上無解)
0.先用yum 安裝內建的openssl
1.去openssl官網下載最新的壓縮檔然後解壓縮,進入該目錄
2.執行「./config –prefix=/usr –openssldir=/usr/local/openssl enable-tlsext shared」 請一字不漏包含符號的執行
3.接著就 make install
4.完成安裝查看opensll版本 openssl version 這時應該就出現最新版的版本號了!

好啦,如果你是用內建的apache,到這邊已經完工,電腦重開後應該就OK,但如果你是自編的apache,這時在編譯apache時需要增加額外參數,參考如下
–enable-ssl –with-ssl=/usr/local/openssl
然後PHP也要重新編譯讓他支援openssl,編譯參數如下「 –with-openssl」
到這邊才算正式完工!

最後記得防火牆打開443啊!!
藍色部分就是我試了一周後試出來的心得,非常珍貴………
為了紀念我那一周的大腦細胞,決定寫下這篇文章
—————————————————————

This week in exchange for the blood and tears of experience to share ..
Working Background: CentOS, Apache2 (built-in self and are tested)
OpenSSL is not built with support for TLS extensions

Common Apache + mod_ssl + openssl to complete the job site SSL encryption.
But if there is a host on a virtual host, when you install the second SSL certificate, you will find what is wrong means, the host does not recognize the second or subsequent certificate!
This is because the OpenSSL default authentication method is IP-BASE, a IP on a certificate.

Want to solve this way has updated OpenSSL to 0.9.8J later, there is support SNI mode (Server Name Indication) vernacular is to use the URL to identify the certificate.

Introduction
According to the classical early SSLv2 Public Key Infrastructure PKI (Public Key Infrastructure) design, it defaults to that: a server (or an IP) will only provide a service, so the SSL handshake, the server can be sure that the client application which certificates.
But people never imagined that web hosting vigorously developed, which resulted in a situation corresponding to a plurality of IP will domain names. Some solutions, such as pan-domain certificate application, all * .yourdomain.com domain can be authenticated, but if you have a yourdomain.net domain, it is not.
In the HTTP protocol, the request of the domain name as the host header (Host) on the HTTP Header, so the server knows which domain should be directed to the request, but early SSL can not do this, because the SSL handshake process, Host will not have the information, so the server-side configuration is usually returned in the first available certificate. Thus some older environment, may produce multi-domain certificates are a good job, but the return is always the same.
Since the cause of the problem is the lack of host header information when SSL handshake, then fill it wants.
SNI (Server Name Indication, meaning “Server Name Indication”) is defined in RFC 4366, is an improvement for SSL / TLS technology is enabled in SSLv3 / TLSv1 in. It allows a client to initiate SSL handshake request (specifically, the client sends SSL requests ClientHello stage), Host submitted the requested information so that the server can switch to the correct field and returns the corresponding certificates.
To use the SNI, requires the client and the server at the same time to meet the conditions, but fortunately for modern browsers, most support SSLv3 / TLSv1, so you can enjoy the convenience brought by SNI.

Emphasis
Simple introductions, here I speak directly to the vernacular.
Q1. How to make Apache for HTTPS encryption work?
A1: openssl installed and enabled mod_ssl (teaching a bunch on the web)
Q2. There are many virtual hosts sites, each would like to have an SSL certificate, but how loaded fail, Why?
A2. Because you have not enabled the openssl SNI host function

Well, see here is to know, only Bahrain openssl and mod_ssl is not enough, but also to enable SNI functions can allow the host to support multiple SSL!
General CentOS5.X probably built openssl version 0.9.8e, but unfortunately, at least to have a later version to 0.9.8J SNI.

Therefore, the following steps
1. Update Openssl to 0.9.8j or later date
2. Enable SSL virtual website, httpd-ssl.conf set NameVirtualHost
3. httpd-ssl.conf SSLStrictSNIVHostCheck off ← This add it myself

This basically completed the pre-work, and the rest can be added cf. general SSL site!

Wait … there are so simple, I still need a week to test blood and tears? Of course not, because you’ll probably experience one problem!
Q3.yum update openssl 0.9.8e only how to update to the latest manual?
Q4. Even if the latest update to the openssl, apache also set finished, there ‘OpenSSL is not built with support for TLS extensions “as GG when you restart apache?

These two issues are relatively relations, openssl is not updated to the latest case, the set will be complete apache Q4 problems, even if the latest update to the problems still arise Q4, says opensll update untrue.
If the self-made Apache please recompile Apache again after the update finished OPENSSL

Manually update the OpenSSL teaching (here is the essence of a week in exchange for experience, here you see the article really earn, no solution on the web)
0. The first use yum install built-openssl
1. go openssl official website to download the latest zip file and unzip into the directory
2. Run “./config -prefix = / usr -openssldir = / usr / local / openssl enable-tlsext shared” Please execute verbatim contain symbols
3. then make install
4. Complete the installation view opensll version openssl version should then appear on the latest version of the version number!

Well, if you are using the built-in apache, to the side has been completed, the computer should be re-opened after it OK, but if you are self-compiled apache, then compile apache needed additional parameters, refer to the following
“-enable-Ssl -with-ssl = / usr / local / openssl”
Then recompile PHP should let him support openssl, compiled the following parameters “-with-openssl”
To be considered formally completed here!

Finally, remember to turn on the firewall 443 ah !!
Blue part is I tried out a week after the trial experience, very precious ………
To commemorate the week of brain cells I decided to write this article

vsftp 無法取得目錄清單

vsftp 無法取得目錄清單

很久沒有重新安裝CentOS,今天再次嘗試後出現了 Vsftp無法取得目錄清單的問題。
明明已經開啟21Port,也可以成功連線,但就是無法取得目錄清單。
原來是iptables沒有設定好!解決方法如下:
vi /etc/sysconfig/iptables-config
IPTABLES_MODULES=”ip_nat_ftp ip_conntrack_ftp”# 加入模組即可!兩個模組中間有空白鍵隔開!

Try it!

關西機場到大阪 或 到京都 以及樂桃航空行李合併問題 解決方式

關西機場到大阪 或 到京都 以及樂桃航空行李合併問題 解決方式

Kyoto-Kiyomizudera,_Japan

從關西機場到大阪市內可以有兩個選擇:
1.搭乘はるか號 http://kanku.mi-ktt.ne.jp/ 沿途停靠:米原駅、草津駅、京都駅、新大阪駅、西九条駅、天王寺駅、関西空港駅
如果飯店在梅田的話,可以考慮搭乘,但票價比較貴!
如果要去京都的話,直接搭這班最方便。

2.搭乘南海電鐵 mak_exp http://www.nankai.co.jp/

沿途停靠:關西機場、臨空城、泉佐野、貝塚、岸和田、春木、泉大津、羽衣、堺、天下茶屋、新今宮、難波
如果飯店在市中心的話,可以考慮搭南海電鐵道難波後在轉地下鐵即可。

樂桃航空行李合併問題:
問題:同一張訂單,各自都有買20公斤,一人行李裝到15公斤,另一人行理裝到25公斤,是否可以?
回答:經過2015-08-15 實地測試,由大阪飛回台北,可以。

php 手機上傳照片後 會自動旋轉 方向問題

php 手機上傳照片後 會自動旋轉 方向問題

最近在處理從手機上傳照片或圖片後,發現當手機是用直的拍時,上傳後會變成旋轉90度的照片。
上網爬了一下,國外已經有大神寫出相關函式來處理這個問題。
函式如下:
//上傳圖片旋轉
function image_fix_orientation($path){
$image = imagecreatefromjpeg($path);
$exif = exif_read_data($path);

if (!empty($exif[‘Orientation’])) {
switch ($exif[‘Orientation’]) {
case 3:
$image = imagerotate($image, 180, 0);
break;
case 6:
$image = imagerotate($image, -90, 0);
break;
case 8:
$image = imagerotate($image, 90, 0);
break;
}
imagejpeg($image, $path);
}
}

之後再呼叫函式即可處理旋轉的問題

image_fix_orientation($path);

打完收工

泰國叫計程車 攻略。使用GrabTaxi叫車 免喊價、免被當羊宰!

泰國叫計程車 攻略。使用GrabTaxi叫車 免喊價、免被當羊宰!

前陣子在泰國待了一段時間,但泰國計程車有個特色,就是每個車子頂頭都掛「跳錶」但實際上一攔下後,他就會問你地點跟你喊價!不是漫天開價就是太近不去、太遠不去 很麻煩。根據自己的經驗通常要攔到第三台車已上才有計程車願意跳錶載客。

後來我查到一個APP軟體「GrabTaxi」根據官網介紹他是新加坡開發的軟體,專門在東南亞使用,有點像Uber,下面是更多介紹

16625186706_d719ea039c_b

「目前泰國曼谷可用的計程車呼叫服務,包括:GrabTaxi(新加坡)、Easy Taxi(巴西)、Uber(美國)等多項國外引進的叫車服務,以及即將在2015年上路的本土All Thai Taxi(泰國)叫車服務,大抵都是利用智慧手機的定位與溝通功能,招募司機與媒合乘客搭乘。

其中,2012年發源自新加坡的GrabTaxi,可說是目前東南亞地區最火紅的叫車服務,目前已在新加坡、馬來西亞、菲律賓、印尼、越南與泰國等6個國家推出,算是泰國曼谷與芭達雅兩地發展最為成功的叫車服務。」

特色:不用喊價,統一跳錶,跳錶的方式是直接用地圖點你的位置和終點站,透過MAP算出里程計價,再加40銖服務費。馬上跟你說多少錢你再決定要不要叫車。也會紀錄你的叫車紀錄,個人覺得滿安全又實用的!!

2015年6月,經過測試,一些地區使用GrabTaxi的計程車數量:
曼谷:約一百台計程車
巴達雅:約十台計程車
華欣:零台

附上一些在泰國時的照片:)

2015-06-07 20.10.00 2015-06-08 18.58.17 2015-06-16 16.05.05 2015-06-16 16.05.24 2015-06-17 17.21.51