在没有子域的子文件夹中安装多个 laravel 项目
我已经尝试搜索这个问题,但它与我的问题完全不同,所以我在这里发布。我正在尝试创建一个Web服务器,用于在子文件夹中托管多个laravel项目。这是我的实验室服务器。所以我想让我的项目像这样:nginx
- domain.com/project1
- domain.com/project2
- domain.com/project3
我正在为每个项目复制以下nginx块(我不知道这里发生了什么,我只是从互联网上复制并且它起作用):location
location ^~ /project1/ {
alias /home/web/project1/public;
try_files $uri $uri/ @project1;
location ~ \.php {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME "/home/web/project1/public/index.php";
}
}
location @project1 {
rewrite /avm/(.*)$ /project1/index.php?/$1 last;
}
在我的laravel应用程序中的RESTful路由,如下所示:
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', ['middleware' => 'auth','uses' => 'HomeController@index'])->name('home');
// Authentication
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@authenticate');
Route::get('auth/logout', 'Auth\AuthController@getLogout');
// Administração
Route::group(['prefix' => 'administracao', 'middleware' => 'auth'], function() {
Route::resource('filiais', 'FiliaisController');
Route::resource('precos', 'PrecosController');
Route::resource('funcionarios', 'FuncionariosController');
Route::resource('cargos', 'CargosController');
Route::resource('vendedores', 'VendedoresController');
});
// Comercial
Route::group(['prefix' => 'comercial', 'middleware' => 'auth'], function() {
Route::resource('clientes', 'ClientesController');
Route::resource('fichas', 'FichasController');
});
// Operacional
Route::group(['prefix' => 'operacional', 'middleware' => 'auth'], function() {
Route::resource('agenda', 'AgendaController');
Route::resource('os', 'OsController');
Route::resource('ambientes', 'AmbientesController');
Route::resource('processos', 'ProcessosController');
Route::get('relatorios', 'RelatoriosController@index');
Route::group(['prefix' => 'processo', 'middleware' => 'auth'], function() {
Route::get('create', 'ProcessoController@create');
Route::get('index', 'ProcessoController@index');
Route::post('{os}/parse', 'ProcessoController@parse');
Route::get('{os}', 'ProcessoController@principal');
Route::match(['get', 'post'], '{os}/detalhe', 'ProcessoController@detalhe');
Route::get('{os}/duplicidades', 'ProcessoController@duplicidades');
Route::get('{os}/restantes', 'ProcessoController@restantes');
Route::match(['get', 'post'], '{os}/auditoria', 'ProcessoController@auditoria');
Route::match(['get', 'post'], '{os}/operadores', 'ProcessoController@operadores');
Route::match(['get', 'post'], '{os}/divergencia', 'ProcessoController@divergencia');
Route::match(['get', 'post'], '{os}/finalizar', 'ProcessoController@finalizar');
Route::get('{os}/excluir/{setor}', 'ProcessoController@destroy');
});
});
虽然它似乎工作(页面出现等),当它进入业务逻辑(保存到数据库等)时,它似乎有很多错误。例如,当我尝试在url中创建新员工时,它会给我一个错误:(它有点在一些url路由之前)http://domain.com/project1/administracao/funcionarios
SQLSTATE[42S22]: Column not found: 1054 Unknown column '/administracao/funcionarios' in
当我设置一个子域时,一切都很好。但我不想为每个项目创建一个子域,我希望它在子文件夹url中工作。可能吗?project1.domain.com