How to configure multiple systems in a domain?

Asked

Viewed 153 times

0

I have domain www.meusite.com.br

I would like to host several systems in this domain. So:

www.meusite.com.br/system1

www.meusite.com.br/system2

www.meusite.com.br/sistema3

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 for 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 is working this way above, however, I think it is not the right approach. In another project we’re using, it’s showing errors in the url’s of ajax calls. I am a student and I need to configure this university server to host other systems in this domain.

Could you advise me on which approach to use or what I should start studying? I don’t have much knowledge, I need a direction.

1 answer

0


Each system with its own subdomain and a VirtualHost for each one:

<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 laborious to point out many DNS records, but this approach efficiently separates each of the applications. Can even enable and disable any of them without affecting the whole.

And if you have to share the core of the application among all point everything to the same directory and your system should check which is the right hostname and work with the right data. (I wouldn’t recommend)

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

And yet you don’t stop using a single domain, you’re just using it differently than you initially thought.

  • Thank you for your attention. I will do as you said, but the problem is the coordinator wants the addresses to be as I said: www.meusite.com.br/system1 etc. It is possible to do otherwise than I did ?

  • I would present to your coordinator the advantages in security issues of isolating one application from another, but thinking about the solution you are proposing I believe that the Rewritebase configuration does not have to have asterisks. Tell me more about the behavior that happens when you run this configuration that I try to help you..

  • Friend, manage to solve my problem with regard to ajax urls. I will propose what you told me. Hug

Browser other questions tagged

You are not signed in. Login or sign up in order to post.