title: Using ZeroMQ in a PHP script inside Apache
body: <p>I want to use the ZeroMQ publisher/subscriber to dispatch data from my web application to multiple servers.</p>
  
  <p>I use Apache and PHP for the web app, my php script works as follow:</p>
  
  <pre><code>//Initialization
  $context = new ZMQContext();
  $publisher = $context-&gt;getSocket(ZMQ::SOCKET_PUB);
  $publisher-&gt;bind("tcp://*:5556");
  
  //Then publishing for testing:
  
  $publisher-&gt;send("test");
  $publisher-&gt;send("test");
  $publisher-&gt;send("test");
  $publisher-&gt;send("test");
  $publisher-&gt;send("test");
  </code></pre>
  
  <p>For testing I adapted a subscriber from the documentation in python:</p>
  
  <pre><code>import sys
  import zmq
  
  #  Socket to talk to server
  context = zmq.Context()
  socket = context.socket(zmq.SUB)
  
  socket.connect ("tcp://localhost:5556")
  
  # Subscribe to zipcode, default is NYC, 10001
  socket.setsockopt(zmq.SUBSCRIBE, "")
  
  print "Waiting..."
  # Process 5 updates
  for update_nbr in range (5):
      string = socket.recv()
      print string
  </code></pre>
  
  <p>The whole thing works when I run the php script from command line but does not work through Apache (when the script is run through a web browser).</p>
  
  <p>Is there anything I should do to my Apache configuration to make it work ?</p>
  
  <p>Thanks</p>
  
  <p>Alexandre</p>