How to install yui compressor in CentOs

12,096

Solution 1

As Jordan mentioned, make sure you have Java installed. Try java -version to see if the JDK info shows up. If not try, which java -- on CentOS it should be in /usr/bin/java if are using the RPM installed version.

If it doesn't show up, use: yum install java-1.6.0-openjdk which should install the JDK and any other required java libs (do this with sudo or as root user). Just make sure you don't already have another JDK installed or you could run into problems later (try rpm -qa | grep java to see what's installed via RPM).

Then you should be able to call the yuicompressor directly with a statement like:

/usr/bin/java -jar /usr/share/yui-compressor/yui-compressor.jar --help

If you get the help output, you probably are ok. You can then use it on a file with a statement like:

/usr/bin/java -jar /usr/share/yui-compressor/yui-compressor.jar /path/to/source/file >> /path/to/exportfile.js

(obviously change the filename paths.) There are a number of options you can use, but that should get you started. I'm using this on CentOS with a build script that loops through various files and creates optimized bundled files and it works well.

You may also want to check out the build script and instructions at: http://html5boilerplate.com/ which uses yui-compressor and is the method I would eventually like to go with.

Solution 2

At the most basic level, you will want to update your /usr/bin/yui-compressor script to look something like this:

#!/bin/sh
YUI_JAR=/usr/share/yui-compressor/yui-compressor.jar
java -jar $YUI_JAR "$*"

Ensure that you have a Java runtime installed.

Share:
12,096
J-Rou
Author by

J-Rou

Updated on June 05, 2022

Comments

  • J-Rou
    J-Rou about 2 years

    I know this is going to sound like a noob question, but I'm new to using linux, I was trying to find out how to install yui-compressor in CentOS, but I haven't been able to find it using google.

    I have already done this:

    wget http://yui.zenfs.com/releases/yuicompressor/yuicompressor-2.4.6.zip
    
    unzip yuicompressor-2.4.6.zip
    
    # mv yuicompressor-2.4.6/build/yuicompressor-2.4.6.jar /usr/share/yui-compressor/yui-compressor.jar
    

    I've also created a file in /usr/bin called yui-compressor that has:

    #!/bin/sh
    
    YUI_JAR=/usr/share/yui-compressor/yui-compressor.jar
    

    I dont know what else to do. (I don't even know if its already installed).

    Can someone please help me with the following:

    1. If its installed, please tell me.
    2. If not. Tell me what else do I need to do.

    Thank you.