Documentation:PHP

From UGCS
Jump to: navigation, search

PHP Scripting

UGCS fully supports PHP 5 in any space accessible on the web (including virtual domains). You should write your pages as normal php- nothing special is required. We have a large set of libraries installed on our web servers, but don't hesitate to contact us if you need something we don't have.

Database Access

You can access your Postgres database from PHP scripts. You should connect with either

pg_connect("host=postgres user=<username>_cgi dbname=<username>");

or use the database URL (for DB or MDB2)

pgsql://<username>_cgi@postgres/<username>

It is essential that you not specify a password at all, otherwise you will not be able to connect. If you need a MySQL database because your software won't support Postgres, contact us. We have a patched version of mediawiki that will handle postgres correctly (normal versions always try to specify a password even if it is blank)- see Mediawiki on UGCS for more information.

Filesystem Access

Your scripts are run with AFS tokens for <username>_cgi. If you want a directory to be writeable to your php script, you must give <username>_cgi write permissions for it. See AFS for more help.

By default, all directories in ~/public are world-readable. If you do not want this for your php scripts, you can remove read access from the directory by setting the acl "system:anyuser none". However, you must ensure that the www-data user is able to read the directory ("www-data read").

php.ini

You can specify your own php.ini with your own settings if you want. Our script wrappers will give php-cgi ~/public/html/.php_ini as a configuration file if it exists. Note that if you change this and are running a vhost, you will have to wait for the existing fastcgi processes to die for your new one to be reloaded. If you need it to happen faster, let us know and we can kill them for you.

See Also

Personal tools