install multiple Laravel 4 projects to sub directories

前端 未结 2 1748
南方客
南方客 2021-02-06 13:55

I\'m trying to upload multiple Laravel 4 projects to my web server, not my development server. Each laravel 4 app is housed in their own subdirectory. How should my file structu

相关标签:
2条回答
  • 2021-02-06 14:28

    Looks like my development structure here is exactly what you're trying to do. So I have this folder structure:

    var
    |-- www
        |-- Store
        |    |-- app 
        |    |-- bootstrap 
        |    |-- ...
        |-- blog
             |-- app 
             |-- bootstrap 
             |-- ...
    

    This is my VirtualHost file /var/www/Store/vhost.conf:

    Alias /Store "/var/www/Store/public"
    <Directory /var/www/Store>
      Options Indexes Includes FollowSymLinks MultiViews
      AllowOverride AuthConfig FileInfo Indexes
      Order allow,deny
      Allow from all
    </Directory>
    

    Yeah, I put it in my project folder and add an include in /etc/apache2/apache2.conf:

    Include /var/www/Store/vhost.conf
    

    This is my .htaccess file:

    <IfModule mod_rewrite.c>
        #Options -MultiViews
        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /Store/index.php/?$1 [L]
    </IfModule>
    

    And I just have to hit

     http://server.dev/Store
    

    or

     http://[ipaddress]/Store
    

    To see it.

    I've built a small script to do all that for me: https://github.com/antonioribeiro/laravel-installer. It downloads, installs, configures and boot a Laravel application in whatever folder I need to, doing whatever is necessary. Compatible with Debian based distros, like Ubuntu.

    EDIT

    Note that there are two things that remove the /public and the /index.php from your url:

    1) the /Store pointing directly to your public folder:

    Alias /Store "/var/www/Store/public"
    

    2) and the rewriting rule to keep your url clean from the index.php:

    RewriteRule ^(.*)$ /Store/index.php/?$1 [L]
    
    0 讨论(0)
  • 2021-02-06 14:41

    move all content include index.php in each public directory to Store, Blog and Newspaper respectively. and change the following line:

    require __DIR__.'/../bootstrap/autoload.php';
    
    $app = require_once __DIR__.'/../bootstrap/start.php';
    

    to

    require __DIR__.'/bootstrap/autoload.php';
    
    $app = require_once __DIR__.'/bootstrap/start.php';
    

    good luck.

    EDIT: Sorry. You have to edit /bootstrap/paths.php as well, change

     'public' => __DIR__.'/../public',
    

    to

    'public' => __DIR__.'/../',
    
    0 讨论(0)
提交回复
热议问题