1. 下载源码
在命令行界面输入 git clone
https://github.com/zhangfangsong/Lara.git
下载源码,
国内网速慢的同学可以用码云地址:https://gitee.com/zfs/Lara.git
wwwroot root$ git clone https://github.com/zhangfangsong/Lara.git Initialized empty Git repository in /home/wwwroot/Lara/.git/ remote: Counting objects: 5540, done. remote: Compressing objects: 100% (4025/4025), done. remote: Total 5540 (delta 1487), reused 5395 (delta 1342), pack-reused 0 Receiving objects: 100% (5540/5540), 15.55 MiB | 22 KiB/s, done. Resolving deltas: 100% (1487/1487), done.
2. 安装composer
依赖
进入项目根目录,在命令行界面输入 composer install
安装项目依赖
Lara root$ composer install Do not run Composer as root/super user! See https://getcomposer.org/root for details Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Package operations: 95 installs, 0 updates, 0 removals - Installing symfony/thanks (v1.0.7): Loading from cache - Installing league/fractal (0.17.0): Loading from cache - Installing vlucas/phpdotenv (v2.4.0): Loading from cache - Installing symfony/css-selector (v4.1.0): Loading from cache - Installing tijsverkoyen/css-to-inline-styles (2.2.1): Loading from cache - Installing symfony/polyfill-mbstring (v1.8.0): Loading from cache - Installing symfony/var-dumper (v3.4.11): Loading from cache - Installing symfony/routing (v3.4.11): Loading from cache - Installing symfony/process (v3.4.11): Loading from cache - Installing symfony/polyfill-ctype (v1.8.0): Loading from cache // 省略...
3. 配置.env
文件
复制一份.env.example
并重命名为.env
编辑.env
文件的以下部分为你的数据库连接配置
Lara root$ cp .env.example .env Lara root$ vim .env DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=数据库 DB_USERNAME=用户名 DB_PASSWORD=密 码
4 设置应用秘钥
在命令行界面输入 php artisan key:generate && php artisan jwt:secret
Lara root$ php artisan key:generate && php artisan jwt:secret Application key [base64:5lTTddEgdwVBiVlYaFJV1tPGbVWDDJAw4rw9trPrAY4=] set successfully. jwt-auth secret [RV4yuHhL8HVCDVL2FG2sFQ3ZLDqsCMSX] set successfully.
php artisan key:generate
生成应用的加密密钥,确保用户会话和其他加密数据安全。
php artisan jwt:secret
用于Api token
认证签名。
5. 数据库迁移
在命令行界面输入 php artisan migrate
运行数据库迁移文件,生成数据库表结构
Lara root$ php artisan migrate Migration table created successfully. Migrating: 2014_10_12_000000_create_users_table Migrated: 2014_10_12_000000_create_users_table Migrating: 2018_05_11_024840_create_categories_table Migrated: 2018_05_11_024840_create_categories_table Migrating: 2018_05_11_040613_add_description_to_categories_table Migrated: 2018_05_11_040613_add_description_to_categories_table Migrating: 2018_05_12_155005_create_tags_table Migrated: 2018_05_12_155005_create_tags_table Migrating: 2018_05_13_052846_create_links_table Migrated: 2018_05_13_052846_create_links_table Migrating: 2018_05_14_064021_create_pages_table Migrated: 2018_05_14_064021_create_pages_table Migrating: 2018_05_15_023756_create_articles_table Migrated: 2018_05_15_023756_create_articles_table Migrating: 2018_05_23_020340_add_description_to_users_table Migrated: 2018_05_23_020340_add_description_to_users_table Migrating: 2018_05_23_060750_create_configs_table Migrated: 2018_05_23_060750_create_configs_table Migrating: 2018_05_24_055750_add_status_to_users_table Migrated: 2018_05_24_055750_add_status_to_users_table Migrating: 2018_05_24_113322_create_comments_table Migrated: 2018_05_24_113322_create_comments_table Migrating: 2018_05_25_082819_create_roles_table Migrated: 2018_05_25_082819_create_roles_table Migrating: 2018_05_28_015833_add_url_to_categories_table Migrated: 2018_05_28_015833_add_url_to_categories_table Migrating: 2018_05_28_081109_change_value_field_to_configs Migrated: 2018_05_28_081109_change_value_field_to_configs Migrating: 2018_06_13_035033_create_collections_table Migrated: 2018_06_13_035033_create_collections_table Migrating: 2018_07_15_032530_create_nodes_table Migrated: 2018_07_15_032530_create_nodes_table Migrating: 2018_07_15_034451_create_node_role_table Migrated: 2018_07_15_034451_create_node_role_table Migrating: 2018_07_15_063249_add_alias_to_nodes_table Migrated: 2018_07_15_063249_add_alias_to_nodes_table
6. 数据库填充
在命令行界面输入 php artisan db:seed
填充默认数据
Lara root$ php artisan db:seed Seeding: UsersTableSeeder Seeding: RolesTableSeeder Seeding: NodesTableSeeder Seeding: CategoriesTableSeeder Seeding: ArticlesTableSeeder Seeding: CommentsTableSeeder Seeding: LinksTableSeeder Seeding: TagsTableSeeder Seeding: ConfigsTableSeeder
7. 配置权限
修改 storage
目录权限为 777
Lara root$ chmod -R 777 storage
至此,程序安装完毕,你就拥有了自己的博客CMS
和一套Api
服务器了。
网站前台:http://demo.zfsphp.com
网站后台:http://demo.zfsphp.com/admin
Api接口: http://demo.zfsphp.com/api/v1/categories
(分类列表)
注:
1. 如果是在nginx
环境,需要在nginx
配置文件加上以下配置
location / { try_files $uri $uri/ /index.php?$query_string; }
2. 管理员初始账号,密码为 845573796@qq.com
和 secret
你也可以在命令行输入 php artisan reset:password
为相应的用户重置密码。
Lara root$ php artisan reset:password 请输入你想重置密码的用户ID: > 1 请输入用户密码: > 密码重置成功
3. 默认开启了调试模式,你可以编辑.env
文件,修改 APP_DEBUG
项为 false
即可。
《Lara博客系统安装》上有 1 条评论!