Question

Ubuntu droplet, Apache2 - port won't open

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 

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
November 25, 2019
Accepted 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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel