Thứ Tư, 11 tháng 2, 2009

Cách cài đặt apache mod_ssl trên windows

Đây là liên kết tới trang tutorial



Nội dung cơ bản như sau (đã thành công với phiên bản 2.2.8)

1. Cài đặt apache http server (2.x, 1.3.x không sử dụng được ssl)

2. Sử dụng openssl (có sẵn trong thư mục bin của apache)

copy ssleay32.dll and libeay32.dll vào thư mục system 32

tìm file openssl.cnf (có biểu tượng của window dialup) trong thư mục conf, hoặc download mẫu file openssl.cnf ở đây (nếu không thấy trong thư mục conf của apache) http://tud.at/programm/openssl.cnf

3. Tạo certificate : từ thư mục bin của apache (trong chế độ command line), lần lượt sử dụng các lệnh sau

openssl req -config $path/openssl.cnf -new -out my-server.csr
với $path là đường dẫn tới file openssl.cnf
my-server.csr là tên file output


openssl rsa -in privkey.pem -out my-server.key

openssl x509 -in my-server.csr -out my-server.cert -req -signkey my-server.key -days 365

openssl x509 -in my-server.cert -out my-server.der.crt -outform DER

Ok, lúc này trong thư mục bin của apache xuất hiện 2 tệp tin my-server.key và my-server.cert, bạn có thể giữ nguyên đó hoặc copy vào thư mục khác tùy ý, nhưng phải nhớ đường dẫn đến để thực hiện tiếp bước 4

4. Cấu hình apache httpd.conf

Mở chức năng ssl (mod_ssl.so)
Tìm tới dòng
#LoadModule ssl_module modules/mod_ssl.so
và đơn giản là bỏ dấu # (chú thích ở đầu đi)
LoadModule ssl_module modules/mod_ssl.so

Thêm vào hoặc sửa thông tin (nếu đã có sẵn)

<virtualhost www.my-server.dom:443> 
SSLEngine On 
SSLCertificateFile $path/my-server.cert 
SSLCertificateKeyFile $path/my-server.key 
</virtualhost>

#với chú ý, www.my-server.dom phải được thay bằng address của website của bạn, 
và $path là đường dẫn tới nơi chứa 2 file .cert và .key tạo ra bởi openssl 
How to config The Apache + SSL on Win32 SSL, apache, window

Thứ Sáu, 6 tháng 2, 2009

ISS rewrite with cakePHP

Hi,

I have read a lot of messages about running Cake PHP on IIS webserver. I was able to make it working using IIS_Rewrite Lite (http://www.isapirewrite.com/) with the following environment/settings/changes:

1. Create a new website on IIS pointing to /app/webroot folder. 2. Install IIS_Rewrite Lite and configure the httpd.ini file as follows:

[ISAPI_Rewrite]

RewriteCond (?!.*STATIC_REWRITE).* RewriteRule ^(.*)$ /index.php?url=$1 [L]

3. Enable the IIS_Rewrite Lite in the IIS ISAPI Filters. 4. Open the /app/webroot/index.php file and replace the all the lines from "require CORE_PATH.'cake'.DS.'bootstrap.php';" with the following code:

/* IIS Workaround */ if (isset($_GET['url']) && preg_match('/Microsoft-IIS/i', $_SERVER['SERVER_SOFTWARE']) && preg_match('/\?(.*)$/si', $_GET['url'], $matches)) { parse_str($matches[1], $_GET); } unset($matches); /* /IIS Workaround */

require CORE_PATH.'cake'.DS.'bootstrap.php';

if(isset($_GET['url']) && $_GET['url'] === 'favicon.ico') { } /* IIS Workaround */ elseif (isset($_GET['url']) && file_exists(dirname(__FILE__) . $_GET['url'])) { header('Location: ' . $_GET['url'] . '?STATIC_REWRITE'); exit(); } /* /IIS Workaround */ else { $Dispatcher= new Dispatcher (); $Dispatcher->dispatch($url); }

if (DEBUG) { echo ""; }

Please refer any bug/problem.