varnish / libvmod-example

An example vmod for Varnish Cache
https://varnish-cache.org/vmods/
53 stars 74 forks source link

Install instructions need to be updated for Varnish 4.0 #6

Closed daghf closed 9 years ago

daghf commented 10 years ago

Since we no longer require the source to be available, and now use pkg-config to figure out the various paths.

rvilardo commented 10 years ago

Is there any work around to make it work right now? I am facing this issue

rvilardo commented 10 years ago

I have varnish_cache 4.0 Redhat version installed (in a specific path), the only way I could compile it was installing varnish-api-devel, copying the varnish.m4 (that only came with the api-devel) to aclocal, configuring the PKG_CONFIG_PATH to point to the folder where varnishapi.pc is (again, only came with the api-devel) and correct the paths inside the varnishapi.pc. So, you still need to have the varnish-api-devel (or source) in order to compile the vmod.

By the way, I couldn't set the VMODDIR during the configure process. It always follows the one defined on "varnishapi.pc"

daghf commented 10 years ago

If you've installed from any of the official package builds, it should just work via ./configure; make; make install.

If Varnish is installed outside of the default install directories, you need to first tell aclocal and pkg-config where to look for varnish.m4 file and varnishapi.pc. This can be handled by sourcing the following:

PREFIX=/opt/varnish4 export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig export ACLOCAL_PATH=$PREFIX/share/aclocal

(replace '/opt/varnish4' with whatever you used as --prefix when building Varnish)

rvilardo commented 10 years ago

I understand but my concern is that I couldn't find the varnish.m4 and varnishapi.pc by downloading from official package build (RHEL 6.2). Those files only come with "varnish-libs-devel" pkg. So, you still need to have the varnish-libs-devel (or source) in order to compile the vmod.

Did I get it wrong?

tfheen commented 10 years ago

That is correct, you need the header files from Varnish to compile vmods. Those header files live in varnish-libs-devel (on RHEL/CentOS). They should be picked up automatically by autoreconf and pkg-config once you've installed, no need to copy them anywhere

RBeaudoin commented 10 years ago

I've encountered a similar situation, and hope clarification helps someone else...

I'm on Debian and I install the 4.0 varnish package but get this error when running ./configure in the libvmod-example directory:

'configure: error: No Varnish source tree specified'

@daghf are you saying 'configure' should work without taking additional steps?

RBeaudoin commented 10 years ago

I've also tried installing the libvarnishapi-dev package, but still get the error:

'configure: error: No Varnish source tree specified'

If I download the Varnish source, and supply the VARNISHSRC param to configure I get further, but then am required to move the varnish.m4 file per the earlier comments by @rvilardo . Having a clear, consistent set of steps (and/or clarification on the existing steps) would be very helpful

daghf commented 10 years ago

@RBeaudoin, are you building libvmod-example from the 3.0 branch? For Varnish 4.0 you need the master branch.

RBeaudoin commented 10 years ago

Thanks @daghf switching to the 'master' branch solved the problem with ./configure, but now I get this error with 'make':

make[2]: Entering directory /home/vagrant/source/libvmod-example/src' make[2]: *** No rule to make target@VMODTOOL@', needed by vcc_if.c'. Stop. make[2]: Leaving directory/home/vagrant/source/libvmod-example/src' make[1]: * [all-recursive] Error 1 make[1]: Leaving directory `/home/vagrant/source/libvmod-example' make: * [all] Error 2

I also noticed this in the output from 'configure':

./configure: line 12705: VARNISH_VMOD_INCLUDES: command not found ./configure: line 12706: VARNISH_VMOD_DIR: command not found ./configure: line 12707: VARNISH_VMODTOOL: command not found

daghf commented 10 years ago

@RBeaudoin, did you re-run ./autogen.sh after switching to the master branch?

RBeaudoin commented 10 years ago

Yes, I did:

vagrant@precise64:~/source/libvmod-example$ ./autogen.sh

rvilardo commented 10 years ago

That's the same issue I had, it happens because it cannot find the varnish macros (defined at varnish.m4 file). To fix this, you have to copy the ,m4 file as I said before (I tried exporting ACLOCAL_PATH with where my .m4 file was as suggested by @daghf but didn't work).

As soon as you place the varnish.m4 file into the aclocal (../share/local), you need to re-run autogen and it should work.

RBeaudoin commented 10 years ago

That was my thought as well, but that would require getting the source (or retrieving the .m4 file somewhere) and @daghf mentioned that source is not necessary for 4.0 so I wanted to get some clarification

daghf commented 10 years ago

@RBeaudoin, libvarnishapi-dev installs varnish.m4 under /usr/share/aclocal, which should match the output of 'aclocal --print-ac-dir' on Ubuntu precise. Downloading the varnish source package is not required.

RBeaudoin commented 10 years ago

@daghf unfortunately libvarnishapi-dev did not install varnish.m4 under /usr/share/aclocal:

vagrant@precise64:~$ sudo apt-get install libvarnishapi-dev Reading package lists... Done Building dependency tree
Reading state information... Done The following NEW packages will be installed: libvarnishapi-dev 0 upgraded, 1 newly installed, 0 to remove and 166 not upgraded. Need to get 0 B/10.3 kB of archives. After this operation, 84.0 kB of additional disk space will be used. Selecting previously unselected package libvarnishapi-dev. (Reading database ... 55494 files and directories currently installed.) Unpacking libvarnishapi-dev (from .../libvarnishapi-dev_3.0.2-1ubuntu0.1_amd64.deb) ... Setting up libvarnishapi-dev (3.0.2-1ubuntu0.1) ... vagrant@precise64:~$ ls /usr/share/aclocal/ argz.m4 libtool.m4 ltdl.m4 lt~obsolete.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 pkg.m4 vagrant@precise64:~$

And I still get the error posted above:

make[2]: Entering directory /home/vagrant/source/libvmod-example/src' make[2]: * No rule to make target@VMODTOOL@', needed by vcc_if.c'. Stop. make[2]: Leaving directory/home/vagrant/source/libvmod-example/src' make[1]: * [all-recursive] Error 1 make[1]: Leaving directory `/home/vagrant/source/libvmod-example' make: *\ [all] Error 2

