1、首先項目地址貼出來https://laravel-admin.org/docs/zh/installation
2、第一步創建laravel5.5項目
3、PHP7.0的話安裝一個phpstudy就可以了,本機有,就不贅述了,phpmyadmin地址:http://phpstudy.php.cn/
4、laravel5.5的話中文文檔地址:https://learnku.com/docs/laravel/5.5/installation/1282
PHP composer.phar create-project --prefer-dist laravel/laravel blog "5.5.*"
5、確保有php環境+composer的依賴就是php.exe的地址和執行上面命令行的文件夾中存在composer.phar和composer.json文件
6、安裝完成了之後設置一下Nginx轉發,在nginx.conf中加一段配置
server {
listen 80;
server_name 127.0.0.5;
root "F:/PHPTutorial/WWW/blog/public";
index index.php index.html index.htm;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
}
location ~ /\.ht {
deny all;
}
}
7、重啓nginx然後輸入127.0.0.5查看是否有啦
8、檢查數據庫連接是否正確,順便安裝一個phpmyadmin,官網地址:https://www.phpmyadmin.net/,下載就完事了,然後將解壓縮包的文件放到web能夠訪問的地址。
9、配置數據庫連接,修改config下的database.php文件,將mysql配置改爲正確配置,默認的數據庫爲test,密碼用戶名:root,root;再修改.env文件的部分
10、驗證數據庫配置是否正確,首先添加路由配置,在routes下的web.php中添加一個測試路由
Route::group(['prefix' => 'test'],function ($router){
$router->get('/', 'TestController@index');//測試1
});
11、到app/Http/Controller下創建TestController文件
<?php
/**
* Created by PhpStorm.
* User: xky
* Date: 2019/4/21
* Time: 9:24
*/
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
class TestController extends Controller
{
public function index(){
DB::table('rst')->first();
}
}
12、訪問127.0.0.5/test,雖然報錯,但是表不存在,而不是權限問題,數據庫連接成功。
13、安裝laravel-admin,參照文檔的步驟執行,第三步的時候報錯
查看了下創建的user表的引擎是MYISAM,需要修改爲InnoDB
1>在配置文件my.ini中的 [mysqld] 下面修改default-storage-engine=InnoDB
2>重啓Mysql服務器
3>修改完成後,執行show engines,InnoDB變成了默認引擎
14、將之前執行創建的user表刪掉,再次執行
php artisan admin:install
還是報錯!!!氣死我了,然後我就去把找到了遷移表的user表,先不要唯一,去掉unique();刪除之前的表,再次執行
php artisan admin:install
成功!
15、啓動服務後,在瀏覽器打開 http://localhost/admin/
,使用用戶名 admin
和密碼 admin
登陸,貼幾張圖。
後續使用參考文檔:https://laravel-admin.org/docs/zh/installation