需要:安裝好Apache Http Server、PHP、Composer
1.移動至欲安裝Laravel專案的位置
cd [欲安裝位置]
2.建立Laravel專案
方式1:全域模式安裝套件:composer global require "laravel/installer"
接著移動到你要安裝專案的資料夾中:cd [檔案位置]
安裝Laravel專案:laravel new animal
方式2(本人使用):Composer create-project安裝Laravel:
composer create-project --prefer-dist laravel/laravel [專案資料夾名稱] [版本(自行添加):"8.0"第八版]
3.設定httpd.conf(專案資料夾位置:拖曳檔案進終端機就會出現了。)
# 變更:根目錄位置修改。
DocumentRoot "[專案資料夾位置]/public"
<Directory "[專案資料夾位置]/">
# Directory內容有忽略沒更動的部分,不要直接覆蓋掉。
# 變更:讓伺服器使用.htacess配置檔
AllowOverride All
</Directory>
# 變更:讓伺服器使用php做為預設首頁
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
# 變更:設定錯誤紀錄存放位置
ErrorLog "[專案資料夾位置]/storage/logs/[自定義日誌名].log"
4.重新啟動httpd載入新的設定檔:
brew services restart httpd
5.開啟網頁如果你看到這個畫面,代表你已經安裝成功了。
