我正在使用PHP 7.1,NGINX和Laravel 5.8运行ubuntu 16.04。
我的目标是在我的本地(dev)环境中创建一个多租户应用。
根URL为myapp.com
。我想从以下URL中检索:account1.myapp.com
,account2.myapp.com
,...
,然后显示字符串account1
或account2
,...
。< / p>
通过低谷后一些帖子:
我得知我应该:
/etc/dnsmasq.conf (address=/myapp.com/127.0.0.1)
/etc/nginx/sites-available/myapp.com.conf (server_name *.myapp.com myapp.com;)
所有步骤之后,
网址myapp.com Route::get('/', 'HomeController@index');
运作良好,但网址http://account1.myapp.com/仍然无法运作(无法访问该网站)
我不知道自己在做什么错。 一些帮助?
那是我到目前为止的代码:
Route::domain('{account}.myapp.com/')->group(function ($account) {
return $account;
});
Auth::routes();
Route::get('/', 'HomeController@index');
127.0.0.1 myapp.com
server {
listen 80;
server_name *.myapp.com myapp.com;
root /var/www/vhosts/myapp.com/public;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/myapp.com-error.log error;
error_page 404 /index.php;
sendfile off;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /\.ht {
deny all;
}
client_max_body_size 1000m;
}
# Configuration file for dnsmasq.
#
address=/myapp.com/127.0.0.1
# Format is one option per line, legal options are the same ...
...