larvera本地l多域名使用
一:配置文件更改(该域名指向对应项目)
我用的是PHPstudy,不过配置都大同小异
1:vhosts-ini
server {
listen 80;
server_name api.woodentest.com ;#要使用的另一个域名,我这里只打算作用于api,所以就配置了一个api的域名
root "C:\xx\xx\xxx\xxx\xxx\public";#项目具体路径
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$query_string;
#autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}:
2:host #本地配置虚拟域名
二:代码配置
1:C:\xx\xx\xx\WWW\test\app\Providers\RouteServiceProvider.php //在这个位置配置
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
$this->mapApiApiRoutes();
$this->mapApiTestRoutes();// 配置的测试域名
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
* 定义路由
* @return void
*/
protected function mapApiTestRoutes()
{
Route::domain(config('app.API_Test_DOMAIN'))
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));//路径
}
2:C:\xx\xx\xx\WWW\chengzhuan\config\app.php
配置域名地址
'name' => env('APP_NAME', 'Laravel'),
'admin_domain' => env('ADMIN_DOMAIN'),//后台域名
'api_domain' => env('API_DOMAIN'),
'api_test_domain' => env('API_Test_DOMAIN'),//(测试)
'img_domain' => env('IMG_DOMAIN'),//图片域名
3:.env
API_API_DOMAIN =api.woodentest.com #测试域名
上一篇: Nginx 多域名绑定