Install FC6 and Apache Web Server

Stick the Fedora Core 6 DVD in and reboot. Then follow the instructions. I took all defaults where I can, including letting it “delete all Linux partitions” and automatically partition the disk. I choose to install “Web Server” and “Development Tools” when offered the chance. This installs the Apache Web Server 2.2.3 on the box.

Install Tomcat

Tomcat 5 is included in Fedora Core 6, but not installed by default. So I have to bring it in from the repository:

[root@root]# yum install tomcat5 tomcat5-webapps tomcat5-admin-webapps

This installs Tomcat 5.5.17 and a lot of their dependencies onto the system.

Read more

Virtual Hosting with Tomcat

January 7th, 2008No Comments  |  

This is a guide on setting up Tomcat to do virtual hosting and make it behave like a simple webserver with jsp and servlet support, for many different sites all hosted on the same IP address. The aim is to have a single directory for each virtual host, which can be manipulated individually without hassles from managing multiple .war files and other configuration difficulties.

To configure Tomcat for a virtual host, you need a directive in the server.xml file, and a ROOT.xml file in the conf/Catalina/$host directory. Here’s the minimal setup required for a copy of Tomcat serving directly on Port 80, using no connectors or other configuration difficulties.

This was written for Tomcat 5 on linux, with Tomcat installed in /usr/local/tomcat

We start with the simplest configuration, of one website, called ‘localhost’ which keeps it’s files in /usr/local/tomcat/webapps/localhost . We’re not using any .war files here – all the files are placed straight into the directory.

Read more

PHP – MySQL order by random

January 7th, 2008No Comments  |  

To select random rows from mysql database table, you can use below query:

Here, I’m trying to select a random row from a table in a MySQL database.

Syntax:

SELECT * FROM table_name ORDER BY RAND()

Creating Custom Error Messages in Apache

January 7th, 2008No Comments  |  

Below is an example of a httpd.conf file, just copy and paste into your file, but change the paths:

ErrorDocument 404 /path/to/your/error/file/or/script
ErrorDocument 500 /path/to/your/error/file/or/script
ErrorDocument 403 /path/to/your/error/file/or/script

A very important point to note is that the paths should be the relative paths. This means that the paths would be what you would type on the machine to get to the files, not what you would type in the address box in a browser.

Examples:
Full path would be http://www.yoursite.com/path/to/error/page
Absolute path would be /home/yoursite.com/path/to/error/page
Relative path would be /path/to/error/page