Best way to Run Selenium tests with PHP+Apache?

I have a test project that tries to run a selenium test using phpunit. The selenium standalone runs as a service. It seems that php-webdriver is able to accesss the selenium service but I keep getting this:

Facebook\WebDriver\Exception\WebDriverException: JSON decoding of remote response failed.

Error code: 4
...some HTML code ...
    <p>
      Whoops! The URL specified routes to this help page.
    </p>

Here is the relevant part of my workflow file:

  test:
    needs: build
    runs-on: ubuntu-latest
    container:
      image: php:7.4-apache
    env:
      TEST_BASE_URL: http://localhost
      SELENIUM_HOST: http://selenium:4444

    services:
      selenium:
        image: selenium/standalone-chrome
        options: --health-cmd "curl http://selenium:4444" --health-interval=5s
        ports: 
          - 4444:4444

    steps:
 
    - name: Download built files
      uses: actions/download-artifact@v2
      with:
        name: www-build

    - name: Extract artifacts
      run: |
        tar -xzf www-build.tar.gz
        ls -l

    - name: Copy files to web root
      run: |
        cp -R ./www/* /var/www/html

    - name: Restart apache server
      run: service apache2 restart

    - name: Check if site is accessible
      run: curl $TEST_BASE_URL

    - name: Run Test
      run: ./vendor/bin/phpunit test

What am I doing wrong? Is there a better way to do this?

Finally figured it out myself. What was happening was I was using the wrong URL for the selenium hub. I also then ran on to the problem of the selenium service unable to access the php:7.4-apache server (localhost from the selenium server refers to itself, duh). The relevant changes I made were:

The relevant section on the workflow has been changed to this:

  test:
    needs: build
    runs-on: ubuntu-latest
    container: 
      image: php:7.4-apache
      ports: 
        - 80:80
      options: --network-alias=testserver 

    env:
      TEST_BASE_URL: http://testserver
      SELENIUM_HOST: http://selenium:4444/wd/hub

    services:
      selenium:
        image: selenium/standalone-chrome
        # options: --health-cmd "curl http://selenium:4444" --health-interval=5s
        ports: 
          - 4444:4444
    steps:
    - name: Download built files
      uses: actions/download-artifact@v2
      with:
        name: www-build

    - name: Extract artifacts
      run: |
        tar -xzf www-build.tar.gz
        ls -l

    - name: Copy files to web root
      run: |
        cp -R ./www/* /var/www/html

    - name: Restart apache server
      run: service apache2 restart

    - name: Check if site is accessible
      run: |
        curl $TEST_BASE_URL

    - name: Run Test
      run: ./vendor/bin/phpunit test