Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
575 views
in Technique[技术] by (71.8m points)

php - Multiple Laravel 5 projects on the same domain

I got several Laravel 5 projects running on subfolders, on the same domain.

Each Laravel application is generating it's own session cookie, and sometimes it generates so much that we get http 400 errors on the entire domain.

Should I share the storage folder between all those projects, or there's any settings to prevent that to happen?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Each Laravel installation should be located in its own directory.

Then an alias needs to be defined which points the domain sub-folder to the "child" Laravel folder.

Example in Apache http.conf:

<VirtualHost some.domain:80>

    ServerName some.domain

    ## Path to laravel domain
    DocumentRoot "/path/to/some/domain/laravel-1/public"
    <Directory "/path/to/some/domain/laravel-1/public">
        AllowOverride All
    </Directory>

    ## Path to laravel sub-folder
    Alias /laravel-2-path-alias/ "/path/to/some/domain/laravel-2/public"
    <Directory "/path/to/some/domain/laravel-2/public">
        AllowOverride All
    </Directory>

</VirtualHost>

For session cookies, check configsession.php in both installations.

Root installation configsession.php:

'cookie' => 'a_unique_name'
'path' => '/',

Subfolder installation configsession.php:

'cookie' => 'another_unique_name'
'path' => '/path/to/sub/folder',

This should ensure that each installation is writing its own unique session cookies. Any cookies generated by the sub application should not interfere with those of the parent.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...