PHP environment in Pubweb
If you have done PHP development work in other environments, you should know about the following PHP environment gotchas on Pubweb.
Short open tags <?
Short open tags (<? as opposed to <?php) are not enabled on Pubweb.
This means you may need to modify old code or code you have borrowed or downloaded from other sources. When <? is used, the page is treated like XML and you will see the PHP code when visiting the page from a Web browser. Change these to <?php to make your pages parseable as PHP.
Be sure to search and replace through all of your code, not only the first instance in each file.
$_SERVER (server variables)
On Pubweb, use of SERVER variables (especially those that refer to host, port, path) will be wrong.
On Pubweb, your path looks like ~/public_html/yourapp/
but after it is proxied to www.ndsu.edu/yourapp/ the /pubweb/~yourID/ are removed. Thus, references to ~/public_html/yourapp/ or www.ndsu.edu/yourapp/ are incorrect.
Instead, you should configure your application using the paths that will exist after the proxy. The nature of this varies per site, depending whether you have an enhanced site, and per SERVER variable.
$HTTP_SERVER_VARS is not available at all. If you see instances of $HTTP_SERVER_VARS in your code, you should update with the $_SERVER format.
Ref: PHP $_SERVER
Array ( [SCRIPT_URL] => /~unixid/php.php Path missing /pubweb relative to www.ndsu.edu [SCRIPT_URI] => http://shingle.ndsu.nodak.edu:8080/~unixid/php.php [HTTP_HOST] => shingle.ndsu.nodak.edu:8080 Will be incorrect relative to www.ndsu.edu [HTTP_USER_AGENT] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:184.108.40.206) Gecko/20091016 Firefox/3.5.4 (.NET CLR 3.5.30729) [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 [HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5 [HTTP_ACCEPT_ENCODING] => gzip,deflate [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7 [HTTP_COOKIE] => Cookie info for www.ndsu.edu [HTTP_CACHE_CONTROL] => max-age=0 [HTTP_MAX_FORWARDS] => 10 [HTTP_X_FORWARDED_FOR] => IP address of the actual "person" visiting the proxied address [HTTP_X_FORWARDED_HOST] => www.ndsu.edu [HTTP_X_FORWARDED_SERVER] => www.ndsu.edu [PATH] => /sbin:/usr/sbin:/bin:/usr/bin [SERVER_SIGNATURE] => Apache/2.2.3 (Red Hat) Server at shingle.ndsu.nodak.edu Port 8080 [SERVER_SOFTWARE] => Apache/2.2.3 (Red Hat) [SERVER_NAME] => shingle.ndsu.nodak.edu [SERVER_ADDR] => 220.127.116.11 Pubweb's address [SERVER_PORT] => 8080 Pubweb's port [REMOTE_ADDR] => 18.104.22.168 www.ndsu.edu address, not the "person" visitor [DOCUMENT_ROOT] => /var/www/html Doesn't reference your home dir. as root [SERVER_ADMIN] => root@localhost [SCRIPT_FILENAME] => /home/unixid/public_html/php.php Pubweb path [REMOTE_PORT] => 48181 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /%7Eunixid/php.php Pubweb address [SCRIPT_NAME] => /~unixid/php.php Pubweb address [PHP_SELF] => /~unixid/php.php Pubweb address [REQUEST_TIME] => 1259350556 )
NULL (this is deprecated)
Array ( [_POST] => Array ( As appropriate ) [_GET] => Array ( As appropriate ) [_COOKIE] => Array ( [PHPSESSID] => ... etc. ) [_FILES] => Array ( As appropriate ) [php_errormsg] => Undefined variable: HTTP_SERVER_VARS Present here because this script last tried to reference $HTTP_SERVER_VARS )