I am trying to run apache and nginx together. I want that apache should listen to port 8080 and nginx should listen to 80. For that, I have modified the ports.conf to Listen to 8080 and also modified the virtual host configuration. After restart, the server starts without any error but I am unable to access the url.


<VirtualHost *:8080>
  ServerName myproject
  ServerAdmin your@email.com

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

  ErrorLog /var/log/apache2/error.log
  LogLevel warn
  CustomLog /var/log/apache2/access.log combined
  ServerSignature On

<Location /svn>
   DAV svn
   SVNParentPath /svn

   AuthType Basic
   AuthName "Subversion Repository"
   AuthUserFile /etc/svnauth
   Require valid-user
   AuthzSVNAccessFile /etc/svnaccess

<Location /trac>
   SetHandler mod_python
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnvParentDir /trac
   PythonOption TracUriRoot /trac

   AuthType Basic
   AuthName "Trac"
   AuthUserFile /etc/svnauth
   Require valid-user



NameVirtualHost *:8080
Listen 8080

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443

<IfModule mod_gnutls.c>
    Listen 443

Do I need to change something else here?


Verify that there are no other Listen directives anywhere: grep -ri listen /etc/apache/*

Also show what netstat says apache IS listening on: netstat -plnt | grep http

Replace httpd with the name of the apache binary on your system

  • Replacing httpd did work – gentrobot Oct 20 '12 at 11:11

Did you try to access the url with the port behind? ....com:8080 ?

My guess is that you intended to configure nginx to be running as a reverce proxy, but you do not proxy the traffic you want to port 8080.

Can you please post your nginx config, too?


Make sure that nginx is not listening on 443. Or remove the Listen 443 from apache configuration.


Apache under debian and Ubuntu uses a seperate file

as already posted under

How to choose which IP apache2 uses globally

You can see that there is a ports.conf


For anyone repeatedly reading posts like these, then head-slapping when it doesn't work, the older posts refer to older versions of Apache.

The file you probably need to edit to change the port is: /etc/apache2/apache2.conf

Thanks to someone who posted a version of this, which let me identify my own problem:

grep -ri listen /etc/apache2/*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.