Custom php.ini với Dreamhost (để setup video site với Drupal)

Trong trường hợp bạn cần một site có tính năng: upload các file video với các định dạng khách nhau (wmv, avi, mpeg, ...), dung lượng file có thể lên đến 100 MB, site tự động chuyển file về định dạng .flv, tạo ảnh thumbnail, ... thì bạn có thể sử dụng Drupal 6 kết hợp với module flashvideo được cài đặt trên một server có hỗ trợ thư viện FFmpeg, ở đây tôi sử dụng Dreamhost.

Theo mặc định thì Dreamhost chỉ cho upload file <= 7 MB. Tuy nhiên, nó cũng cho phép chúng ta sử dụng cấu hình PHP tùy chỉnh cho từng site. Sau đây là các bước:

  1. Khởi động Putty rồi sử dụng ssh để login, còn ở Linux/Max desktop thì mở terminal lên.
  2. Tạo file thư mục cgi-bin ở thư mục root của site cần set up
    mkdir $HOME/example.com/cgi-bin
  3. Copy file cấu hình mặc định của dreamhost vào thư mục vừa tạo
    cp /etc/php5/php.ini $HOME/example.com/cgi-bin/php.ini
  4. Tạo file php-wrapper.cgi với nội dung sau rồi upload lên thư mục cgi-bin vừa tạo
    1. #!/bin/sh
    2. exec /dh/cgi-system/php5.cgi $*

    *Hoặc* có thể sử dụng dòng lệnh sau cho lẹ
    1. cat << EOF > $HOME/example.com/cgi-bin/php-wrapper.cgi
    2. #!/bin/sh
    3. exec /dh/cgi-system/php5.cgi $*
    4. EOF
  5. Thiết lập chmod cho thư mục và file
    1. chmod 755 $HOME/example.com/cgi-bin
    2. chmod 755 $HOME/example.com/cgi-bin/php-wrapper.cgi
    3. chmod 640 $HOME/example.com/cgi-bin/php.ini
  6. Chèn đoạn sau vào .htaccess ở thư mục gốc của site
    1. Options +ExecCGI
    2. AddHandler php5-cgi .php
    3. Action php-cgi /cgi-bin/php-wrapper.cgi
    4. Action php5-cgi /cgi-bin/php-wrapper.cgi
  7. Điều chỉnh file php.ini, tăng giới hạn dụng lượng file upload lên
    1. post_max_size = 100M
    2. upload_max_filesize=100M
    3. max_execution_time=1000
    4. max_input_time=1000
  8. Cũng nhớ bỏ hàm sh_exec() ra khỏi danh sách các file bị disabled. FlashVideo module cần sử dụng hàm này để gọi thư viện ffmpeg.

Thế Hồng

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <sup> <br> <p> <h3>
  • Lines and paragraphs break automatically.
  • Link to content with [[some text]], where "some text" is the title of existing content or the title of a new piece of content to create. You can also link text to a different title by using [[link to this title|show this text]]. Link to outside URLs with [[http://www.example.com|some text]], or even [[http://www.example.com]].
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.