Home > Web hosting - Linux.

Web hosting - Linux.

Using PHP on the Linux web hosting platform

PHP is a fast and versatile scripting language that allows quick and easy addition of interactivity to your website. For those of you used to using ASP, it is very similar, but faster and more efficient. You can make database calls, output text and random variables, simple field includes (e.g. current date), as well as call files and templates from your webspace at Pulsant.
<? echo (“this is a simple script\n”); ?>

<?php echo(“if you want to serve XML documents, do like this\n”); ?>

<script language=”php”>
echo (“some editors don’t like processing instructions”);
</script>

As of December 2010, the version of PHP is 5.1.6. and full details of the version, available modules and configuration can be found at http://rhel5phpinfo.lumison.net/phpinfo.php

Note that if the global settings are not as required it is possible to overide many by adding settings to a .htaccess file, see the PHP documentation at http://www.php.net/ for full details.

In order to use PHP in your webpages, insert the PHP code into your webpage and upload it to your web space using a .php extension. If you would like an alternative file extension used then add the following command to a .htaccess file in the affected web directory or one of it’s parents (The example shown will cause .html files to be parsed).

AddType application/x-httpd-php html

Using SSI ( Server Side includes) on the Linux webhosting platform.

Writing CGI in perl means you can quickly add interactivity or deal with web forms. Whilst you may call a CGI either from a FORM or directly from an HREF, you may wish to include script output, or html, directly into a webpage.

Our web server can parse your html, to include either output from a script or other templates, using SSI (Server Side Includes) but you need to enable this first.

To enable SSI, for the default .shtml files, add the following line to a .htaccess file in the affected web folder or one of it’s parents :-

Options +Includes

If you would like to parse files with other extensions you can enable this by adding the following to your .htaccess
file (.html in this example) :-

AddOutputFilter INCLUDES .html

Once you have enabled parsing you can add includes into your file text as detailed in the following examples :-

<!–#include virtual=”anotherfile.html”–>
<!–#include virtual=”/somedir/anotherfile.txt”–>
…and in order to run scripts:
<!–#include virtual=”/cgi-bin/user/someone/myscript.cgi”–>

For complete documentation please check the Apache web site: http://www.apache.org/docs/mod/mod_include.html

Using GPG on the Linux webhosting platform.

GPG (or GNU privacy guard) is an application that allows you to sign/encrypt your data for transmission, by email, across the internet.

In order to use GPG you will need to have secure keys, which you can generate on our server or elsewhere and import it.

To generate a key, use the ‘–gen-key’ flag:

$ gpg –gen-key (and follow the instructions. In most cases choosing the default answers will be sufficient)

Import the public key of the person you are sending email to:-

$ gpg –import <keyfile name>

To encrypt a text file, with a key you hold, use:

$ gpg –out <encrypted file name> –recipient <uid> –armour –encrypt <original file name>

