Selenium服务器无法连接到主机,未指定显示 - OLD:无法启动新的浏览器会话

I'm using Selenium server (2.39.0) on centOs server 6.5 (redhat) developing tests in PHP, using phpUnit (i installed phpunit by pear as well)

but everytime i get this error:

Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/': 
Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException:
Error while launching browser
Caused by
RuntimeException: 
Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/': 
Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException:
Error while launching browser

this is the test that i'm trying to execute:

<?php

require_once 'PHPUnit/Extensions/SeleniumTestCase.php';

class Example extends PHPUnit_Extensions_SeleniumTestCase
{
   function setUp()
  {
    $this->setBrowser("*firefox");
    $this->setBrowserUrl("http://www.google.com/");
  }

  function testMyTestCase()
  {
    $this->open("/");
    $this->type("q", "selenium rc");
    $this->click("btnG");
    $this->waitForPageToLoad("30000");
    $this->assertTrue($this->isTextPresent("Results * for selenium rc"));
  }
}
?>

i'm trying also to run the script using :

phpunit --configuration conf.xml example.php

where in conf.xml i've got:

<browser name="Firefox" browser="*firefox" host="IPHOST" port="4444" timeout="30000" />

but i receive the same error

and the door 4444 is free:

netstat -anp | grep 4444

gives:

tcp        0      0 :::4444                     :::*                        LISTEN 

what am i doing wrong?

EDIT:

@sircapsalot: do you mean to change the script?

anyway i don't know if i'm going to the right direction but i changed something: first of all the script is different:

<?php
class Example extends PHPUnit_Extensions_Selenium2TestCase
{
  protected function setUp()
  {
    $this->setBrowser('firefox');
    $this->setBrowserUrl('http://www.example.com/');
  }

  public function testTitle()
  {
    $this->url('http://www.example.com/');
    $this->assertEquals('Example WWW page', $this->title());
  }
}
?>

and i installed Xvfb so now i don't have the error that selenium has failed to start new browser session, but i'm having another error

PHPUnit_Extensions_Selenium2TestCase_WebDriverException: 
Unable to connect to host 127.0.0.1 on port 7055 after 45000ms. 
Firefox console output:
Error: no display specified

and i already tried with:

Xvfb :99 -ac -screen 0 1280x1024x24 &

and:

export DISPLAY=:99

i've fixed the "no display specified" error, the mistake was that selenium server was already running when i was starting Xvfb, so this are the steps (after Xvfb and selenium installation):

  • run Xvfb ( Xvfb :99 -ac -screen 0 1280x1024x24 & )
  • export display ( export DISPLAY=:99 )
  • run selenium ( java -jar selenium-server-standalone-versionNumber.jar )
  • run script ( phpunit namefile.php )

if selenium is already running you can stop it by:

localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer

now the script works