Apache configures different host applications to use the same IP and the same port

Solution for Apache configures different host applications to use the same IP and the same port
is Given Below:

For example, I have an external network ip118.16.132.42 and port 80

Flask1 and flask2 project applications are deployed at / var / www,

I want to enter different project applications through different application names

For example, can the application from to flask1 and to flask2 be realized

Here is the application path


When you host more than one site on your web server, the best way is to set correctly the virtual host files for your each of the sites you want to publish.This means that when someone views your site the request will travel to the server, which in turn, will determine which site’s files to serve out based on the domain name.

As I see you’ve already have created a directory for each application you want to deploy and I’m assuming your applications are already stored on these directories, so you’re all set with the first Step.


Your next step would be to create a configuration file for each website and store it in /etc/apache2/sites-available/. On this directory Apache has a default configuration file named 000-default.conf which you can use to create your own configuration:

cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/flask1.com.conf

cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/flask2.com.conf

Once you create the config file for each site, you will just have to edit this file with the ServerName and DocumentRoot, which should point to the directory where your app will be stored.

vim /etc/apache2/sites-available/flask1.com.conf

<VirtualHost *:80>
ServerAdmin [email protected]
ServerName flask1.com
ServerAlias www.flask1.com
DocumentRoot /var/www/flask1
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

For our final step is to enable the configuration files you’ve created for flask1.com.conf and flask2.com.conf so your server will be mapped to your domains

a2ensite flask1.com.conf
a2ensite flask2.com.conf

Restart your Apache server

systemctl restart apache2


As per Apache official documentation, creating virtual host configurations on your Apache server does not magically cause DNS entries to be created for those host names. You must have the names in DNS, resolving to your IP address, or nobody else will be able to see your web site. You can put entries in your hosts file for local testing, but that will work only from the machine with those hosts entries.