How to configure multiple systems in a domain?

0

I have domain www.mysite.com

I would like to host multiple systems in this domain. Staying like this:

www.mysite.com/system1

www.mysite.com/system2

www.mysite.com/system3

I use virtualhost like this:

<VirtualHost *:80>
  ServerName meusite.com.br
  ServerAlias www.meusite.com.br
  ServerAdmin [email protected]
  DocumentRoot "/var/www"   


Alias /sistema1 "/var/www/sistema1/public"
   <Directory "/var/www/sistema1/public">
     AllowOverride All
     Options Indexes FollowSymLinks MultiViews
     Order deny,allow
     Allow from all
   </Directory>

Alias /sistema2 "/var/www/sistema2/public"
   <Directory "/var/www/sistema2/public">
     AllowOverride All
     Options Indexes FollowSymLinks MultiViews
     Order deny,allow
     Allow from all
   </Directory>

I change the .htaccess of each of the projects to this:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    Options +FollowSymLinks
    RewriteEngine On
    **RewriteBase /sistema1**

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

The system is all in laravel. It's working that way up, though, I guess that's not the right approach. In another project we are using, it is displaying errors in the ajax url's. I am a student and need to configure this university server to host other systems in that domain.

Could you tell me which approach to use or what should I start studying? I do not know much, I need a direction.

    
asked by anonymous 24.10.2017 / 23:17

1 answer

0

Each system with its own subdomain and VirtualHost for each:

<VirtualHost *:80>
    ServerAdmin [email protected]

    ServerName sistema1.meusite.com.br

    DocumentRoot /var/www/sistema1/public
    ErrorLog ${APACHE_LOG_DIR}/sistema1-error.log

    <Directory /var/www/sistema1/public>
            Options -Indexes
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

And the next one is:

<VirtualHost *:80>
    ServerAdmin [email protected]

    ServerName sistema2.meusite.com.br

    DocumentRoot /var/www/sistema2/public
    ErrorLog ${APACHE_LOG_DIR}/sistema2-error.log

    <Directory /var/www/sistema2/public>
            Options -Indexes
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

And each virtualhost with a different configuration file:

/etc/apache2/sites-available/sistema1.conf

/etc/apache2/sites-available/sistema2.conf

It may seem to be laborious to keep pointing to many DNS records, but this approach separates each of the applications efficiently. You can even activate and deactivate any of them without affecting the whole.

And if you have to share the core of the application between all point everything to the same directory and your system should check which is the right hostname and work with the correct data. (Would not recommend)

And finally, you can write a Shell Script that automates the creation of these configuration files.

And still you do not stop using a single domain, you're just using it differently than you originally thought.

    
24.10.2017 / 23:28