---
title: "Java CGI Tomcat Apache PHP MySQL on Ubuntu - Easy Steps"
description: "Quick steps to set up LAMP stack and CGI on Ubuntu. Practical notes and code examples on Java CGI Tomcat Apache PHP MySQL."
url: "https://h3manth.com/scribe/java-cgi-tomcat-apache-php-msql-on-ubuntu-easy-steps/"
canonical_url: "https://h3manth.com/scribe/java-cgi-tomcat-apache-php-msql-on-ubuntu-easy-steps/"
markdown_url: "https://h3manth.com/scribe/blog/java-cgi-tomcat-apache-php-msql-on-ubuntu-easy-steps.md"
publishDate: "2008-11-27T00:00:00.000Z"
author: "Hemanth HM"
category: "cli"
tags: ["linux","java"]
word_count: 188
reading_time_minutes: 1
x_markdown_tokens: 403
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# Java CGI Tomcat Apache PHP MySQL on Ubuntu - Easy Steps

> Quick steps to set up LAMP stack and CGI on Ubuntu. Practical notes and code examples on Java CGI Tomcat Apache PHP MySQL.

Instead of giving introductions and speeches, I would love to tell you only the steps.

P.S: You have to be root while executing the commands mentioned below.

## LAMP

```bash
apt-get update
sudo apt-get install apache2 php5 mysql-server-5.0 phpmyadmin
# Wait till its done

sudo gedit /etc/apache2/apache2.conf
```

Step 4 will open a text file for you. Paste the below to the end of the file, save and exit:

```apache
# Enable PHPMyAdmin
Include /etc/phpmyadmin/apache.conf
```

Restart Apache:

```bash
sudo /etc/init.d/apache2 restart
```

**Check if you were right till now:**
- http://127.0.0.1 → webpages
- http://127.0.0.1/phpmyadmin → database administration

## CGI

```bash
sudo aptitude install libapache2-mod-perl2
sudo rm -r /usr/lib/cgi-bin
sudo mkdir /var/www/cgi-bin  # if it fails use -p option
cd /usr/lib/
sudo ln -s /var/www/cgi-bin/ cgi-bin
```

**Check if you were right till now:**

```bash
cd /var/www/cgi-bin
sudo gedit test.pl  # a text file opens
```

Paste the below, save and exit:

```perl
#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
print "I love Linux\n";
```

```bash
sudo chmod a+x test.pl
```

Go to `localhost/cgi-bin/test.pl` in a browser.

It must say "I love Linux"

**That's it :) Enjoy Programming :)**
