部署準(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)建屬于laravel的nginx配置文件
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ò)
下面需要配置laravel的hosts文件
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è)
