Port Mapping and Apache Virtual Host

Posted August 11, 2014 13.3k views

I would like to maintain port 80 for Apache2 to handle freepbx and sugarcrm portal). how could I set up 000-default.conf? If I can’t use port 80 for 2 portals, can I do port mapping such as Once I port map which part of the firewall must I set up to reflect it? iptables or csf or ufw?

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.

Submit an Answer
1 answer

There are a number of ways to approach this. Do you have a domain name for your server? If so, the best way to serve both FreePBX and SugarCRM on port 80 would be to use subdomains. could point to your FreePBX instance while can point to SugarCRM. This article should point you in the right direction.

If that’s not an option, you can edit your Apache VirtualHost to simply listen on a different port. In your FreePBX’s VirtualHost, just change 80 to 8081

Listen *:8081
<VirtualHost *:8081>

    ErrorLog /var/log/apache2/freepbx.error.log
    CustomLog /var/log/apache2/freepbx.access.log combined
    DocumentRoot /var/www/freepbx

    <Directory /var/www/freepbx>
        Options Indexes FollowSymLinks MultiViews
        Order allow,deny
        AllowOverride All
        Allow from all

FreePBX’s will now be available at your.ip.address:8081

As far as firewalling goes, csf and ufw are actually both just wrappers around IP Tables. You just need to open port 8081. With ufw, that would be:

sudo ufw allow 8081/tcp
by Justin Ellingwood
The Apache web server is the most popular way to serve web content on the internet. Apache has the ability to serve multiple domains from a single server by using a mechanism called "virtual hosts". If a virtual host is configured correctly for each domain, the web server can correctly route traffic to the appropriate files based on the domain name requested. In this guide, we'll demonstrate how to configure Apache virtual hosts on an Ubuntu 14.04 VPS.
  • thanks for your detailed information and makes me understand the concept of ufw (I usually will go to Linksys router to set the port mapping rule). I followed your second option and got freepbx to work on port 8081.

    I followed faithfully the sugarcrm installation guideline and set up all the file permission but when I did http://ip/sugarcrm, the browser found http://IP/sugarcrm/install.php, but the screen is blank for firefox and chrome, but IE complained HTTP 500. Anything that I should look out for?

  • A blank page or a 500 error usually means that there was an error. Check apache’s error log – do you see anything?

    sudo tail -30 /var/log/apache2/error.log