There are numerous options for connecting to GPG using Perl so we would recommend an internet search to find something that suites your programming style (e.g. http://www.perlmonks.org/?node_id=152489)

GPG is also supported by PHP as detailed at http://www.php.net/manual/en/book.gnupg.php

For more info on GPG see the documentation section at www.gnupg.org.

Adding MIME types to Apache, using .htaccess, on the Linux webhosting platform.

The web server’s list of filename extension to mime type mappings can be added to or overridden by customers on a per-account or per-directory basis using .htaccess files.

The syntax is: AddType mime/type extension

e.g.
AddType image/gif .gif
AddType audio/x-mpegurl .m3u

For more information please see: http://httpd.apache.org/docs/mod/mod_mime.html#addtype

Password-protecting web pages, using .htaccess, on the linux web hosting platform

Most of the time, if Pulsant hosts your website, you want the whole world to be able to see it in all its glory. However, there may be occasions where you want to prevent the world at large from accessing certain pages, such as a page just for a certain client or a company intranet only for employees.

For websites hosted on our Apache (UNIX) webserver it is possible for you to protect areas of your website yourself in two simple steps. NB To follow these instructions, you require shell access to your Pulsant account. If you do not have this or would like to know more about it,take a look at our shell server FAQ.

Step 1: Creating an access list

For any website to which you want to restrict access, you need to have a list of users who are allowed access to parts of the site. You can do this by creating a password file. It goes without saying that this file should be protected from prying eyes, so a good place to put it is in your home directory.

If you do not already have an .htaccess password file, type the following command at the shell prompt:

htpasswd -c /home/<accountname>/<passwordfile> <username>

where <accountname> is your Pulsant account name, <passwordfile> is the name of the password file you’re creating, and <username> is the name of the user for whom you’re adding the password. You will then be prompted for a password for that username.

NB if you have already created a password file and are just adding more users then use the above command without the -c option.

Please note that standard password encryption methods can only encrypt up to 8 characters, so while you can use a password longer than 8 characters, the remainder of the characters will be ignored.

Please refer to the shell command “man htpasswd” for more information.

Step 2: Locking a directory

The way to prevent unauthorised access to web pages is to keep them in a locked sub-directory of your public_html directory. To lock a sub-directory, you need to create a file in that directory called .htaccess. Below is a bare-bones, working .htaccess file which may be copied and pasted into a text editor:

AuthName “Realm”
AuthType Basic
AuthGroupFile /dev/null
AuthUserFile /home/<accountname>/<passwordfile>
require valid-user

where Realm (which should be in quotes) is a label which appears in the password protection dialog box for the directory you’re protecting, <accountname> is your Pulsant account name, and <passwordfile> is the name of your .htaccess password file from Step 1.

NB the line require valid-user will allow anyone in the password file access to the protected directory. If you wish to allow only certain specific people from the password list into a directory, you can achieve this by replacing the line with:

require user user1 user2 user3. . .

for as many users as you wish to allow. This is most useful if you wish to protect more than one directory, each with different users, but wish to maintain only one password file.

After the file is created in the directory, you will not see it because it is hidden from normal view of the ls command. To see hidden files, you must use ls -a.

Finally you need to type the following command, at the shell prompt, in the directory containing the .htaccess file:

chmod 644 .htaccess

Once this is done, your directory and any web pages in it are protected.

Server details for the Linux web hosting platform

Our Linux web hosting platform uses a loadbalanced server farm and should be accessed using the following host names.

FTP access

ftp.lumison.net, on port 21,  using your Linux webspace username/password.

SSH/SFTP Shell access

shell.lumison.net, on port 22, using your Linux webspace username/password.

DNS

If you have your DNS hosted elsewhere you will need to point your hostname at the shared web platform using a CNAME record pointing to vweb.lumison.net or, where a CNAME is not permitted, an A record of 87.246.107.166

Using Java servlets and JSP on the Linux web hosting platform.

Java Servlets and JSP

As of December 2010 the current version is Tomcat 5.5.23 supporting Servlet 2.3 and JSP 1.2 standards as published by Sun.

Setup

To purchase Tomcat hosting, and use on your site, please send an email to [email protected] with the following information :-

  • username and hostname for your site to associate the hosting with
  • confirmation of acceptance of cost – £100 plus vat/annum

Hosting will be setup within 24 hours of your request.

Uploads

A web application directory will be created for you as ‘ejava’, in your home directory, and used to store HTML, JSP and class files. These maybe uploaded in the usual way, using ftp or the Pulsant shell server.

The basic directory structure is as follows:

ejava/WEB-INF/web.xml Tomcat configuration file
ejava/WEB-INF/classes/* Servlet and library .class files
ejava/WEB-INF/lib/* Servlet and library .jar files
ejava/* Static or JSP pages

The full directory layout and configuration file format is described in the Tomcat Application Developer’s Guide.

Access

Your uploaded Java files will be accessible using the following URLs (substitute <your domain> and <your user name> as appropriate).

http://<your domain>/ejava/<your user name>/servlet/*
http://<your domain>/ejava/<your user name>/*.jsp

Development

Standard libraries on the default classpath include the Servlet library, Xerces, PostgreSQL and MySQL drivers. When compiling class files, it may be necessary to copy these on to your local classpath i.e. take a copy of the Jar file(s) from the Pulsant Library and upload to
/ejava/WEB-INF/lib.