I have a website that I have hosted in /var/www/html
. I was able to access it using my.ip.add.res
. Now I want to be able to access it from multiple ports. I mean all three URLs, my.ip.add.res:80
, my.ip.add.res:8000
and my.ip.add.res:8950
, in the browser should lead to the same website.
What I tried:
Step 1: In /etc/apache2/ports.conf
file, Listen 80
was already there. I added Listen 8000
and Listen 8950
. The file looks like:
Listen 80
Listen 8000
Listen 8950
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
Step 2: In /etc/apache2/sites-available
directory, there was a file 000-default.conf
. I copied it to two files: myservice1.conf
and myservice2.conf
. I changed the first statement, VirtualHost *:80>
to VirtualHost *:8000>
and VirtualHost *:8950>
in myservice1.conf
and myservice2.conf
files, respectively.
Step 3: I established symbolic links of these files to the corresponding files in /etc/apache2/sites-enabled
. This is what I mean:
root@virtual-machine:/etc/apache2/sites-enabled# ls -l
total 0
lrwxrwxrwx 1 root root 35 Jul 7 09:18 000-default.conf -> ../sites-available/000-default.conf
lrwxrwxrwx 1 root root 46 Aug 22 11:45 loginservice.conf -> /etc/apache2/sites-available/loginservice.conf
lrwxrwxrwx 1 root root 44 Aug 22 11:44 scfservice.conf -> /etc/apache2/sites-available/scfservice.conf
Step 4: Then I restarted the Apache2 server
root@virtual-machine:/etc/apache2/sites-enabled# /etc/init.d/apache2 restart
[ ok ] Restarting apache2 (via systemctl): apache2.service.
The result is:
my.ip.add.res
: leads to correct website
my.ip.add.res:80
: leads to correct website
my.ip.add.res:8000
: Unable to Connect
my.ip.add.res:8950
: No such resource (even if I stop the server ... surprising)
What is it that I am doing wrong or missing?
Edit1: As suggested by jedifans, I tried apachectl -S
. below is the output.
root@virtual-machine:/etc/apache2/sites-available# apachectl -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
*:8950 127.0.1.1 (/etc/apache2/sites-enabled/loginservice.conf:1)
*:8000 127.0.1.1 (/etc/apache2/sites-enabled/scfservice.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
Edit 2:
root@virtual-machine:/etc/apache2/sites-available# telnet 127.0.0.1 8000
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
root@virtual-machine:/etc/apache2/sites-available# telnet 127.0.0.1 8950
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
# gets stuck here. I have to ctrl + C to come out.