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

 
Tên miền .vn của Việt Nam hơn gì tên miền .com?

Tên miền .vn của Việt Nam hơn gì tên miền .com?

Trong vài ngày gần đây, một số tờ báo đã thông tin về một loạt dự án bất động sản (BĐS) bị mất thương hiệu tên miền.com và đang phải xúc tiến mua lại. Thực chất câu chuyện có nghiêm trọng đến như vậy?

Trang thời tiết Weather Channel’s Journey chuyển sang Drupal

Trang thời tiết Weather Channel’s Journey chuyển sang Drupal

When my business partner, Paul Chason, and I joined forces over seven years ago we had a rather simple vision for Mediacurrent.

Sản phẩm cơ sở dữ liệu dân cư tiết kiệm thời gian quản lý

Sản phẩm cơ sở dữ liệu dân cư tiết kiệm thời gian quản lý

Sản phẩm cho phép mở rộng quản lý với phạm vi lớn hơn, tiện ích hơn cho cơ quan Công an trong việc nhập liệu, quản lý và thống kê dân cư tại địa bàn.

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

 

Diet con trung