Question

I want to be able to run apache on two ports having two different document roots one with var/www folder and another with some other folder.Below is my default file in sites available. But whenever I hit 127.0.0.1 the index in the first virtual host gets displayed. I want to be able to access index in /home/somefolder/tmp if I hit 127.0.0.1:8080 url but instead i get "Browser could not connect to 127.0.0.1:8080". What am I missing?

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

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

    DocumentRoot /home/somefolder/tmp
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

Was it helpful?

Solution

You need to make sure that Apache is setup to listen on port 8080, therefore you will need

Listen 8080

and

NameVirtualHost *:8080

set in your main configuration, which will vary from distro to distro.

You can check what ports Apache is listening on using the following command:

sudo netstat -ntlp | egrep 'apache|httpd'

Sounds like you'll see 80 in there but not 8080.

OTHER TIPS

Try this,

Listen 80
Listen 8080

NameVirtualHost 127.0.0.1:80
NameVirtualHost 127.0.0.1:8080

<VirtualHost 127.0.0.1:80>
#ServerName eightzero.com
DocumentRoot /var/www/
</VirtualHost>

<VirtualHost 127.0.0.1:8080>
#ServerName eightzeroeightzero.com
DocumentRoot /var/www-8080
</VirtualHost>

I hope this will help you. Try to do a prompt restart/reload of httpd/apache2 after making changes with apache conf file. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top