php - 在 nginx vps 主机上托管具有多个子域的 Laravel 应用程序
问题描述
我有一个 Ubuntu 18.04 LTS VPS,我正在托管一个 Laravel 应用程序,其论坛部分路由到子域。该站点的主要部分被路由到 TLD。
当我访问 www.example.com 时,我能够配置 Nginx 以提供我的主站点内容,但是,当我访问 forum.example.com 时,找不到该站点的 IP 地址
这是我的 Godaddy 配置:https ://pasteboard.co/IP3XM3n.png
这是我的 nginx 配置文件:
listen 80;
root /var/www/intransportal/public;
index index.php index.html index.htm;
server_name intransportal.com forum.intransportal.com;
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
location / {
try_files $uri $uri/ @rewrite;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
这是我的路线
$domain = parse_url(config('app.url'), PHP_URL_HOST);
Route::domain('forum.'.$domain)->group(function() {
Route::get('/threads/', 'ThreadsController@index');
Route::get('/threads/create', 'ThreadsController@create');
Route::get('/threads/{channel}/{thread}', 'ThreadsController@show');
Route::delete('/threads/{channel}/{thread}', 'ThreadsController@destroy');
Route::post('/threads', 'ThreadsController@store');
Route::get('/threads/{channel}/{thread}/replies','RepliesController@index');
Route::post('/threads/{channel}/{thread}/replies','RepliesController@store');
Route::get('/threads/{channel}', 'ThreadsController@index');
Route::patch('/replies/{reply}', 'RepliesController@update');
Route::delete('/replies/{reply}', 'RepliesController@destroy');
Route::post('/replies/{reply}/favorite', 'FavoritesController@store');
Route::delete('/replies/{reply}/favorite','FavoritesController@destroy');
Route::get('/', 'ThreadsController@index');
Route::patch('/replies/{reply}', 'RepliesController@update');
});
Route::get('/','HomeController@index');
Auth::routes();
Route::get('profiles/{user}', 'ProfilesController@show')->name('profile');
Route::get('/home', 'HomeController@index')->name('home');
Route::resource('photos', 'PhotosController');
如何将论坛的路由指向我的子域?
解决方案
您想要CNAME
子域的记录。
+-----------------------+
| Type Name Value |
+-----------------------+
| CNAME forum @ |
+-----------------------+
推荐阅读
- r - 基于 cv.glmnet 中 type.measure 参数的不同结果
- javascript - 使用 axios 检索数据---得到 404 错误
- php - 如何在单击时获取复选框的值
- r - R - IMDb 数据集未加载
- r - 为什么 tidyverse 安装在 Ubuntu 上找不到包?
- php - 如何显示数据库中多行的表格
- r - 如何在多列上循环或应用具有 2 个条件的 ifelse 语句?
- doctrine - 如何从 DefaultController 中的教义数据库中获取所有数据,然后将该数据转发到 Symfony4 中的树枝模板
- c# - 如何在 C# MVC 中获取每个列表项验证错误
- c++ - 了解元函数以在一组类型中查找类型