Lara 系统安装 Lara 是一款基于`Laravel`框架`6.x`版本开发的个人博客系统,它灵活轻巧,简单易用并易于扩展,适合搭建个人博客或作为企业 CMS 使用。 ##### 下载源码 在命令行界面输入 `git clone https://github.com/zhangfangsong/Lara.git`下载源码,国内网速慢的同学可以移步码云:`https://gitee.com/zfs/Lara.git` ```php Code zfs$ git clone https://github.com/zhangfangsong/Lara.git Cloning into 'Lara'... remote: Enumerating objects: 1667, done. remote: Counting objects: 100% (1667/1667), done. remote: Compressing objects: 100% (1167/1167), done. remote: Total 7869 (delta 748), reused 1299 (delta 451), pack-reused 6202 Receiving objects: 100% (7869/7869), 17.40 MiB | 34.00 KiB/s, done. Resolving deltas: 100% (2503/2503), done. Checking out files: 100% (4748/4748), done. ``` ##### 安装 composer 依赖 进入项目根目录,在命令行界面输入`composer install`安装项目依赖。 ```php Lara zfs$ composer install Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Package operations: 101 installs, 0 updates, 0 removals - Installing doctrine/inflector (2.0.3): Downloading (100%) - Installing doctrine/lexer (1.2.1): Loading from cache - Installing dragonmantank/cron-expression (v2.3.0): Downloading (100%) - Installing symfony/polyfill-ctype (v1.18.1): Loading from cache - Installing phpoption/phpoption (1.7.5): Loading from cache - Installing vlucas/phpdotenv (v3.6.7): Downloading (100%) - Installing symfony/css-selector (v5.1.3): Downloading (100%) - Installing tijsverkoyen/css-to-inline-styles (2.2.3): Downloading (100%) - Installing symfony/polyfill-php80 (v1.18.1): Loading from cache - Installing symfony/polyfill-php72 (v1.18.1): Loading from cache - Installing symfony/polyfill-mbstring (v1.18.1): Loading from cache - Installing symfony/var-dumper (v4.4.11): Downloading (100%) - Installing symfony/routing (v4.4.11): Downloading (100%) - Installing symfony/process (v4.4.11): Downloading (100%) - Installing symfony/polyfill-php73 (v1.18.1): Loading from cache // 省略... ``` ##### 配置 .env 文件 复制一份`.env.example`并重命名为`.env`,编辑`.env`文件的以下部分为你的数据库连接配置。 ```php 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=密 码 ``` ##### 设置应用秘钥 在命令行界面输入`php artisan key:generate && php artisan jwt:secret` ```php Lara zfs$ php artisan key:generate && php artisan jwt:secret Application key set successfully. This will invalidate all existing tokens. Are you sure you want to override the secret key? (yes/no) [no]: > yes jwt-auth secret [0723fusxSNVcMT1wOVIkUZIssg2bMHV3wU4k5Oo474ASK1zQS0KisfP3kqB5GXmO] set successfully. ``` `php artisan key:generate`生成应用的加密密钥,确保用户会话和其他加密数据安全。 `php artisan jwt:secret`用于Api token 认证签名。 ##### 数据库迁移 在命令行界面输入`php artisan migrate`运行数据库迁移文件,生成数据库表结构。 ```php Lara zfs$ php artisan migrate Migration table created successfully. Migrating: 2014_10_12_000000_create_users_table Migrated: 2014_10_12_000000_create_users_table (0.1 seconds) Migrating: 2018_05_11_024840_create_categories_table Migrated: 2018_05_11_024840_create_categories_table (0.06 seconds) Migrating: 2018_05_12_155005_create_tags_table Migrated: 2018_05_12_155005_create_tags_table (0.03 seconds) Migrating: 2018_05_13_052846_create_links_table Migrated: 2018_05_13_052846_create_links_table (0.05 seconds) Migrating: 2018_05_14_064021_create_pages_table Migrated: 2018_05_14_064021_create_pages_table (0.03 seconds) Migrating: 2018_05_15_023756_create_articles_table Migrated: 2018_05_15_023756_create_articles_table (0.07 seconds) Migrating: 2018_05_23_060750_create_configs_table Migrated: 2018_05_23_060750_create_configs_table (0.04 seconds) Migrating: 2018_05_24_113322_create_comments_table Migrated: 2018_05_24_113322_create_comments_table (0.08 seconds) Migrating: 2018_05_25_082819_create_roles_table Migrated: 2018_05_25_082819_create_roles_table (0.03 seconds) Migrating: 2018_06_13_035033_create_collections_table Migrated: 2018_06_13_035033_create_collections_table (0.04 seconds) Migrating: 2018_07_15_032530_create_nodes_table Migrated: 2018_07_15_032530_create_nodes_table (0.05 seconds) Migrating: 2018_07_15_034451_create_node_role_table Migrated: 2018_07_15_034451_create_node_role_table (0.04 seconds) Migrating: 2019_08_20_142134_seed_sites_data Migrated: 2019_08_20_142134_seed_sites_data (1.42 seconds) Migrating: 2020_08_22_152917_create_notifications_table Migrated: 2020_08_22_152917_create_notifications_table (0.06 seconds) ``` ##### 数据库填充 在命令行界面输入`php artisan db:seed`填充默认数据 ```php Lara zfs$ php artisan db:seed Seeding: CategoriesTableSeeder Seeded: CategoriesTableSeeder (0.02 seconds) Seeding: CommentsTableSeeder Seeded: CommentsTableSeeder (0.01 seconds) Seeding: PostsTableSeeder Seeded: PostsTableSeeder (0.05 seconds) Seeding: TagsTableSeeder Seeded: TagsTableSeeder (0.01 seconds) Seeding: UsersTableSeeder Seeded: UsersTableSeeder (0.36 seconds) Database seeding completed successfully. ``` ##### 配置权限 修改`bootstrap` `storage` `public/uploads`目录权限为 777 ```php Lara zfs$ chmod -R 777 bootstrap storage public/uploads ``` 至此,程序安装完毕,你就拥有了自己的博客`CMS`和一套`Api`服务器了。 ```php 网站前台:http://demo.zfsphp.com 网站后台:http://demo.zfsphp.com/admin Api 接口:http://demo.zfsphp.com/api/v1/categories (分类列表) ``` ##### 注意 1)如果是在`nginx`环境,需要在`nginx`配置文件加以下配置 ```php location / { try_files $uri $uri/ /index.php?$query_string; } ``` 2)管理员初始账号,密码为`admin`和`123456`你也可以在命令行输入`php artisan reset:password`为管理员重置密码。 ```php Lara zfs$ php artisan reset:password 请输入你想重置密码的用户ID: > 1 请输入用户新密码: > 密码重置成功 ``` 3)默认开启了调试模式,你可以编辑`.env`文件,修改`APP_DEBUG` 为`false`即可。
《Lara 系统安装》上有 1 条评论!