RBeaudoin commented 10 years ago

I manually downloaded the source, and copied to the /usr/share/aclocal directory per @rvilardo, re-ran autogen.sh, and was able to successfully run 'configure'. I now get an error when running 'make':

Making all in src make[2]: Entering directory /home/vagrant/source/libvmod-example/src' ../src/vmod_example.vcc /bin/bash: ../src/vmod_example.vcc: Permission denied make[2]: *** [vcc_if.c] Error 126 make[2]: Leaving directory/home/vagrant/source/libvmod-example/src' make[1]: * [all-recursive] Error 1 make[1]: Leaving directory `/home/vagrant/source/libvmod-example' make: * [all] Error 2

rvilardo commented 10 years ago

set the PKG_CONFIG_PATH to the place where your 'varnishapi.pc' is. By the way, check if your varnishapi.pc is pointing to the correct paths.

RBeaudoin commented 10 years ago

@rvilardo for for the sake of clarity, the only way to get varnishapi.pc is to build from source, which I did and I also exported PKG_CONFIG_PATH, I still get the error I shared in my last comment:

Making all in src make[2]: Entering directory /home/vagrant/source/libvmod-example/src' ../src/vmod_example.vcc /bin/bash: ../src/vmod_example.vcc: Permission denied make[2]: * [vcc_if.c] Error 126 make[2]: Leaving directory/home/vagrant/source/libvmod-example/src' make[1]: * [all-recursive] Error 1 make[1]: Leaving directory `/home/vagrant/source/libvmod-example' make: *\ [all] Error 2

There appears to be some issue with make trying to execute the file vmod_example.vcc for some reason, any help here would be appreciated as we trying to build an example VMOD as a POC to use Varnish in our cloud platform. If we can't build a basic example it creates a barrier to entry for us and we may need to go with another solution

rvilardo commented 10 years ago

@RBeaudoin, you can get the varnishapi.pc by installing the libvarnishapi-dev which I guess you already did. You can find this file at "varnish-api-dev-prefix/usr/lib64/pkgconfig"

At least, for RHEL this file came with the libvarnishapi-api.

By the way, which version of autoconf/pkg-config are you using?

RBeaudoin commented 10 years ago

I actually had to build from source to get it, unfortunately it wasn't under the directory you mentioned above.

I am using version 2.68 of autoconf

rvilardo commented 10 years ago

Ok, so you built the varnish-lib-api from the source and have the varnishapi.pc, right? And you already exported the PKG_CONFIG_PATH to where varnishapi.pc is, right? Check if the paths inside varnishapi.pc is correct because checking the error msg you sent, its a 'permission denied' error, maybe its trying to write files into the wrong place.

RBeaudoin commented 10 years ago

Actually, I cloned the source from GitHub and built in order to get varnishapi.pc.

Is there a way to identify the 'right' paths? Maybe at this point using version 3.0 of Varnish and that module system would be better until the 4.0 module ecosystem matures.

rvilardo commented 10 years ago

Use the one below as your varnishapi.pc (I barely changed it to use all paths derived from the prefix). Just adjust the prefix to where you installed the varnish-lib-api.

Then do all the process again: autogen, configure, make...

