1.專案名稱
(1) test01
(2) test02
(3) test03
(1) 建立資料夾
$cd /var/www/html/
$mkdir test01
$mkdir test02
$mkdir test03
(2)針對各資料夾,建立laravel,並更名
$composer create-project laravel/laravel --prefer-dist /home/webadmin/html/test01
$cd /var/www/html/test01/
$php artisan key:generate
$sudo chown -R www-data storage/ bootstrap/cache/
$cd /var/www/html/test01/resources/
$pico welcome.blade.php
在82行 將 Laravel 改為 test01.Laravel
$composer create-project laravel/laravel --prefer-dist /home/webadmin/html/test02
$cd /var/www/html/test02/
$php artisan key:generate
$sudo chown -R www-data storage/ bootstrap/cache/
$cd /var/www/html/test02/resources/
$pico welcome.blade.php
在82行 將 Laravel 改為 test02.Laravel
$composer create-project laravel/laravel --prefer-dist /home/webadmin/html/test03
$cd /var/www/html/test03/
$php artisan key:generate
$sudo chown -R www-data storage/ bootstrap/cache/
$cd /var/www/html/test03/resources/
$pico welcome.blade.php
在82行 將 Laravel 改為 test03.Laravel
3.編輯 /etc/hosts
$sudo pico /etc/hosts
新增
127.0.0.1 www.localhost.test01.laravel
127.0.0.1 www.localhost.test02.laravel
127.0.0.1 www.localhost.test03.laravel
4.編輯 /etc/apache2/sites-enabled/000-default.conf
$sudo pico /etc/apache2/sites-enabled/000-default.conf
新增
<VirtualHost *:80>
ServerName localhost.test01
ServerAlias www.localhost.test01.laravel
DocumentRoot /var/www/html/test01/public
<Directory "/var/www/html/test01">
Options -Indexes
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName localhost.test02
ServerAlias www.localhost.test02.laravel
ServerAlias www.localhost.test02.laravel
DocumentRoot /var/www/html/test02/public
<Directory "/var/www/html/test02">
Options -Indexes
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName localhost.test03
ServerAlias www.localhost.test03.laravel
ServerAlias www.localhost.test03.laravel
DocumentRoot /var/www/html/test03/public
<Directory "/var/www/html/test03">
Options -Indexes
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
5.輸入指令啟動rewrite mod
$sudo a2enmod rewrite
6.重新啟動 Apache2
$sudo service apache2 restart
7.開啟瀏覽器,在分頁上分別輸入
www.localhost.test01.laravel
www.localhost.test02.laravel
www.localhost.test03.laravel
如下圖
資料來源:
1.laravel開發講義
2.lubuntu 16.04 x64 安裝 laravel 5 與安裝phpmyadmin
3.「教學」Amazon EC2 Ubuntu 設定 Apache Virtual Hosts
4.Ubuntu Apache啟用虛擬多網站(VirtualHost)
5.Ubuntu drupal multisite多網站安裝
2.lubuntu 16.04 x64 安裝 laravel 5 與安裝phpmyadmin
3.「教學」Amazon EC2 Ubuntu 設定 Apache Virtual Hosts
4.Ubuntu Apache啟用虛擬多網站(VirtualHost)
5.Ubuntu drupal multisite多網站安裝