Thursday, June 21, 2012

Open 2 Ports in Ubuntu Apache Web Server

Basically, it is impossible to open 2 ports at same time in an Apache process.
You need to understand that you will create a "virtual" web server to answer multiple ports.

Anyway, let's open the ports.


/etc/apache2/ports.conf

NameVirtualHost *:80
NameVirtualHost *:8000
Listen 80
Listen 8000

port 80 and port 8000 are opened, but port 8000 will not work even though you may see it as opened.

Create a "virtual" web server to answer port 8000.

Edit following;

/etc/apache2/sites-enabled

You may see a long configuration like...


<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks

        ...........................

</VirtualHost>

Copy all text, and paste it at the bottom of the file.
And change the second virtual host's port as 8000.

 
<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www

        ...........................

</VirtualHost>
< VirtualHost *:8000>
        ServerAdmin webmaster@localhost


        ...........................

</VirtualHost>

That's it.

You can access 2 port after a restart.

sudo service apache2 restart



No comments:

Post a Comment