Search code examples
phpspawn-fcgi

How to get Hello World to work with Spawn-fcgi and php


I am trying to run a spawn-fcgi script for php but I get the below error.

spawn-fcgi -n -d /home/ubuntu/workspace/Gold-Lantern/glPixelServer/php/ -s /tmp/nginx9010.socket -u www-data -f /home/ubuntu/workspace/Gold-Lantern/glPixelServer/php/pixel.php
/home/ubuntu/workspace/Gold-Lantern/glPixelServer/php/pixel.php: 1: Syntax error: newline unexpected

Below is the contents of the script:

<html>
<head>
<title>My First PHP Page</title>
</head>
<body>
<?php
echo "Hello World!";
?>
</body>
</html>

Solution

  • Solution #1: Your first line should be:

    #!/usr/bin/php
    

    and make sure the permissions are set to execute (chmod a+x )

    Solution #2: Change the launch command to:

    ... -u www-data -f /usr/bin/php /home/ubuntu/workspa...