FAS IT’s web site helpfully points out that their servers support PHP “in cgi-mode,” but does not explain what that means. What follows are three fairly straightforward steps for setting up PHP in your FAS web space. This assumes some basic UNIX knowledge. If you lack it, find a friend to help you.
- SSH into fas.harvard.edu and create a public_html directory if you don’t already have one. Make sure it has permissions 755. Also make sure your home directory is world executable.
- Copy the PHP binary into your public_html directory (note: this file is nearly 5MB in size and will count towards your quota). Since it is stored on the web servers but not the shell servers, you need to do this by creating a CGI script and visiting it in your web browser. This one does the trick:
#!/bin/sh cp `which php` php.cgi && chmod 755 php.cgi
After using it once, delete it. You should now have a php.cgi executable in your public_html directory.
- Create an .htaccess file to tell the web server how to server your PHP files. It should look like this:
Options +ExecCGI AddHandler application/x-httpd-php .php Action application/x-httpd-php /~youruser/php.cgi
Now create PHP files as you normally would and they should work fine without any special permissions or modifications. Tada!