Mailing List Archive

Using Varnish with PHP
Hi,

Not sure if this is the right forum but would appreciate if you could let
me know how to serve PHP pages using Varnish. We have wordpress (Blog)
hosted on our server. Varnish sits behind Nginx in the stack.
Currently, PHP is served directly by Nginx using PhpFpm. We would like to
use varnish to cache wordpress pages.

We are already using Varnish to serve pages from a Python based framework.

Looking forward to any help.

Thanks,
Pinakee Biswas

http://www.jivaana.com
Re: Using Varnish with PHP [ In reply to ]
Hi, I'm not sure I get the question. Varnish will serve anything as long as
it's HTTP-based, so you can just point Varnish to Nging, and it will cache
whatever Nginx sends its way.

--
Guillaume Quintard
Re: Using Varnish with PHP [ In reply to ]
Hi,

Thanks for your response but in our scenario, Nginx is in front:

Users/Clients----->Nginx---> Varnish---->PHP

So, you mean I would need a webserver for PHP.

Thanks,
Pinakee

On Wed, Feb 15, 2017 at 2:17 PM, Guillaume Quintard <
guillaume@varnish-software.com> wrote:

> Hi, I'm not sure I get the question. Varnish will serve anything as long
> as it's HTTP-based, so you can just point Varnish to Nging, and it will
> cache whatever Nginx sends its way.
>
> --
> Guillaume Quintard
>
>
Re: Using Varnish with PHP [ In reply to ]
Yes, the usual way of doing thing is:

Users/Clients----->Varnish---> Nginx---->PHP

Varnish is "only" a cache, it won't generate content.

--
Guillaume Quintard
Re: Using Varnish with PHP [ In reply to ]
Hi,

Thanks for clarifying. Doesn't it support other protocols like FastCGI to
support PHP-FPM? If HTTP is the only option, then would use a web server.

Thanks,
Pinakee

On Wed, Feb 15, 2017 at 3:11 PM, Guillaume Quintard <
guillaume@varnish-software.com> wrote:

> Yes, the usual way of doing thing is:
>
> Users/Clients----->Varnish---> Nginx---->PHP
>
> Varnish is "only" a cache, it won't generate content.
>
> --
> Guillaume Quintard
>
Re: Using Varnish with PHP [ In reply to ]
Correct, that's HTTP only.

--
Guillaume Quintard
Re: Using Varnish with PHP [ In reply to ]
NGIX is a web server. And PHP-FPM is not a protocol. HTTP is the protocol. Your question is confused.

Sent from my iPhone

> On Feb 15, 2017, at 4:47 AM, Guillaume Quintard <guillaume@varnish-software.com> wrote:
>
> Correct, that's HTTP only.
>
> --
> Guillaume Quintard
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: Using Varnish with PHP [ In reply to ]
I have a working config file for php/wordpress/varnish/nginx if you'd
like to take a look.


They are plaintext on pastebin.



http://pastebin.com/4MgKWWUx -- varnishd 4.0 /etc/varnish/default.vcl for WordPress caching


Based on the content of the config, you would need your nginx vhost
running on port 8080 and varnish would run on port 80 and/or 443. I have
other PHP/nginx/varnish examples here: http://pastebin.com/u/meesteridle








On Tue, Feb 14, 2017, at 11:38 PM, Pinakee Biswas wrote:

> Hi,

>

> Not sure if this is the right forum but would appreciate if you could
> let me know how to serve PHP pages using Varnish. We have wordpress
> (Blog) hosted on our server. Varnish sits behind Nginx in the stack.
> Currently, PHP is served directly by Nginx using PhpFpm. We would like
> to use varnish to cache wordpress pages.
>
Re: Using Varnish with PHP [ In reply to ]
oops. I guess varnish doesn't support 443. sorry. still, can be
used for 80




On Wed, Feb 15, 2017, at 10:01 AM, Brad Tarver wrote:

> I have a working config file for php/wordpress/varnish/nginx if you'd
> like to take a look.
>

> They are plaintext on pastebin.

>

> http://pastebin.com/4MgKWWUx -- varnishd 4.0 /etc/varnish/default.vcl
> for WordPress caching
>

> Based on the content of the config, you would need your nginx vhost
> running on port 8080 and varnish would run on port 80 and/or 443. I
> have other PHP/nginx/varnish examples here:
> http://pastebin.com/u/meesteridle
>

>

>

>

> On Tue, Feb 14, 2017, at 11:38 PM, Pinakee Biswas wrote:

>> Hi,

>>

>> Not sure if this is the right forum but would appreciate if you could
>> let me know how to serve PHP pages using Varnish. We have wordpress
>> (Blog) hosted on our server. Varnish sits behind Nginx in the stack.
>> Currently, PHP is served directly by Nginx using PhpFpm. We would
>> like to use varnish to cache wordpress pages.
>>

>
Re: Using Varnish with PHP [ In reply to ]
Hi,

Thanks for your response.

FastCGI is the protocol between Nginx (web server) and PHP-FPM. The PHP
pages are served by PHP-FPM. But as I understand, Varnish only supports
HTTP.

Thanks,
Pinakee

On Wed, Feb 15, 2017 at 7:35 PM, Tim Dunphy <bluethundr@gmail.com> wrote:

> NGIX is a web server. And PHP-FPM is not a protocol. HTTP is the protocol.
> Your question is confused.
>
> Sent from my iPhone
>
> > On Feb 15, 2017, at 4:47 AM, Guillaume Quintard <
> guillaume@varnish-software.com> wrote:
> >
> > Correct, that's HTTP only.
> >
> > --
> > Guillaume Quintard
> >
> > _______________________________________________
> > varnish-misc mailing list
> > varnish-misc@varnish-cache.org
> > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
Re: Using Varnish with PHP [ In reply to ]
Hi,

Thanks for sharing the config - I would certainly take a look.

Thanks,
Pinakee

On Wed, Feb 15, 2017 at 9:31 PM, Brad Tarver <idle@pobox.com> wrote:

> I have a working config file for php/wordpress/varnish/nginx if you'd like
> to take a look.
>
> They are plaintext on pastebin.
>
> http://pastebin.com/4MgKWWUx -- varnishd 4.0 /etc/varnish/default.vcl for
> WordPress caching
>
> Based on the content of the config, you would need your nginx vhost
> running on port 8080 and varnish would run on port 80 and/or 443. I have
> other PHP/nginx/varnish examples here: http://pastebin.com/u/meesteridle
>
>
>
>
> On Tue, Feb 14, 2017, at 11:38 PM, Pinakee Biswas wrote:
>
> Hi,
>
> Not sure if this is the right forum but would appreciate if you could let
> me know how to serve PHP pages using Varnish. We have wordpress (Blog)
> hosted on our server. Varnish sits behind Nginx in the stack.
> Currently, PHP is served directly by Nginx using PhpFpm. We would like to
> use varnish to cache wordpress pages.
>
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
Re: Using Varnish with PHP [ In reply to ]
On Thu, Feb 16, 2017 at 6:25 AM, Pinakee Biswas <pinakee@waltzz.com> wrote:
> Hi,
>
> Thanks for your response.
>
> FastCGI is the protocol between Nginx (web server) and PHP-FPM. The PHP
> pages are served by PHP-FPM. But as I understand, Varnish only supports
> HTTP.

Varnish only supports HTTP/1 natively on the backend side, someone
could write a FastCGI-capable module. I'm just saying... in case that
someone has both the time and skill and didn't know they could do it.

Dridi

PS. someone, if you're reading this, you know what to do

_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc