Mac 下安裝部署 Laravel 5.6

部署準(zhǔn)備

1.Nginx
2.PHP >= 7.1.3
3.Mysql
4.Composer

安裝 Laravel5.6

我們通過(guò)命令行的形式安裝laravel,Laravel Installer的安裝方法就不介紹了
首先通過(guò)cd命令進(jìn)入所需要安裝的目錄下

cd /Users/stussy/www/

緊接著一行命令即可安裝最新的laravel版本

//laravel56為自定義文件名,即生成項(xiàng)目根目錄
composer create-project --prefer-dist laravel/laravel laravel56

在幾秒之后,屏幕最后顯示

> @php artisan key:generate
Application key [base64:xJ3tB7p0ZltXaaz92UZ0n2aLYIj/ofybKv4OSq11fII=] set successfully.

恭喜你,laravel已經(jīng)安裝完成
那么如何才能在瀏覽器中訪問(wèn)laravel,需要用到我們的Nginx來(lái)配置hosts

配置 Nginx

默認(rèn)的Nginx自定義配置文件的路徑在

/usr/local/etc/nginx/servers

那么創(chuàng)建屬于laravelnginx配置文件

vim laravel56.conf

進(jìn)入vim編譯器

server {
        listen         80;
        server_name    laravel.cc;
        set  $htdocs   /Users/stussy/www/laravel56/public/;

        location / {
            root $htdocs;
            index  index.php index.html;
            try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php(.*)$ {
            include fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME  $htdocs$fastcgi_script_name;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
        }
}

記住需要將/public/加入路徑中,以免后面的文件路徑報(bào)錯(cuò)
下面需要配置laravelhosts文件

vim /etc/hosts

進(jìn)入vim編譯器,名稱需要與server_name保持一致

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
127.0.0.1       laravel.cc

此時(shí),可以順利進(jìn)入下一步,開啟瀏覽器訪問(wèn)我們配置好的laravel項(xiàng)目

開啟Chrome

鍵入laravel.cc即將步入優(yōu)雅的Laravel界面,沒(méi)想到意外報(bào)錯(cuò)

UnexpectedValueException
The stream or file "/Users/stussy/www/laravel56/storage/logs/laravel.log" 
could not be opened: failed to open stream: Permission denied

原來(lái)是文件權(quán)限不足

chmod -R 777 bootstrap/cache/
chmod -R 777 storage/

好了,一切的辛苦總算沒(méi)有白費(fèi),我們看到了干凈整潔的Laravel首頁(yè)

配置 .env 文件

安裝 barryvdh/laravel-debugbar

安裝 barryvdh/laravel-ide-helper

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容