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

 
Sự tiện lợi của Drupal 8 adoption led by Adam Balsam

Sự tiện lợi của Drupal 8 adoption led by Adam Balsam

Contributed modules in Drupal deliver the functionality and innovation proprietary content management solutions simply can't match

Những từ giúp cho tiêu để thêm đắt giá marketing

Những từ giúp cho tiêu để thêm đắt giá marketing

Tiêu đề luôn là phần quan trọng nhất của một bài viết hấp dẫn. Một tiêu đề tuyệt với khiến người đọc không

Hướng dẫn mua iPad 2

Hướng dẫn mua iPad 2

Những lựa chọn thường gặp dưới đây sẽ khiến người dùng bối rối ít nhiều khi chọn mua máy tính bảng iPad 2.

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

 

Diet con trung