Cài đặt LESS CSS Apache module

Cài đặt LESS CSS Apache module

Cài đặt LESS CSS Apache module

This is an Apache2 module that is written to compile LESS code inside the CSS files when they are requested so the process will be transparent from any script using CSS no matter what it’s language is.

This Apache2 module is written using C.

How it works:

Easy! When a request is sent to any CSS file this request will be handled by this module, the module will compile the CSS file and create another file from this CSS file with .less extension, then the module will pass the compiled version as a response to the request.

Here is an example:

Request: http://localhost/themes/css/style.css <=== this CSS file contains LESS codes inside it the module will compile style.css and save the compiled version to:

Response: http://localhost/themes/css/style.css.less <==== this is the compiled version from style.css then the module will return the compiled version as response for the file "style.css"

Dependencies:

Apache2

  • To install, use:
    sudo apt-get install apache2

Less CSS

  • To install, use:
    sudo apt-get install rubygems1.8​
    sudo gem install rubygems-update​
    sudo update_rubygems
    ​sudo gem install less

Installation:

Download the project from here: https://github.com/waleedq/libapache2-mod-less_beta1/tarball/master

copy /bin/mod_less.so to /usr/lib/apache2/modules/mod_less.so
chmod 644 /usr/lib/apache2/modules/mod_less.so
copy /bin/less.load to /etc/apache2/mods-available/less.load
copy /bin/less.conf to /etc/apache2/mods-available/less.conf

You can edit the less.conf file to change when this module is going to be invoked

For example: This conf with "\.css$" will invoke the module when any .css file is requested:

<FilesMatch "\.css$"> SetHandler less </FilesMatch> 

changing "\.css$" to "\.less$" will invoke the module only for requested files with .less extension.

Compile from source:

You can clone the code from git://github.com/waleedq/libapache2-mod-less_beta1.git

GitHub repo link: https://github.com/waleedq/libapache2-mod-less_beta1

Source can be found in /src/mod_less.c to compile it you will need the apxs2 tool which can be found in the apache2-prefork-dev package.

sudo apt-get install apache2-prefork-dev

After installing apxs2 tool, cd to the src directory and execute this command

sudo apxs2 -c -i mod_less.c 

Compiled file “mod_less.so” will be automatically copied to /usr/lib/apache2/modules/mod_less.so and chmoded. you only need to add the less.load and less.conf as mentioned in the Installation section above.

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
How to Add Sharing Options to Safari’s Reading List

How to Add Sharing Options to Safari’s Reading List

Reading List, the Instapaper-like feature included with iOS 5, is a great way to save web pages for reading later.

Google Trang Trí Trang Chủ Tìm Kiếm Cho Giáng Sinh

Google Trang Trí Trang Chủ Tìm Kiếm Cho Giáng Sinh

Sau hiệu ứng tuyết rơi, hôm nay Google tiếp tục trang trí thêm trang tìm kiếm của họ với quả châu đủ màu sắc chào đó kỳ nghỉ Giáng Sinh sắp đến gần.

Làm thế nào để facebook không gửi mail?

Làm thế nào để facebook không gửi mail?

Facebook có quá nhiều ưu điểm khiến cho chúng ta “mê mệt” nhưng nó cũng có những điểm làm chúng ta cảm thấy rất khó chịu.

Công ty diệt chuột T&C

 

Diet con trung