0

I have multiple web project in the same VPS as below:

/var/www/html/
│---webapp1/
│   │---public/
│   │   │---index.php
│---webapp2/
│   │---public/
│   │   │---index.php
│---index.html

I want to serve the webapp1 under 95.87.154.170:81 and webapp2 under 95.87.154.170:87.

I have tried to create virtual hosts /etc/apache2/sites-available/webapp1.conf:

<VirtualHost *:81>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/webapp1

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

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

and /etc/apache2/sites-available/webapp2.conf:

<VirtualHost *:87>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/webapp2

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

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

But it doesn't work when I visit 95.87.154.170:81 or 95.87.154.170:87 it shows ERR_EMPTY_RESPONSE. Both sites are enabled. My problem is I have only one IP and I don't have domain names. Is there any possibility to solve it in this way?

jAdex
  • 121
  • 2
  • Define `doesn't work`. The actual error message tells a lot about where the problem could be. Apart from that, get a domain. It costs next to nothing and allows you to use subdomains for the applications, so you don't have to meddle with different ports. – Gerald Schneider Mar 28 '19 at 13:54
  • One thing that stands you: you write that you created the config files in `sites-available`. In debian based systems this directory is only used indirectly. You need to create symlinks in `sites-enabled` to files in that dir (usually using `a2ensite webapp1; a2ensite webapp2; systemctl reload apache`). – Gerald Schneider Mar 28 '19 at 13:56
  • @GeraldSchneider, Yes I did it. – jAdex Mar 28 '19 at 13:57
  • Did you configure apache to listen on these ports? – Gerald Schneider Mar 28 '19 at 13:59
  • @GeraldSchneider, nope just did it works fine! – jAdex Mar 28 '19 at 14:01
  • Go and buy a domain name. – Michael Hampton Mar 28 '19 at 14:07
  • @lucifer, if you have solved your problem, please post your solution in an answer below. It will help others who come across your question. – ender.qa Mar 29 '19 at 16:06

0 Answers0