h_dml
h_dml

Reputation: 75

Run 2 different apache servers on the same machine with different ports?

I would like to know if it's possible to have two apache server and able to set it for two different port, for example: 192.168.0.1:80 and 192.168.0.1:81. If it is possible, how to do it? For information, I'm on an ubuntu server machine.

Upvotes: 1

Views: 862

Answers (3)

onxx
onxx

Reputation: 1447

Here is what worked for me in ubuntu 2x you need edit the following files:

Assumption is you already have a mysites.conf or 000-default.conf file working, and your local ufw or iptables are open for the new port you want to listen on.

/etc/apache2/ports.conf # add in the ports you need to listen

 Listen 80
 Listen 81

/etc/apache2/sites-available/yoursites.conf # of 000-default.conf

<VirtualHost *:80>
    DocumentRoot "/www/app1"

    # Other directives here
</VirtualHost>

<VirtualHost *:81>
    DocumentRoot "/www/app2"

    # Other directives here
</VirtualHost>

systemctl reload apache2

Upvotes: 0

zeeshan4it
zeeshan4it

Reputation: 1

I have 2 different apache servers installed on same PC but only one works at a time. I tried to set port 8080 for first server and port 80 for second one and tried to start both but only one works at a time. So my answer is No you cant unless you run second via VM. If it really works then share solution with me as well.

Upvotes: 0

mister_cool_beans
mister_cool_beans

Reputation: 1533

Yes it is possible by configuring virtual hosts in apache, something like this...

    Listen 80
    Listen 81
    
<VirtualHost *:80>
    DocumentRoot "/www/app1"

    # Other directives here
</VirtualHost>

<VirtualHost *:81>
    DocumentRoot "/www/app2"

    # Other directives here
</VirtualHost>

Upvotes: 1

Related Questions