How to publish multiple Laravel applications on Shared Server?

2

I have two independent applications made in Laravel I would like to host them on the same server, in separate directories.

I searched extensively in the documentation and forums, and managed to make only one application work correctly, however, all configuration files were vulnerable to access via URL and I do not want in any way to do the file-by-file configuration of what can and can not can be accessed in the .htaccess configuration file.

What is the best way to publish multiple applications in laravel on the same server?

    
asked by anonymous 19.02.2016 / 21:23

2 answers

3

Using an Apache server you can create Virtual Hosts, in which you can redirect a server URL to be served from another directory as mentioned in this apache documentation

# Ensure that Apache listens on port 80
Listen 80
<VirtualHost *:80>
    DocumentRoot "/www/example1"
    ServerName www.example.com

    # Other directives here
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/www/example2"
    ServerName www.example.org

    # Other directives here
</VirtualHost>

In this sample file two applications run on the same server with different urls and different directories, the URL does not necessarily have to be different domains, they may be just folders, I've done using only different folders.

The DocumentRoot for you will be the folder where the laravel is, the servername is your url. This is worth taking a look at the Aliases and Directory directives that control URL access.

Still regarding the configuration files because they are not in the public folder they should already be safe, if you think you need more security you can pass the settings to Apache as environment variables and accessing them through PHP with $ _ ENV .

If you are using NGINX it also allows this type of operation.

    
22.02.2016 / 15:55
0

If you are using cPanel with softaculous, try installing Laravel through the softaculous installer, not manually.

There will be a way to install in separate directories and softaculous will set everything up right.

    
28.02.2016 / 13:56