Ubuntu droplet, Apache2 - port won't open

November 24, 2019 68 views
Apache

I am trying to open a port on the droplet, to add a second site which I want to access via ip:port (in my case port 8000). I have this config files:

main.conf

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/VetPartnersPrintPortal/public

        <Directory /var/www/html/VetPartnersPrintPortal/public>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>

</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/VetPartnersPrintPortal/public

    <Directory /var/www/html/VetPartnersPrintPortal/public>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <IfModule mod_dir.c>
        DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
    </IfModule>

</VirtualHost>

slider.conf

<VirtualHost *:8000>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/slider/

        <Directory /var/www/html/slider/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>

</VirtualHost>

ufw status give following:


Status: active

To                         Action      From
--                         ------      ----
22/tcp                     LIMIT       Anywhere                  
443/tcp                    ALLOW       Anywhere                  
80/tcp                     ALLOW       Anywhere                  
22                         ALLOW       Anywhere                  
8000                       ALLOW       Anywhere                  
8000/tcp                   ALLOW       Anywhere                  
22/tcp (v6)                LIMIT       Anywhere (v6)             
443/tcp (v6)               ALLOW       Anywhere (v6)             
80/tcp (v6)                ALLOW       Anywhere (v6)             
22 (v6)                    ALLOW       Anywhere (v6)             
8000 (v6)                  ALLOW       Anywhere (v6)             
8000/tcp (v6)              ALLOW       Anywhere (v6)

What am I doing wrong here? The main site can be accessed, but slider is giving an error:


Unable to connect

Firefox can’t establish a connection to the server at 
1 Answer

Hello,

I think that you would need to add port 8000 as a Listen port as well so that Apache listens on that port before you could use it in your Vhost.

To do that open this file:

/etc/apache2/ports.conf

And bellow the Listen 80 line add Listen 8000 and then restart Apache:

systemctl restart apache2

To check if Apache is listening on the port run:

netstat -plant | grep 8000

Then the Vhost setup that you have should work as expected.

Hope that this helps.
Regards,
Bobby

Have another answer? Share your knowledge.