How to publish multiple Laravel applications on Shared Server?

Asked

Viewed 1,376 times

2

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

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

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

2 answers

3


Using an Apache server you can create Virtual Hosts, where 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 example file two applications run on the same server with different urls and different directories, the URL does not necessarily need to be different domains, may be just folders, I’ve done using only different folders.

The Documentroot for you will be the folder where the Windows is, the servername is your url. For this it is worth taking a look at the Alias and Directory directives that control access to URL.

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

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

  • I managed to solve this problem easily using Jelastic service from Locaweb. Thank you very much.

0

If you’re using cPanel with Softaculous, try installing Laravel through the Softaculous installer, not manually.

Ai will have way to install in separate directories and Softaculous will set everything straight.

Browser other questions tagged

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