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 Tran 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
  • Phone/Zalo: (+84) 944 225 212
  • WhatsApp: (+84) 944 225 212
  • Line Messenger: (+84) 944 225 212
  • Email: asaleotestf@gmail.com
  • Telegram Messenger: https:/t.me/tommytran0401

Quảng cáo việc làm

 

Thích hợp các bạn nữ mảng thợ may làm việc tại nước NGA

Đơn hàng Tuyển dụng 100 Thợ may đi Nga(đợt 1 tháng 3.2021, đợt 2 tháng 5.2021). Lương thực lãnh 800 USD, bao ăn ở, vé máy bay và visa, phí xuất cảnh(1800 USD)trả khi đi làm có lương. Bạn có thể liên hệ CÔNG TY qua Phone/Zalo: (+84) 944 225 212. Công ty sẽ tư vấn cho bạn.

Xem chi tiết: >>> https://bit.ly/3o9NOfR

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

 
Ngày 2 – Học Big Data, So sánh Volume, Velocity và Variety

Ngày 2 – Học Big Data, So sánh Volume, Velocity và Variety

Các tổ chức ngày càng phát triển, dữ liệu liên quan cũng phát triển và ngày càng phức tạp hơn. Hầu hết các tổ chức lớn đều có dữ liệu trong nhiều ứng dụng

Why responsive design?

Nói về Rresponsive design là gì

Last fall and winter, the web got very small for me. From early November until late February, nearly all of my internet access was via my iPhone 4S. (I was away from the office dealing with an urgent family health matter.)

Những vấn đề basic của Drupal 8 tại DrupalCon Austin

Những vấn đề basic của Drupal 8 tại DrupalCon Austin

To figure that out, I've mined the schedule for Drupal 8 related talks and events and organized them a bit to help me – and hopefully you – find the Drupal 8 sessions not to be missed.