laravel安装教程

  • 1,电脑的bois要开启虚拟化
  • 2,出现这个错误“0X00000000”指令引用的“0x00000000”内存,该内存不能为“read”或“written,解决办法:http://liss.iteye.com/blog/986096
    ##运行 输入cmd 回车在命令提示符下输入 
    for %1 in (%windir%\system32\*.dll) do regsvr32.exe /s %1  
  • 3,首先将box文件放到此Homestead文件夹下,然后创建文件aa.json,内容如下,
    {
        "name": "laravel/homestead",
        "versions": [{
            "version": "1.0.1",
            "providers": [{
                "name": "virtualbox",
                "url": "file://E:/data/laravel/Homestead/virtualbox.box"
            }]
        }]
    }

    执行命令 vagrant box add aa.json.

  • 3,修改相关文件,然后执行vagrant up

    • e:/data/laravel/Homestead/Homestead.yaml
    • E:\data\laravel\Homestead\Vagrantfile

      Homestead.yaml

    ---
    ip: "192.168.10.10"
    memory: 2048
    cpus: 1
    provider: virtualbox
    
    #authorize: ~/.ssh/id_rsa.pub
    authorize: C:/Users/zhouxinxin/.ssh/id_rsa.pub
    
    keys:
        #- ~/.ssh/id_rsa
        - C:/Users/zhouxinxin/.ssh/id_rsa
    
    folders:
        - map: E:/data/laravel/Homestead
          to: /home/vagrant/code
    
    sites:
        - map: homestead.test
          to: /home/vagrant/code/public
    
    databases:
        - homestead
    
    # blackfire:
    #     - id: foo
    #       token: bar
    #       client-id: foo
    #       client-token: bar
    
    # ports:
    #     - send: 50000
    #       to: 5000
    #     - send: 7777
    #       to: 777
    #       protocol: udp
    

    Vagrantfile

    #在下面添加如下代码,vagrant up的时候图形化界面会自动跳出来
    config.vm.provider :virtualbox do |vb|
        vb.gui = true
    end
  • 5,遇到这个错误config.vm.boot_timeout,此时是可以进入系统的,然后修改

    sudo vim /etc/systemd/system/network-online.target.wants/networking.service
    将里面的TimeoutStartSec=5min  修改为TimeoutStartSec=10sec
    然后重启系统,就可以生效了

    ,然后这样操作

  • 6,系统默认账号是 vagrant/vagrant,为root设置密码
    sudo passwd root 
  • 7,laravel使用的php版本为7.2,在php7.2中,函数使用非常严格.
    //count`函数仅支持参数为数组, 非数组情况下将报警告. 我们可以修改为:
    if ( count($user)) =>
    if (is_array($user) && count($user) > 0)
  • 8,代码的修改,php7.2中count()函数要求变得严格,作为其别名函数sizeof(),也是变得严格,前后台需要修改些代码,才可以顺利启动larabbs\app\Models\Traits\ActiveUserHelper.php line 67

    //if (count($user)) {//old
    if (is_array($user) && count($user) > 0) {//new
        ...
    }

    larabbs\vendor\summerblue\administrator\src\Frozennode\Administrator\Fields\Factory.php line 363

    //if (!sizeof($this->editFields) || $override) {//old
    if (!($this->editFields) || $override ) {//new
    $this->editFields = array();
    ...
    }

    larabbs\vendor\summerblue\administrator\src\Frozennode\Administrator\Fields\Relationships\Relationships.php line 98

    //if (sizeof($constraints)) {//old
    if (is_array($constraints) && count($constraints)>0) {//new
    ...
    }
  • 9,npm run dev报错no such file or directory, scandir '/home/vagrant/code/larabbs/node_modules/node-sass/vendor',解决办法:
    • 删除nnode_modules文件夹下面的node-sass模块,
    • 重新用yarn add node-sass来重新安装,
    • 然后执行rebuild,执行命令npm rebuild node-sass --no-bin-links
    • success:
京ICP备16046576号-1