What are you trying to do? Running Selenium to do some web processing over a web server is not optimal, even if using phantomjs.
And if you are using phantomjs, you might consider serving the content via node.js (express.js) rather than PHP as there is better/direct integration there being on the same language platform stack.
If you're using PHP on the web side, technically for some web queries you're making, you're better off using PHP curl to do the HTTP requests (GET, POST, etc.) rather than Selenium phantomjs or Mechanize, BeautifulSoup, and thus also bypass the Python script layer. PHP has JSON and XML parsing support itself as well.
If you prefer Python, then perhaps you should serve the content via a Python web framework instead of PHP (e.g. Bottle, Django).
Whatever you're doing can work as you've set up but it's too many layers to do something simple.