Take the 2-minute tour ×

I want to run different web app on different ports on same server, I have a apache php server running on a Linux machine. How can I achieve this ? and when I Google I stumble upon 'tomcat', what is this ? I am a noob, so please forgive if that is a stupid question.

share|improve this question

3 Answers 3

Check the apache manual for the VirtualHost directive. It'll explain everything.

One thing to remember (it caught me out first time) - if you use virtual hosts, you have to define a virtual host for the default page too.

Don't worry about Tomcat at the moment. If you don't know what it is, you don't need it yet.

share|improve this answer

Add one line to your Apache server's httpd.conf file, somewhere near the existing Listen line:

Listen 8080

Where 8080 is the port number. After restarting Apache, it will start listening at port 8080 as well. You can then place your apps inside different directories under document root.

share|improve this answer
But this will only allow the default page to be accessed via a different port. The OP wants to run different web apps on a single server. The sensible solution is a virtual host which can have a completely self-contained application without the risk of picking upa file from a different folder by use of .. etc –  DaveyBoy Apr 16 '12 at 10:21
This will allow entire document root to be accessible via different port. OP specifically asked for different ports (perhaps for some good reason) hence this answer. Two isolated virtual hosts can easily be added on top of this solution (e.g. foo.domain.com:8080 and bar.domain.com:8081). –  Salman A Apr 16 '12 at 10:50
The OP asked 'to run different webapp on different ports on same server'. Publishing the full document root under another port and putting a different webapp in a sub-folder achieves nothing. A different webapp could be a dev/test version which has a completely different layout and library set but achieve the same thing as the main webapp. A virtual host allows this and removes any possibility of using http://example.com:8080/app2/../index.html or something similar –  DaveyBoy Apr 16 '12 at 11:00

Step 1: Install the Tomcat files


Step 2: Make directories for each instance






share|improve this answer
The OP isn't asking how to install Tomcat (they don't actually know what it is), rather asking how to run multiple PHP apps (or web sites) on a single machine with different ports. –  DaveyBoy Apr 16 '12 at 9:27

Your Answer