prefix=/home/rvila/varnish/tools/varnish-lib-api/usr exec_prefix=${prefix} bindir=${prefix}/bin sbindir=${prefix}/sbin libdir=${prefix}/lib64 includedir=${prefix}/include pkgincludedir=${includedir}/varnish datarootdir=${prefix}/share datadir=${prefix}/share pkgdatadir=${datadir}/varnish pkgdataincludedir=${pkgdatadir}/include vmodincludedir=${pkgdataincludedir} vmoddir=${libdir}/varnish/vmods vmodtool=${pkgdatadir}/vmodtool.py

Name: VarnishAPI Description: Varnish API Version: 4.0.0 Cflags: -I${includedir}/varnish Libs: -L${libdir} -lvarnishap

RBeaudoin commented 10 years ago

@rvilardo unfortunately I don't believe I have a similar directory to what you have under /home/rvila/varnish/tools/varnish-lib-api

rvilardo commented 10 years ago

Thats the place I installed libvarnishapi-dev. I did by "sudo yum --installroot=$HOME/varnish/tools/varnish-lib-api install varnish-libs-devel.x86_64"

RBeaudoin commented 10 years ago

I was able to manually download the .deb package for libvarnishapi-dev, and listed the debian package contents:

vagrant@precise64:~$ dpkg -c libvarnishapi-dev_3.0.2-1ubuntu0.1_amd64.deb drwxr-xr-x root/root 0 2012-06-19 11:51 ./ drwxr-xr-x root/root 0 2012-06-19 11:51 ./usr/ drwxr-xr-x root/root 0 2012-06-19 11:51 ./usr/include/ drwxr-xr-x root/root 0 2012-06-19 11:51 ./usr/include/varnish/ -rw-r--r-- root/root 2639 2012-06-19 11:51 ./usr/include/varnish/vsl_tags.h -rw-r--r-- root/root 3092 2012-06-19 11:51 ./usr/include/varnish/vsm.h -rw-r--r-- root/root 5992 2012-06-19 11:51 ./usr/include/varnish/vcli.h -rw-r--r-- root/root 2720 2012-06-19 11:51 ./usr/include/varnish/vsl.h -rw-r--r-- root/root 7567 2012-06-19 11:51 ./usr/include/varnish/varnishapi.h -rw-r--r-- root/root 1820 2012-06-19 11:51 ./usr/include/varnish/vsc.h -rw-r--r-- root/root 2053 2012-06-19 11:51 ./usr/include/varnish/vsc_all.h -rw-r--r-- root/root 9787 2012-06-19 11:51 ./usr/include/varnish/vsc_fields.h drwxr-xr-x root/root 0 2012-06-19 11:51 ./usr/lib/ drwxr-xr-x root/root 0 2012-06-19 11:51 ./usr/lib/pkgconfig/ -rw-r--r-- root/root 242 2012-06-19 11:51 ./usr/lib/pkgconfig/varnishapi.pc drwxr-xr-x root/root 0 2012-06-19 11:51 ./usr/share/ drwxr-xr-x root/root 0 2012-06-19 11:51 ./usr/share/doc/ drwxr-xr-x root/root 0 2012-06-19 11:51 ./usr/share/doc/libvarnishapi-dev/ -rw-r--r-- root/root 2025 2011-10-29 13:24 ./usr/share/doc/libvarnishapi-dev/copyright lrwxrwxrwx root/root 0 2012-06-19 11:51 ./usr/lib/libvarnishapi.so -> libvarnishapi.so.1.0.0 lrwxrwxrwx root/root 0 2012-06-19 11:51 ./usr/share/doc/libvarnishapi-dev/changelog.Debian.gz -> ../libvarnishapi1/change

The thing is, this appears to be a version 3.0.2 package, and I don't see a version 4.0 package. I am now using the varnishapi.pc file included in this bundle and still get this error from make:

make all-recursive make[1]: Entering directory /home/vagrant/source/libvmod-example' Making all in src make[2]: Entering directory/home/vagrant/source/libvmod-example/src' ../src/vmod_example.vcc /bin/bash: ../src/vmod_example.vcc: Permission denied make[2]: * [vcc_if.c] Error 126 make[2]: Leaving directory `/home/vagrant/source/libvmod-example/src' make[1]: * [all-recursive] Error 1 make[1]: Leaving directory`/home/vagrant/source/libvmod-example' make: *\ [all] Error 2

For some reason it wants to execute vmod_example.vcc, and I keep getting a permission denied error via make.

RBeaudoin commented 10 years ago

Does anyone know of any VMOD that builds out of the box with 4.0 that I can use as a reference instead of libvmod-example?

tfheen commented 10 years ago

]] Rich Beaudoin

vagrant@precise64:~$ dpkg -c libvarnishapi-dev_3.0.2-1ubuntu0.1_amd64.deb

This package is from Ubuntu and not from the official repositories. It is, as you point out, an old version.

