如何在同一个域上运行Laravel的多个实例?

时间:2016-06-23 21:34:23

标签: php apache .htaccess laravel laravel-5

我在Windows Server 2012上运行Apache 2.4,在端口8080上运行PHP 5.6.23。

假设我的服务器的域是“serv1.example.com”我需要使用以下链接运行3个Laravel实例productionstagingdev

serv1.example.com:8080/production
serv1.example.com:8080/staging
serv1.example.com:8080/dev

我找到了另一个似乎做同样事情的SO question。但当我尝试做同样的事情时,我得到以下错误

Forbidden

You don't have permission to access /dev on this server.

这是我到目前为止所做的。在我的httpd-vhosts.conf文件中,我添加了以下VirtualHost

<VirtualHost *:8080>

    ErrorLog "logs/dev-error.log"
    CustomLog "logs/dev-access.log" common
    DocumentRoot "C:\www\dev\public"
    ServerName serv1.example.com
    ServerAlias /dev

    <Directory "C:\www\dev">
        Options Indexes Includes FollowSymLinks MultiViews
        AllowOverride AuthConfig FileInfo Indexes
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>

然后我将c:\www\dev\public\.htaccess代码更改为以下

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

我在这里做错了什么?如何使用相同的域访问每个实例?

1 个答案:

答案 0 :(得分:1)

在Apache配置文件<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <ul> <li><span>Item 1</span></li> <li><span>Item 2</span> <ul> <li><span>Item 2-1</span></li> <li><span>Item 2-2</span></li> <li><span>Item 2-3</span></li> <li><span>Item 2-4</span></li> </ul> </li> <li><span>Item 3</span></li> <li><span>Item 4</span></li> </ul>

中试试这个
/etc/apache2/sites-available

<VirtualHost *:8080> ServerName serv1.example.com ServerAlias serv1.example.com DocumentRoot "C:/www/dev/public" # Rewrites for pretty URLs, better not to rely on .htaccess. <Directory "C:/www/dev/public"> Options All AllowOverride All Require all granted <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> </Directory> # Log file locations LogLevel warn ErrorLog "logs/dev-error.log" CustomLog "logs/dev-access.log" common

c:\www\dev\public\.htaccess

我希望这会奏效。有关详细信息,请访问以下链接:Multiple laravelsites on single apache servermultiple web sites in single laravel installation