lumen5.6同一项目配置多模块指向不同的域名
用lumen5.6开发一个项目后台,现在需要加一个运营中心,写在同一个框架下,使用不同的域名.
在原有域名的基础上新加一个运营中心的域名
原后台域名: test1.top
新加运营中心域名: test2.top
一.编辑bootstarp/app.php文件
原:
$app->router->group([
'namespace' => 'Controllers',
], function ($router) {
require __DIR__.'/../routes/admin.php';
});
return $app;
修改后:
$app->router->group([
'namespace' => 'Controllers',
], function ($router) {
require __DIR__.'/../routes/admin.php';
require __DIR__.'/../routes/broker.php';
});
return $app;
二.在routes目下新建broker.php路由文件
<?php
Route::group(
['prefix'=>'broker','namespace'=>'Broker'],function () use ($router){
Route::get('/','AuthController@index');
}
);
三.在控制器目录下新建Broker目录,在Broker目录下新建AuthController文件
namespace Controllers\Broker;
use Controllers\BaseController;
class AuthController extends BaseController
{
public function index()
{
return ("12344455");
}
}
四.修改ngixn配置文件,并重启nginx
server
{
listen 80;
server_name test1.top test2.top;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/ekee_panel/public;
#include rewrite/other.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
#include enable-php.conf;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log /home/wwwlogs/test.com.log;
}
五.访问
test1.top
test2.top