Run Interworx with mod_php5 ?

Is there a way to install Interworx on CentOS 7 and use mod_php5 instead of suphp?

I want to switch from APC to Zend Opcache, but opcache won’t cache scripts on suphp.

Any pointers would be super!

dave

Hi Dave

I believe this is possible to do, but I have not attempted myself.

Hopefully some of the users who have tried or completed this will post.

Appreciate if you could update your post if you try

Many thanks

John

Happy Halloween, everybody!

John, thank you for your reply.

The more I thought about it, the more I worried I would end up too far out of the mainstream to be anything other than a maintenance nightmare.

Instead, I am pursuing Varnish as a reverse proxy cache alternative. (Largely based on the Nexcess Magento Best Practices timings and recommendations)

From what I’ve read in the Forums, you are already aware that Varnish is not exactly a “bag-O-laughs” with Iworx name-based virtual hosting. I’m having the same problems everyone else is.

I’m convinced that Varnish is mangling host headers. Today I will explore Varnish built in methods to modify host headers before they are presented to Apache.

dave

OK… Trick or Treat!!

[SIZE=4]===> 151105 - Please see my update below <===[/SIZE]

My suspicions about Varnish turned out to be TOTALLY WRONG. Sorry if I besmirched the good name of that impressive product in any way.

The real problem turned out to be my lack of understanding of what was going on with named-based virtual domains. Apache tests IP/Server name combinations and if it doesn’t find a match, the first defined virtual domain gets the request.

So, when you run Varnish as a frontend, the IP that Varnish uses to talk to Apache is “localhost”, not the external IP you used to define the original domain. So, basically there is never going to be a match. Things go wrong very quickly from there.

I’m setting up a new CentOS 7 Interworx server that will have only name-based virtual domains all using the same IP address.

So, this is what I did to make this work for me. As always… YMMV

[LIST=1]

  • Use Nodeworx to change the Webserver listen port to 81
  • Use Nodeworx firewall to allow TCP 81
  • Install Varnish
  • Make Varnish listen to port 80
  • Make the Varnish backend port 81
  • Use Nodeworx to add the shared localhost IP 127.0.0.1
  • Use Nodeworx to change the primary IP for all domains to 127.0.0.1
  • Make sure each domains DNS still points to the server external IP
  • Reboot. Everything should work. [/LIST]

    Hope this saves someone a little time.

    Here are some URLs for pages that helped me:

    http://docs.interworx.com/nodeworx/webserver/index-Web-Server-Options.php#toc-Chapter-4
    http://www.interworx.com/support/faq/add-remove-addresses-nodeworx/
    http://www.unixmen.com/install-varnish-cache-4-0-centos-7/

    dave

  • Hi Dave

    Excellent post, kudos to you

    I did state in my varnish post to use localhost but I missed adding localhost as a shared ip

    Many thanks

    Johb

    Just How Wrong Can I Be???

    Well after a little experience using Varnish in front of Interworx, I discovered that using localhost (127.0.0.1) is a pretty bad idea. It adds a lot of work editing domain settings, breaks SMTP and is just plain old unnecessary. I apologize if I wasted anyone’s time.

    Simply change the backend host spec in the Varnish.vcl file and avoid all of those localhost shenanigans.

    Note: This server has only 1 external IP. All domains share this IP.
    So, this is what I now do to make this work for me. As always… YMMV

    [LIST=1]

  • Use Nodeworx to change the Webserver listen port to 81
  • Use Nodeworx firewall to allow TCP 81
  • Install Varnish
  • Make Varnish listen to port 80
  • In the Varnish.vcl file make backend port 81
  • In the Varnish.vcl file make backend host match your shared external IP
  • Reboot. Everything should work. [/LIST] ​

    dave

  • Managed to get working in a server with multiple/dedicated ips aswell, hereby is our working config:

    1. Use Nodeworx to change the Webserver listen port to 8080
    2. Use Nodeworx firewall to allow TCP port 8080
    3. Install Varnish
    4. Make sure your vanish is running on port 80, for us, we use CentOS 7 and varnish version 6.0, to change port use this config: /etc/systemd/system/multi-user.target.wants/varnish.service and inside:

    [Unit]
    Description=Varnish Cache, a high-performance HTTP accelerator
    After=network-online.target

    [Service]
    Type=forking
    KillMode=process

    Maximum number of open files (for ulimit -n)

    LimitNOFILE=131072

    Locked shared memory - should suffice to lock the shared memory log

    (varnishd -l argument)

    Default log size is 80MB vsl + 1M vsm + header -> 82MB

    unit is bytes

    LimitMEMLOCK=85983232

    Enable this to avoid “fork failed” on reload.

    TasksMax=infinity

    Maximum size of the corefile.

    LimitCORE=infinity

    ExecStart=/usr/sbin/varnishd -a :80 -f /etc/varnish/user.vcl -s malloc,1G
    ExecReload=/usr/sbin/varnishreload

    [Install]
    WantedBy=multi-user.target

    Due for updates to prevent varnish default.vcl we changed it to user.vcl in /etc/varnish/

    5. In /etc/varnish/default.vcl change to user.vcl and inside user.vcl looks like this:

    This is an example VCL file for Varnish.

    It does not do anything by default, delegating control to the

    builtin VCL. The builtin VCL is called when there is no explicit

    return statement.

    See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/

    and https://www.varnish-cache.org/trac/wiki/VCLExamples for more examples.

    Marker to tell the VCL compiler that this VCL has been adapted to the

    new 4.0 format.

    vcl 4.0;

    Default backend definition. Set this to point to your content server.

    import directors;
    backend one {
    .host = “YourServerIPone”;
    .port = “8080”;
    }
    backend two {
    .host = “YourServerIPtwo”;
    .port = “8080”;
    }
    sub vcl_init {
    new rrdirector = directors.round_robin();
    rrdirector.add_backend(one);
    rrdirector.add_backend(two);
    }

    sub vcl_recv {

    set req.http.x-host = req.http.host;
    set req.http.x-url = req.url;
    }
    sub vcl_backend_response {
    if (beresp.status == 403) {
    set beresp.http.X-Status = beresp.status;
    set beresp.status = 200;
    }
    }

    sub vcl_deliver {
    if (resp.http.X-Status) {
    set resp.status = std.integer(resp.http.X-Status, 403);
    unset resp.http.X-Status;
    }
    }

    6. In “YourServerIPone” and “YourServerIPtwo” put your server additional ips save the config and reload deamon and restart the varnish service:

    systemctl daemon-reload
    service varnish restart

    So you don’t need to run varnish on localhost/127.0.0.1 to interrupt other services, hope it helps someone.

    Cheers.