Laravel 完整實戰(一) —— 搭建及配置

環境: nginx + php + mysql
laravel : 5.5
開發環境的搭建略過

安裝 laravel

composer create-project laravel/laravel   [project-name]  --prefer-dist "5.5.*"

測試安裝是否成功

cd project-name 
php artisan server
瀏覽器輸入: http://127.0.0.1:8000 ,出現如下界面表示安裝成功

Laravel 完整實戰(一) —— 搭建及配置

配置

composer 安裝,根目錄下已經創建 .env 文件, 其他方式安裝的:
    cp .env.example  .env

生成key:
    php artisan key:generate

.env 配置
    APP_NAME=Laravel
    APP_ENV=local
    APP_KEY=base64:************ 
    APP_DEBUG=true
    APP_LOG_LEVEL=debug
    APP_URL=http://localhost

    # 數據庫配置
    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=wbSina
    DB_USERNAME=root
    DB_PASSWORD=root

    BROADCAST_DRIVER=log
    CACHE_DRIVER=file  # 緩存驅動
    SESSION_DRIVER=file   # session 存儲驅動
    SESSION_LIFETIME=120
    QUEUE_DRIVER=sync   # 隊列驅動

    # redis 配置
    REDIS_HOST=127.0.0.1
    REDIS_PASSWORD=null
    REDIS_PORT=6379

    # 郵件配置
    MAIL_DRIVER=smtp
    MAIL_HOST=smtp.mailtrap.io
    MAIL_PORT=2525
    MAIL_USERNAME=null
    MAIL_PASSWORD=null
    MAIL_ENCRYPTION=null

    PUSHER_APP_ID=
    PUSHER_APP_KEY=
    PUSHER_APP_SECRET=
    PUSHER_APP_CLUSTER=mt1

tips: 項目中可根據實際情況進行配置

nginx 配置

server {
        listen       80;
        server_name  wb.leesin.me;
        root   "D:\sinaWb\public";
        location / {
            index  index.html index.htm index.php;
            if (!-e $request_filename){
                rewrite ^/(.*)$ /index.php?/$1 last;
                break;
           }
            #autoindex  on;
        }
        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9002;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}
host ip 映射:
127.0.0.1  wb.leesin.me
重啓 service php7.0-fpm restart 
訪問: http://wb.leesin.me

git 管理代碼

    在github、gitlab、coding、碼雲 中創建空倉庫
    cd project-name
    git init
    在 .gitignore 中添加忽略文件
        /node_modules
        /public/hot
        /public/storage
        /storage/*.key
        /vendor
        npm-debug.log
        yarn-error.log
        .env

    git remote add  origin 倉庫地址
    git add .  &&  git commit -m 'first commit'
    git push -u origin master

    此時就可以開始進行開發了
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章