The thing is, this appears to be a version 3.0.2 package, and I don't see a version 4.0 package. I am now using the varnishapi.pc file included in this bundle and still get this error from make:

http://repo.varnish-cache.org/debian/pool/varnish-4.0/v/varnish/ has the 4.0 packages.

If you follow the instructions on https://www.varnish-cache.org/installation/debian you should get apt set up so you can just install libvarnishapi-dev version 4 and then the instructions should work fine.

Tollef Fog Heen UNIX is user friendly, it's just picky about who its friends are

RBeaudoin commented 10 years ago

@tfheen Thank you, I have everything working now using the following steps:

  1. Follow the instructions here to add the varnish-cache repo: https://www.varnish-cache.org/installation/debian and install varnish 4.0
  2. Run 'sudo apt-get install libvarnishapi1'
  3. Run 'sudo apt-get install libvarnishapi-dev'
  4. Clone the git repo libvmod-example, and switch to the 'master' branch
  5. Run './autogen.sh', './configure', 'make', 'sudo make install'
  6. Edit /etc/varnish/default.vcl and add 'import example;' after the 'vcl 4.0;' statement
  7. Run 'sudo service varnish reload'

If all is well, then varnish will start up without issue. If not then 'sudo service varnish restart' will give you some better error messages. I successfully installed the module on Ubuntu Precise 12.04 using the steps I listed above.

crico commented 9 years ago

I am trying to install Varnish 4.0 on Squeeze but it seems that is no longer available in the repository, I would like to know why it is not already available. I tried to compile the sources too, but get an error since there is no compatible curses library.

Any ideas will be of great help, thanks.

aondio commented 9 years ago

@crico Hi, before compiling the source,have you checked if you have all the build dependencies and they are up-to-date?

crico commented 9 years ago

I execute the command: "./configure" with the following output: ... checking for NcursesW wide-character library... no checking for Ncurses library... no checking for Curses library... no configure: error: requires an X/Open-compatible Curses library

How do I can check dependencies?

aondio commented 9 years ago

@crico Before installing Varnish 4.0 from source you have to check de build dependencies listed here :https://www.varnish-cache.org/docs/4.0/installation/install.html

crico commented 9 years ago

Ok @aondio, thanks!

PorterDon commented 9 years ago

RBeaudoin, thanks much for the discrete steps in your Sept 26 comment. I am trying to tag along and get varnish and its related apps (like varnishstat, varnishtop, etc) correctly installed on my Raspberry Pi 2 running Jessie. At this point I have varnish running because my website is humming (www.CarLoversJournal.com) but must not be installed right because for "sudo /etc/init.d/varnish stop" I get "/etc/init.d/varnish: command not found". Also, sometimes my galleries pop up almost instantaneously and sometimes there is a 5-10+ second wait. BTW, I use CloudFlare also. Your step #4 "Clone the git repo libvmod-example, and switch to the 'master' branch" is just a bit beyond my antiquated vocabulary. Clone means copy, right? But clone what? And "Master branch"? I am trying to create a straightforward step-by-step varnish install (complete) for Raspbian. There have to be many people wanting to use varnish but are beyond intimidated by it's installation. Once installed and running we can fine-tune it etc and get our little Pi web servers greatly sped up. Thanks to you and others who can lend a hand.

RBeaudoin commented 9 years ago

You should take a look at the Git handbook to understand cloning and the branching model: http://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository

Basically you use the "git clone" command to copy a repository from a remote server to your local machine. Once that is done, you can switch branches via the "git checkout" command, so you'd run "git checkout master" in your case.

Hope that helps, let me know if you have any other questions.

Rich

On Thu, Feb 19, 2015 at 3:28 AM, PorterDon notifications@github.com wrote:

RBeaudoin, thanks much for the discrete steps in your Sept 26 comment. I am trying to tag along and get varnish and its related apps (like varnishstat, varnishtop, etc) correctly installed on my Raspberry Pi 2 running Jessie. At this point I have varnish running but must not be installed right because for "sudo /etc/init.d/varnish stop" I get "/etc/init.d/varnish: command not found". Your step #4 https://github.com/varnish/libvmod-example/issues/4 "Clone the git repo libvmod-example, and switch to the 'master' branch" is just a bit my antiquated vocabulary. Clone means copy, right? "Master branch"? I am trying to create a straightforward step-by-step varnish install (complete) for Raspbian. There have to be many people wanting to use varnish but are beyond intimidated by it's installation. Once installed and running we can fine-tune it etc and get our little Pi web servers greatly sped up. Thanks to you and oth ers who can lend a hand.

— Reply to this email directly or view it on GitHub https://github.com/varnish/libvmod-example/issues/6#issuecomment-75029525 .

lkarsten commented 9 years ago

Should be completed now that @nigoroll 's pull requests are merged.