|
Tools
Keywords: web | php | cgi | ccgi | chmod
Summary: A guide for advanced users of the CGI service.
Advanced hosting services for our Residential and Business accounts are available from Pay As You Host - our hosting platform. 2. Common things to do in shell
5. Using PHP and Perl 6. Shell access 7. Temporary storage 8. Rewrite engine 9. 'C' and other compilers Advanced CGI GuideThis guide provides information for using the CGI service. It covers how to use shell access for setting up CGI scripts. There is also more advanced information about how the CGI platform operates, which is directed mostly at experienced users. See Advanced CGI Server settings.
To use your CGI service you will need to use a telnet or SSH client program. We recommend that you use PuTTy, which is free to download. Download PuTTy SSH Client 1. Setting up SSH access using PuTTy
You can check the required settings for Telnet/SSH access to your shell account. [Top] 2. Common things to do in shell
a. Check the path of your current directory
b. Check the path to your "home" directory 3. Advanced CGI Server settingsa. File and directory ownershipThe base ownership of files and directories are as follows: Owner: your username Group: nogroup These ownerships (particularly the 'group' ownership) need to be kept intact for any files and scripts you want to be accessible via the web. [Top] b. File permissions The base permissions you need on a file is chmod 740. Running scripts on the CGI platform will depend on setting the appropriate file attributes, these are the properties of each file that decide who can do what with the file. Incorrect setting of file permissions is a very common cause for CGI scripts to not work as expected - or to generate error messages. Always double check file permissions. All files on the CGI server have an 'owner' and belong to a 'group'. There will be a set of attributes that decide what the owner of the file can do, a set of attributes that decide what group members can do, and finally, a set of attributes that decide what everyone else can do.
A program called CHMOD (an abbrieviation of change mode) is used to change file permissions. For making PHP files executable we have provided a script called fixphpperms to help. There are two ways of using CHMOD.
Navigate to the directory containing the files or directories for which you want to set permissions. On the command line type - chmod (user)=(permission) (filename) user values u - the owner g - group o - other a - all (same as saying ugo) permission values r - read w - write x - execute example: On the command line, type: chmod u=x file.pl Sets the the execute permission for the file owner. On the command line, type: chmod a=rwx Sets read, write and execute for all users. For more information on using CHMOD, read the online manual by using the following command in your shell.
d. FTP Client CHMOD Within your FTP program, navigate in your "remote" window to the directory that contains the files for which you need to set permissions. All FTP programs may work slightly differently, we use CuteFTP as an example -
Note the Manual box provides a numerical version of the set permissions, this consists of a number between 0 and 7 for Owner, Group and All. Permission 755 indicates full permissions for the Owner, with just Read and Exectute permissions for Group and Other. [Top] e. Directory permissions The base permissions you need on a directory is chmod 750. Additionally, a special bit is set on the group permission that ensures all files you create in the directory are group-owned by the group nogroup. If this special bit is removed, files under that directory will be owned by the wrong group and you won't be able to access the contents via a web browser. Due to a security restriction which protects the system from published hacking attempts, you will NOT be able to add this bit back by yourself. [Top] f. Shell connections If you wish to use SSH to connect to the shell service, and your client supports different SSH protocols but does NOT use SSH2 by default, you must manually set your client to use SSH2 only. Attempts to use SSH1 will result in a "permission denied" error. [Top] 4. Operating systemOur CGI uses a Debian operating system. Debian is a very stable and secure OS, which offers a highly sophisticated package maintenance system. At the heart of the platform's security is the 'Jail' type Vserver mechanism. This has the ability to limit the functions available to any rogue user wanting to harm the system. Potential damage to the platform is then only limited to a small area, protecting other users.[Top] 5. Using PHP and Perla. General PHP informationPHP, along with all other forms of CGI runs as an executable program.. The reason for this is mod_php can not be used when you need scripts to run in a per-user context (that is, run a script as the user themselves). This means that PHP files now need to be executable for them to work (perl, python etc files have always required this). See our Beginners Guide to PHP Because of the way Linux works, PHP files can't be automatically created with the execute permissions set. For PHP files to work, they need to be executable both by the user, and by the group ownership (hence a base permission of 440 above) - this is easily done with the chmod utility. However, we have created a script on the shell server to help out. This is called fixphpperms.sh and lives in /usr/local/bin. It can fix a single file, all files and subdirectories from the current directory, or ALL php files in your homespace. Here is how it looks when run with no parameters: cshell02:/# fixphpperms.sh fixphpperms.sh - a script to add user executable bit to .php files you own On the command line, type: fixphpperms.sh (where) (where) values (indicating the location in which php files will be fixed) -c - php files in your current directory AND all subdirs -r - php files from your homedirectory down -s - php files in your current directory only example: fixphpperms.sh -s Will fix all .php files that are located in your current directory. [Top] b. Writing scripts User's scripts can write directly to the user's CGI space. This means that you can protect your own areas with secure chmod settings. This prevents user's scripts from accessing other user's areas. It also limits the impact of any exploitable CGI scripts to only the area of the affected user, not all user's areas. [Top] 6. Shell accessTo maintain overall security shell access is no longer available for compiling or installing directly onto the live CGI platform. However a test server is available.a. Test Server A separate test server for shell and home directory access is available to use. This provides a more secure way to compile and install programs in your own home directory and then test them on the live platform. User accounts are provided with secure settings when the account is created. [Top] 7. Temporary storageTemporary (/tmp) storage is available, however, we do not encourage using it. We cannot guarantee the security of any data held within /tmp, nor can we guarantee the data won't be periodically cleared without warning. It is much better to get your scripts to write to a temporary directory within the security of your own home directory.[Top] 8. Rewrite engineThe rewrite engine ensures that http headers don't get broken. It allows the header to contain both a port as well as an address.[Top] 9.'C' and other compilersThe ability to compile scripts is available, although this activity is restricted to the shell platform only, which has your CGI space mounted and available. The shell platform is only available from within Plusnet IP ranges.[Top]
Has this page helped you solve your problem? Your feedback helps us to improve the help we provide.
Please note: We
cannot reply to individual feedback through Rate My Page. If you need
more help with a problem please use the Help
Assistant. Other customers will be happy to help you with most issues
at the Community Site
Forum.
|
Search help pages
Browse A-Z help index
|
We sell broadband, phone, VoIP and more to homes and businesses in the UK. Winner of 9 out of 11 Categories in the 2008 USwitch survey. Winner of "Best Consumer ISP" at 2008 ISPA awards. Voted number 1 in the Broadband Choices 2008 survey.
© Plusnet plc All Rights Reserved. E&OE