如何在CentOs中安装yui压缩器
我知道这听起来像是一个菜鸟问题,但我是 Linux 的新手,我试图找出如何在 CentOS 中安装 yui-compressor,但我无法使用 google 找到它。
我已经这样做了:
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
我还在 /usr/bin 中创建了一个名为 yui-compressor 的文件,其中包含:
#!/bin/sh
YUI_JAR=/usr/share/yui-compressor/yui-compressor.jar
我不知道还能做什么。 (我什至不知道它是否已经安装)。
有人可以帮我解决以下问题吗:
- 如果已安装,请告诉我。
- 如果不。告诉我我还需要做什么。
谢谢。
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:
- If its installed, please tell me.
- If not. Tell me what else do I need to do.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在最基本的层面上,您需要更新您的
/usr/bin/yui-compressor
脚本,使其看起来像这样:确保您安装了 Java 运行时。
At the most basic level, you will want to update your
/usr/bin/yui-compressor
script to look something like this:Ensure that you have a Java runtime installed.
正如乔丹提到的,确保你安装了 Java。尝试
java -version
查看 JDK 信息是否显示。如果不尝试,which java
- 在 CentOS 上,如果使用 RPM 安装版本,它应该位于 /usr/bin/java 中。如果它没有显示,请使用: yum install java-1.6.0-openjdk ,它应该安装 JDK 和任何其他所需的 java 库(使用 sudo 或以 root 用户身份执行此操作)。只需确保您尚未安装其他 JDK,否则稍后可能会遇到问题(尝试 rpm -qa | grep java 来查看通过 RPM 安装的内容)。
然后你应该能够使用如下语句直接调用 yuicompressor:
如果你得到帮助输出,那么你可能没问题。然后,您可以使用以下语句在文件上使用它:(
显然更改文件名路径。)您可以使用许多选项,但这应该可以帮助您入门。我在 CentOS 上使用它,并使用构建脚本循环遍历各种文件并创建优化的捆绑文件,并且效果良好。
您可能还想查看构建脚本和说明: http://html5boilerplate.com/ 它使用 yui-压缩器,这是我最终想要采用的方法。
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 (tryrpm -qa | grep java
to see what's installed via RPM).Then you should be able to call the yuicompressor directly with a statement like:
If you get the help output, you probably are ok. You can then use it on a file with a statement like:
(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.