yakoffka.ru
    грабли, костыли и велосипеды php, css, html, js и прочего

    Установка и начальная настройка приложения laravel на homestead

    terminalПолные логи установки laravel на homestead, приводящей к 502 ошибке. Попытка понять, ЧЯДНТ.

    АЛАРМА!!! Это не руководство к действию!

    Капустин Яков

    оглавление

    bash:
    yo@yo-Lenovo-G510:~/Homestead$ sudo rm -rf /opt/vagrant yo@yo-Lenovo-G510:~/Homestead$ sudo rm -f /usr/bin/vagrant yo@yo-Lenovo-G510:~/Homestead$ sudo rm -rf ~/.vagrant.d yo@yo-Lenovo-G510:~/Homestead$ yo@yo-Lenovo-G510:~/Homestead$ yo@yo-Lenovo-G510:~/Homestead$ yo@yo-Lenovo-G510:~/Homestead$ sudo rm ~/"VirtualBox VMs" -Rf yo@yo-Lenovo-G510:~/Homestead$ sudo rm ~/.config/VirtualBox/ -Rf yo@yo-Lenovo-G510:~/Homestead$ yo@yo-Lenovo-G510:~/Homestead$ yo@yo-Lenovo-G510:~/Homestead$ yo@yo-Lenovo-G510:~/Homestead$ sudo apt-get install virtualbox Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libgsoap8 libvncserver1 virtualbox-dkms virtualbox-qt Suggested packages: vde2 virtualbox-guest-additions-iso The following packages will be REMOVED: virtualbox-5.2 The following NEW packages will be installed: libgsoap8 libvncserver1 virtualbox virtualbox-dkms virtualbox-qt 0 upgraded, 5 newly installed, 1 to remove and 0 not upgraded. Need to get 24,3 MB of archives. After this operation, 81,3 MB disk space will be freed. Do you want to continue? [Y/n] Get:1 http://ru.archive.ubuntu.com/ubuntu xenial/universe amd64 libgsoap8 amd64 2.8.28-1 [216 kB] Get:2 http://ru.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libvncserver1 amd64 0.9.10+dfsg-3ubuntu0.16.04.3 [122 kB] Get:3 http://ru.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 virtualbox-dkms all 5.1.38-dfsg-0ubuntu1.16.04.2 [651 kB] Get:4 http://ru.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 virtualbox amd64 5.1.38-dfsg-0ubuntu1.16.04.2 [15,8 MB] Get:4 http://ru.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 virtualbox amd64 5.1.38-dfsg-0ubuntu1.16.04.2 [15,8 MB] Get:5 http://ru.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 virtualbox-qt amd64 5.1.38-dfsg-0ubuntu1.16.04.2 [7 500 kB] Fetched 16,0 MB in 4min 10s (63,9 kB/s) sh: 0: getcwd() failed: No such file or directory sh: 0: getcwd() failed: No such file or directory sh: 0: getcwd() failed: No such file or directory (Reading database ... 364872 files and directories currently installed.) Removing virtualbox-5.2 (5.2.26-128414~Ubuntu~xenial) ... Processing triggers for libc-bin (2.23-0ubuntu10) ... Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ... Processing triggers for desktop-file-utils (0.22-1ubuntu5.2) ... Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20180209-0ubuntu1) ... Rebuilding /usr/share/applications/bamf-2.index... Processing triggers for mime-support (3.59ubuntu1) ... Processing triggers for shared-mime-info (1.5-2ubuntu0.2) ... Unknown media type in type 'all/all' Unknown media type in type 'all/allfiles' Processing triggers for hicolor-icon-theme (0.15-0ubuntu1.1) ... Selecting previously unselected package libgsoap8:amd64. (Reading database ... 364041 files and directories currently installed.) Preparing to unpack .../libgsoap8_2.8.28-1_amd64.deb ... Unpacking libgsoap8:amd64 (2.8.28-1) ... Selecting previously unselected package libvncserver1:amd64. Preparing to unpack .../libvncserver1_0.9.10+dfsg-3ubuntu0.16.04.3_amd64.deb ... Unpacking libvncserver1:amd64 (0.9.10+dfsg-3ubuntu0.16.04.3) ... Selecting previously unselected package virtualbox-dkms. Preparing to unpack .../virtualbox-dkms_5.1.38-dfsg-0ubuntu1.16.04.2_all.deb ... Unpacking virtualbox-dkms (5.1.38-dfsg-0ubuntu1.16.04.2) ... Selecting previously unselected package virtualbox. Preparing to unpack .../virtualbox_5.1.38-dfsg-0ubuntu1.16.04.2_amd64.deb ... Unpacking virtualbox (5.1.38-dfsg-0ubuntu1.16.04.2) ... Selecting previously unselected package virtualbox-qt. Preparing to unpack .../virtualbox-qt_5.1.38-dfsg-0ubuntu1.16.04.2_amd64.deb ... Unpacking virtualbox-qt (5.1.38-dfsg-0ubuntu1.16.04.2) ... Processing triggers for libc-bin (2.23-0ubuntu10) ... Processing triggers for systemd (229-4ubuntu21.15) ... Processing triggers for ureadahead (0.100.0-19) ... ureadahead will be reprofiled on next reboot Processing triggers for man-db (2.7.5-1) ... Processing triggers for shared-mime-info (1.5-2ubuntu0.2) ... Unknown media type in type 'all/all' Unknown media type in type 'all/allfiles' Processing triggers for hicolor-icon-theme (0.15-0ubuntu1.1) ... Processing triggers for menu (2.1.47ubuntu1.16.04.1) ... Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ... Processing triggers for desktop-file-utils (0.22-1ubuntu5.2) ... Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20180209-0ubuntu1) ... Rebuilding /usr/share/applications/bamf-2.index... Processing triggers for mime-support (3.59ubuntu1) ... Setting up libgsoap8:amd64 (2.8.28-1) ... Setting up libvncserver1:amd64 (0.9.10+dfsg-3ubuntu0.16.04.3) ... Setting up virtualbox-dkms (5.1.38-dfsg-0ubuntu1.16.04.2) ... Loading new virtualbox-5.1.38 DKMS files... First Installation: checking all kernels... Building only for 4.15.0-43-generic Building initial module for 4.15.0-43-generic Done. vboxdrv: Running module version sanity check. - Original module - No original module exists within this kernel - Installation - Installing to /lib/modules/4.15.0-43-generic/updates/dkms/ vboxnetadp.ko: Running module version sanity check. - Original module - No original module exists within this kernel - Installation - Installing to /lib/modules/4.15.0-43-generic/updates/dkms/ vboxnetflt.ko: Running module version sanity check. - Original module - No original module exists within this kernel - Installation - Installing to /lib/modules/4.15.0-43-generic/updates/dkms/ vboxpci.ko: Running module version sanity check. - Original module - No original module exists within this kernel - Installation - Installing to /lib/modules/4.15.0-43-generic/updates/dkms/ depmod.... DKMS: install completed. Setting up virtualbox (5.1.38-dfsg-0ubuntu1.16.04.2) ... vboxweb.service is a disabled or a static unit, not starting it. Setting up virtualbox-qt (5.1.38-dfsg-0ubuntu1.16.04.2) ... Processing triggers for libc-bin (2.23-0ubuntu10) ... Processing triggers for systemd (229-4ubuntu21.15) ... Processing triggers for ureadahead (0.100.0-19) ... Processing triggers for menu (2.1.47ubuntu1.16.04.1) ... yo@yo-Lenovo-G510:~/Homestead$ cd /media/yo/Storage/Distribute/Linux/ yo@yo-Lenovo-G510:/media/yo/Storage/Distribute/Linux$ sudo gpkg -i vagrant_2.2.3_x86_64.deb sudo: gpkg: command not found yo@yo-Lenovo-G510:/media/yo/Storage/Distribute/Linux$ sudo dpkg -i vagrant_2.2.3_x86_64.deb (Reading database ... 364657 files and directories currently installed.) Preparing to unpack vagrant_2.2.3_x86_64.deb ... Unpacking vagrant (1:2.2.3) over (1:2.2.3) ... Setting up vagrant (1:2.2.3) ... yo@yo-Lenovo-G510:/media/yo/Storage/Distribute/Linux$
    bash:
    yo@yo-Lenovo-G510:/media/yo/Storage/Distribute/Linux$ cd ~ yo@yo-Lenovo-G510:~$ yo@yo-Lenovo-G510:~$ yo@yo-Lenovo-G510:~$ yo@yo-Lenovo-G510:~$ vagrant box add laravel/homestead ==> box: Loading metadata for box 'laravel/homestead' box: URL: https://vagrantcloud.com/laravel/homestead This box can work with multiple providers! The providers that it can work with are listed below. Please review the list and choose the provider you will be working with. 1) hyperv 2) parallels 3) virtualbox 4) vmware_desktop Enter your choice: 3 ==> box: Adding box 'laravel/homestead' (v7.0.0) for provider: virtualbox box: Downloading: https://vagrantcloud.com/laravel/boxes/homestead/versions/7.0.0/providers/virtualbox.box box: Download redirected to host: vagrantcloud-files-production.s3.amazonaws.com ==> box: Successfully added box 'laravel/homestead' (v7.0.0) for 'virtualbox'! yo@yo-Lenovo-G510:~$ yo@yo-Lenovo-G510:~$ yo@yo-Lenovo-G510:~$ yo@yo-Lenovo-G510:~$ git clone https://github.com/laravel/homestead.git ~/Homestead Cloning into '/home/yo/Homestead'... remote: Enumerating objects: 24, done. remote: Counting objects: 100% (24/24), done. remote: Compressing objects: 100% (17/17), done. remote: Total 3298 (delta 6), reused 14 (delta 5), pack-reused 3274 Receiving objects: 100% (3298/3298), 708.05 KiB | 655.00 KiB/s, done. Resolving deltas: 100% (1985/1985), done. Checking connectivity... done. yo@yo-Lenovo-G510:~$ cd ~/Homestead yo@yo-Lenovo-G510:~/Homestead$ git checkout v8.0.1 Note: checking out 'v8.0.1'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b HEAD is now at 499ab1c... 💎 🔖 Tagging v8.0.1 yo@yo-Lenovo-G510:~/Homestead$ bash init.sh Homestead initialized! yo@yo-Lenovo-G510:~/Homestead$ yo@yo-Lenovo-G510:~/Homestead$ yo@yo-Lenovo-G510:~/Homestead$ yo@yo-Lenovo-G510:~/Homestead$ vagrant up Bringing machine 'homestead-7' up with 'virtualbox' provider... ==> homestead-7: Importing base box 'laravel/homestead'... ==> homestead-7: Matching MAC address for NAT networking... ==> homestead-7: Checking if box 'laravel/homestead' version '7.0.0' is up to date... ==> homestead-7: Setting the name of the VM: homestead-7 Vagrant is currently configured to create VirtualBox synced folders with the `SharedFoldersEnableSymlinksCreate` option enabled. If the Vagrant guest is not trusted, you may want to disable this option. For more information on this option, please refer to the VirtualBox manual: https://www.virtualbox.org/manual/ch04.html#sharedfolders This option can be disabled globally with an environment variable: VAGRANT_DISABLE_VBOXSYMLINKCREATE=1 or on a per folder basis within the Vagrantfile: config.vm.synced_folder '/host/path', '/guest/path', SharedFoldersEnableSymlinksCreate: false ==> homestead-7: Vagrant has detected a configuration issue which exposes a ==> homestead-7: vulnerability with the installed version of VirtualBox. The ==> homestead-7: current guest is configured to use an E1000 NIC type for a ==> homestead-7: network adapter which is vulnerable in this version of VirtualBox. ==> homestead-7: Ensure the guest is trusted to use this configuration or update ==> homestead-7: the NIC type using one of the methods below: ==> homestead-7: ==> homestead-7: https://www.vagrantup.com/docs/virtualbox/configuration.html#default-nic-type ==> homestead-7: https://www.vagrantup.com/docs/virtualbox/networking.html#virtualbox-nic-type ==> homestead-7: Clearing any previously set network interfaces... ==> homestead-7: Preparing network interfaces based on configuration... homestead-7: Adapter 1: nat homestead-7: Adapter 2: hostonly ==> homestead-7: Forwarding ports... homestead-7: 80 (guest) => 8000 (host) (adapter 1) homestead-7: 443 (guest) => 44300 (host) (adapter 1) homestead-7: 3306 (guest) => 33060 (host) (adapter 1) homestead-7: 4040 (guest) => 4040 (host) (adapter 1) homestead-7: 5432 (guest) => 54320 (host) (adapter 1) homestead-7: 8025 (guest) => 8025 (host) (adapter 1) homestead-7: 27017 (guest) => 27017 (host) (adapter 1) homestead-7: 22 (guest) => 2222 (host) (adapter 1) ==> homestead-7: Running 'pre-boot' VM customizations... ==> homestead-7: Booting VM... ==> homestead-7: Waiting for machine to boot. This may take a few minutes... homestead-7: SSH address: 127.0.0.1:2222 homestead-7: SSH username: vagrant homestead-7: SSH auth method: private key homestead-7: Warning: Remote connection disconnect. Retrying... homestead-7: homestead-7: Vagrant insecure key detected. Vagrant will automatically replace homestead-7: this with a newly generated keypair for better security. homestead-7: homestead-7: Inserting generated public key within guest... homestead-7: Removing insecure key from the guest if it's present... homestead-7: Key inserted! Disconnecting and reconnecting using new SSH key... ==> homestead-7: Machine booted and ready! ==> homestead-7: Checking for guest additions in VM... homestead-7: The guest additions on this VM do not match the installed version of homestead-7: VirtualBox! In most cases this is fine, but in rare cases it can homestead-7: prevent things such as shared folders from working properly. If you see homestead-7: shared folder errors, please make sure the guest additions within the homestead-7: virtual machine match the version of VirtualBox you have installed on homestead-7: your host and reload your VM. homestead-7: homestead-7: Guest Additions Version: 5.2.8_KernelUbuntu r120774 homestead-7: VirtualBox Version: 5.1 ==> homestead-7: Setting hostname... ==> homestead-7: Configuring and enabling network interfaces... ==> homestead-7: Mounting shared folders... homestead-7: /vagrant => /home/yo/Homestead homestead-7: /home/vagrant/projects => /home/yo/projects ==> homestead-7: Running provisioner: file... homestead-7: /home/yo/Homestead/aliases => /tmp/bash_aliases ==> homestead-7: Running provisioner: shell... homestead-7: Running: inline script ==> homestead-7: Running provisioner: shell... homestead-7: Running: inline script homestead-7: homestead-7: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQD5sGwmNySnia9NpF+v/iZ9niCYuO2B5uoyNsdtC5m5squ7JWT7NLko+JVkiZFb5ocu+wAHP8tlJetAfRWNAwIDCQfpcLOdP5dohxR27xCD7pa8ZzSA5uVmLvOgPyJM2YWXNF80aFuBFL2XgJl766W7uuCXQFtdcQNAuc0ykyeuVdeg5wGw4WKEloYbWcsEGuXxGMMiUZmS5zRxksEZe6QB2Pk6L5Npb4+HDPgm9wn57zDqJCSjmTA+rotbUjifldHJw4PTvdnL5E8OGFGANcQ8RZgKAdX+H8XA9ghjNEWhal9FM1erFzCaM4WhZ6mb8+YzINDvGAf4KFZ+yAt1/ZK+hlv3LVLsbDfJ1I6M/zmj7F1zYTMiwsM2E5KX+/ea8m96TeJz1ASeRTxbF/LXwGjEgtTOBZtEPDBDCbuZCJpM6C80lS0i2ymeMEAzcKMAYbqrLyLhOAw2nnoqSPRWBrFf8WPr73s2tOc0RQFSjCQ+unW9hK52xLFBvptBPL1eBaxt/eKvblJEVrCUUgwpX88wJyxbQKaf45FG+czJZxGBP71quV3yavb0mqIU+Z6rJGfHy0YGo6RoGY8gkkrba60XnJYxrMl3HpsunR9A2xhl2F59yGgUtNQEFPxrHXF4A9k3+l4uGhaJ1uVaZ8riMS17aNZysWAy7FP6Y1Ft7Z+p2Q== yo@yo-Lenovo-G510 ==> homestead-7: Running provisioner: shell... homestead-7: Running: inline script ==> homestead-7: Running provisioner: shell... homestead-7: Running: /tmp/vagrant-shell20190203-419-1vi3fh1.sh ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating Certificate: socket-wrench.test ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating Site: socket-wrench.test ==> homestead-7: Running provisioner: shell... homestead-7: Running: inline script ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Checking for old Schedule ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating Certificate: laravel.test ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating Site: laravel.test ==> homestead-7: Running provisioner: shell... homestead-7: Running: inline script ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Checking for old Schedule ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Clear Variables ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Restarting Cron ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Restarting Nginx ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating MySQL Database: socket_wrench ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating Postgres Database: socket_wrench ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating MySQL Database: homestead ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating Postgres Database: homestead ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Update Composer homestead-7: Updating to version 1.8.3 (stable channel). homestead-7: homestead-7: homestead-7: [ErrorException] homestead-7: rename(/home/vagrant/.composer/cache/composer-temp.phar,/usr/local/bin/composer): Permission denied homestead-7: homestead-7: homestead-7: self-update [-r|--rollback] [--clean-backups] [--no-progress] [--update-keys] [--stable] [--preview] [--snapshot] [--set-channel-only] [--] [] The SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed. The output for this command should be in the log above. Please read the output to determine what went wrong. yo@yo-Lenovo-G510:~/Homestead$

    В этот раз для чистоты эксперимента я не стал пытаться устранить ошибку обновления Composer. После обновления его до версии 1.8.3 команда vagrant reload --provision выдает сообщение о невозможности использования этой версии.

    bash:
    yo@yo-Lenovo-G510:~/Homestead$ vagrant ssh Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-43-generic x86_64) _ _ _ | | | | | | | |__ ___ _ __ ___ ___ ___| |_ ___ __ _ __| | | '_ \ / _ \| '_ ` _ \ / _ \/ __| __/ _ \/ _` |/ _` | | | | | (_) | | | | | | __/\__ \ || __/ (_| | (_| | |_| |_|\___/|_| |_| |_|\___||___/\__\___|\__,_|\__,_| * FYI Vagrant v2.2.2 & Virtualbox: * https://twitter.com/HomesteadDev/status/1071471881256079362 0 packages can be updated. 0 updates are security updates. vagrant@homestead:~$ cd projects/ vagrant@homestead:~/projects$ composer global require laravel/installer Changed current directory to /home/vagrant/.composer Using version ^2.0 for laravel/installer ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Nothing to install or update Writing lock file Generating autoload files vagrant@homestead:~/projects$ composer create-project --prefer-dist laravel/laravel laravel Installing laravel/laravel (v5.7.19) - Installing laravel/laravel (v5.7.19): Downloading (100%) Created project in laravel > @php -r "file_exists('.env') || copy('.env.example', '.env');" Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 86 installs, 0 updates, 0 removals - Installing symfony/polyfill-ctype (v1.10.0): Loading from cache - Installing vlucas/phpdotenv (v2.6.1): Downloading (100%) - Installing symfony/css-selector (v4.2.2): Downloading (100%) - Installing tijsverkoyen/css-to-inline-styles (2.2.1): Downloading (100%) - Installing symfony/polyfill-php72 (v1.10.0): Downloading (100%) - Installing symfony/polyfill-mbstring (v1.10.0): Loading from cache - Installing symfony/var-dumper (v4.2.2): Downloading (100%) - Installing symfony/routing (v4.2.2): Downloading (100%) - Installing symfony/process (v4.2.2): Loading from cache - Installing symfony/http-foundation (v4.2.2): Downloading (100%) - Installing symfony/contracts (v1.0.2): Loading from cache - Installing symfony/event-dispatcher (v4.2.2): Downloading (100%) - Installing psr/log (1.1.0): Downloading (100%) - Installing symfony/debug (v4.2.2): Downloading (100%) - Installing symfony/http-kernel (v4.2.2): Downloading (100%) - Installing symfony/finder (v4.2.2): Loading from cache - Installing symfony/console (v4.2.2): Loading from cache - Installing doctrine/lexer (v1.0.1): Downloading (100%) - Installing egulias/email-validator (2.1.7): Downloading (100%) - Installing swiftmailer/swiftmailer (v6.1.3): Downloading (100%) - Installing paragonie/random_compat (v9.99.99): Downloading (100%) - Installing ramsey/uuid (3.8.0): Downloading (100%) - Installing psr/simple-cache (1.0.1): Loading from cache - Installing psr/container (1.0.0): Loading from cache - Installing opis/closure (3.1.5): Downloading (100%) - Installing symfony/translation (v4.2.2): Loading from cache - Installing nesbot/carbon (1.36.2): Loading from cache - Installing monolog/monolog (1.24.0): Downloading (100%) - Installing league/flysystem (1.0.50): Downloading (100%) - Installing erusev/parsedown (1.7.1): Downloading (100%) - Installing dragonmantank/cron-expression (v2.2.0): Downloading (100%) - Installing doctrine/inflector (v1.3.0): Loading from cache - Installing ralouphie/getallheaders (2.0.5): Loading from cache - Installing psr/http-message (1.0.1): Loading from cache - Installing guzzlehttp/psr7 (1.5.2): Loading from cache - Installing guzzlehttp/promises (v1.3.1): Loading from cache - Installing guzzlehttp/guzzle (6.3.3): Loading from cache - Installing laravel/slack-notification-channel (v1.0.3): Downloading (100%) - Installing laravel/framework (v5.7.24): Downloading (100%) - Installing lcobucci/jwt (3.2.5): Downloading (100%) - Installing php-http/promise (v1.0.0): Downloading (100%) - Installing php-http/httplug (v1.1.0): Downloading (100%) - Installing php-http/guzzle6-adapter (v1.1.1): Downloading (100%) - Installing zendframework/zend-diactoros (1.8.6): Downloading (100%) - Installing nexmo/client (1.6.1): Downloading (100%) - Installing laravel/nexmo-notification-channel (v1.0.1): Downloading (100%) - Installing fideloper/proxy (4.1.0): Downloading (100%) - Installing nikic/php-parser (v4.2.0): Downloading (100%) - Installing jakub-onderka/php-console-color (v0.2): Downloading (100%) - Installing jakub-onderka/php-console-highlighter (v0.4): Downloading (100%) - Installing dnoegel/php-xdg-base-dir (0.1): Downloading (100%) - Installing psy/psysh (v0.9.9): Downloading (100%) - Installing laravel/tinker (v1.0.8): Downloading (100%) - Installing beyondcode/laravel-dump-server (1.2.2): Downloading (100%) - Installing fzaninotto/faker (v1.8.0): Downloading (100%) - Installing hamcrest/hamcrest-php (v2.0.0): Downloading (100%) - Installing mockery/mockery (1.2.0): Downloading (100%) - Installing filp/whoops (2.3.1): Downloading (100%) - Installing nunomaduro/collision (v2.1.1): Downloading (100%) - Installing sebastian/version (2.0.1): Downloading (100%) - Installing sebastian/resource-operations (2.0.1): Downloading (100%) - Installing sebastian/object-reflector (1.1.1): Downloading (100%) - Installing sebastian/recursion-context (3.0.0): Downloading (100%) - Installing sebastian/object-enumerator (3.0.3): Downloading (100%) - Installing sebastian/global-state (2.0.0): Downloading (100%) - Installing sebastian/exporter (3.1.0): Downloading (100%) - Installing sebastian/environment (4.1.0): Downloading (100%) - Installing sebastian/diff (3.0.1): Downloading (100%) - Installing sebastian/comparator (3.0.2): Downloading (100%) - Installing phpunit/php-timer (2.0.0): Downloading (100%) - Installing phpunit/php-text-template (1.2.1): Downloading (100%) - Installing phpunit/php-file-iterator (2.0.2): Downloading (100%) - Installing theseer/tokenizer (1.1.0): Downloading (100%) - Installing sebastian/code-unit-reverse-lookup (1.0.1): Downloading (100%) - Installing phpunit/php-token-stream (3.0.1): Downloading (100%) - Installing phpunit/php-code-coverage (6.1.4): Downloading (100%) - Installing doctrine/instantiator (1.1.0): Downloading (100%) - Installing webmozart/assert (1.4.0): Downloading (100%) - Installing phpdocumentor/reflection-common (1.0.1): Downloading (100%) - Installing phpdocumentor/type-resolver (0.4.0): Downloading (100%) - Installing phpdocumentor/reflection-docblock (4.3.0): Downloading (100%) - Installing phpspec/prophecy (1.8.0): Downloading (100%) - Installing phar-io/version (2.0.1): Downloading (100%) - Installing phar-io/manifest (1.0.3): Downloading (100%) - Installing myclabs/deep-copy (1.8.1): Downloading (100%) - Installing phpunit/phpunit (7.5.3): Downloading (100%) symfony/routing suggests installing doctrine/annotations (For using the annotation loader) symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader) symfony/routing suggests installing symfony/dependency-injection (For loading routes from a service) symfony/routing suggests installing symfony/expression-language (For using expression matching) symfony/routing suggests installing symfony/yaml (For using the YAML loader) symfony/contracts suggests installing psr/cache (When using the Cache contracts) symfony/contracts suggests installing symfony/cache-contracts-implementation symfony/contracts suggests installing symfony/service-contracts-implementation symfony/event-dispatcher suggests installing symfony/dependency-injection symfony/http-kernel suggests installing symfony/browser-kit symfony/http-kernel suggests installing symfony/config symfony/http-kernel suggests installing symfony/dependency-injection symfony/console suggests installing symfony/lock swiftmailer/swiftmailer suggests installing true/punycode (Needed to support internationalized email addresses, if ext-intl is not installed) paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.) ramsey/uuid suggests installing ircmaxell/random-lib (Provides RandomLib for use with the RandomLibAdapter) ramsey/uuid suggests installing ext-libsodium (Provides the PECL libsodium extension for use with the SodiumRandomGenerator) ramsey/uuid suggests installing ext-uuid (Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator) ramsey/uuid suggests installing moontoast/math (Provides support for converting UUID to 128-bit integer (in string form).) ramsey/uuid suggests installing ramsey/uuid-doctrine (Allows the use of Ramsey\Uuid\Uuid as Doctrine field type.) ramsey/uuid suggests installing ramsey/uuid-console (A console application for generating UUIDs with ramsey/uuid) symfony/translation suggests installing symfony/config symfony/translation suggests installing symfony/yaml nesbot/carbon suggests installing friendsofphp/php-cs-fixer (Needed for the `composer phpcs` command. Allow to automatically fix code style.) nesbot/carbon suggests installing phpstan/phpstan (Needed for the `composer phpstan` command. Allow to detect potential errors.) monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB) monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server) monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required)) monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server) monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server) monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver) monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib) monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome) monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar) monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server) monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server) league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2) league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3) league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage) league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching) league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem) league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files) league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib) league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage) league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter) league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage) league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications) laravel/framework suggests installing aws/aws-sdk-php (Required to use the SQS queue driver and SES mail driver (^3.0).) laravel/framework suggests installing doctrine/dbal (Required to rename columns and drop SQLite columns (^2.6).) laravel/framework suggests installing league/flysystem-aws-s3-v3 (Required to use the Flysystem S3 driver (^1.0).) laravel/framework suggests installing league/flysystem-cached-adapter (Required to use the Flysystem cache (^1.0).) laravel/framework suggests installing league/flysystem-rackspace (Required to use the Flysystem Rackspace driver (^1.0).) laravel/framework suggests installing league/flysystem-sftp (Required to use the Flysystem SFTP driver (^1.0).) laravel/framework suggests installing moontoast/math (Required to use ordered UUIDs (^1.1).) laravel/framework suggests installing pda/pheanstalk (Required to use the beanstalk queue driver (^3.0).) laravel/framework suggests installing predis/predis (Required to use the redis cache and queue drivers (^1.0).) laravel/framework suggests installing pusher/pusher-php-server (Required to use the Pusher broadcast driver (^3.0).) laravel/framework suggests installing symfony/dom-crawler (Required to use most of the crawler integration testing tools (^4.1).) laravel/framework suggests installing symfony/psr-http-message-bridge (Required to psr7 bridging features (^1.0).) lcobucci/jwt suggests installing mdanter/ecc (Required to use Elliptic Curves based algorithms.) psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.) psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.) filp/whoops suggests installing whoops/soap (Formats errors as SOAP responses) sebastian/global-state suggests installing ext-uopz (*) phpunit/php-code-coverage suggests installing ext-xdebug (^2.6.0) phpunit/phpunit suggests installing phpunit/php-invoker (^2.0) phpunit/phpunit suggests installing ext-xdebug (*) Writing lock file Generating optimized autoload files > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover --ansi Discovered Package: beyondcode/laravel-dump-server Discovered Package: fideloper/proxy Discovered Package: laravel/nexmo-notification-channel Discovered Package: laravel/slack-notification-channel Discovered Package: laravel/tinker Discovered Package: nesbot/carbon Discovered Package: nunomaduro/collision Package manifest generated successfully. > @php artisan key:generate --ansi Application key set successfully. vagrant@homestead:~/projects$

    На данном этапе, если постараться, уже можно увидеть проскакивающую по F5 502 страницу:

    Рис. 1 502 Bed gateway
    Рис. 1 502 Bed gateway
    Рис. 2 laravel стартовая страница
    Рис. 2 laravel стартовая страница
    bash:
    vagrant@homestead:~/projects$ cd laravel/ vagrant@homestead:~/projects/laravel$ php artisan make:auth Authentication scaffolding generated successfully. vagrant@homestead:~/projects/laravel$ php artisan migrate Migration table created successfully. Migrating: 2014_10_12_000000_create_users_table Migrated: 2014_10_12_000000_create_users_table Migrating: 2014_10_12_100000_create_password_resets_table Migrated: 2014_10_12_100000_create_password_resets_table vagrant@homestead:~/projects/laravel$

    Проверяем:

    Рис. 3 Добавление аутентификации
    Рис. 3 Добавление аутентификации
    Рис. 4 Регистрация пользователя
    Рис. 4 Регистрация пользователя
    Рис. 5 502 ошибка при регистраци
    Рис. 5 502 ошибка при регистраци
    Рис. 6 Unsupported operand types
    Рис. 6 Unsupported operand types

    По совету отсюда добавляю в конфиг Homestead.yaml 'php: "7.2"':

    sites: - map: laravel.test to: /home/vagrant/projects/laravel/public php: "7.2"

    Перегружаю vagrant машину (применяю настройки).

    bash:
    vagrant@homestead:~/projects/laravel$ exit logout Connection to 127.0.0.1 closed. yo@yo-Lenovo-G510:~/Homestead$ vagrant reload --provision ==> homestead-7: Attempting graceful shutdown of VM... ==> homestead-7: Checking if box 'laravel/homestead' version '7.0.0' is up to date... ==> homestead-7: Clearing any previously set forwarded ports... ==> homestead-7: Vagrant has detected a configuration issue which exposes a ==> homestead-7: vulnerability with the installed version of VirtualBox. The ==> homestead-7: current guest is configured to use an E1000 NIC type for a ==> homestead-7: network adapter which is vulnerable in this version of VirtualBox. ==> homestead-7: Ensure the guest is trusted to use this configuration or update ==> homestead-7: the NIC type using one of the methods below: ==> homestead-7: ==> homestead-7: https://www.vagrantup.com/docs/virtualbox/configuration.html#default-nic-type ==> homestead-7: https://www.vagrantup.com/docs/virtualbox/networking.html#virtualbox-nic-type ==> homestead-7: Clearing any previously set network interfaces... ==> homestead-7: Preparing network interfaces based on configuration... homestead-7: Adapter 1: nat homestead-7: Adapter 2: hostonly ==> homestead-7: Forwarding ports... homestead-7: 80 (guest) => 8000 (host) (adapter 1) homestead-7: 443 (guest) => 44300 (host) (adapter 1) homestead-7: 3306 (guest) => 33060 (host) (adapter 1) homestead-7: 4040 (guest) => 4040 (host) (adapter 1) homestead-7: 5432 (guest) => 54320 (host) (adapter 1) homestead-7: 8025 (guest) => 8025 (host) (adapter 1) homestead-7: 27017 (guest) => 27017 (host) (adapter 1) homestead-7: 22 (guest) => 2222 (host) (adapter 1) ==> homestead-7: Running 'pre-boot' VM customizations... ==> homestead-7: Booting VM... ==> homestead-7: Waiting for machine to boot. This may take a few minutes... homestead-7: SSH address: 127.0.0.1:2222 homestead-7: SSH username: vagrant homestead-7: SSH auth method: private key homestead-7: Warning: Remote connection disconnect. Retrying... ==> homestead-7: Machine booted and ready! ==> homestead-7: Checking for guest additions in VM... homestead-7: The guest additions on this VM do not match the installed version of homestead-7: VirtualBox! In most cases this is fine, but in rare cases it can homestead-7: prevent things such as shared folders from working properly. If you see homestead-7: shared folder errors, please make sure the guest additions within the homestead-7: virtual machine match the version of VirtualBox you have installed on homestead-7: your host and reload your VM. homestead-7: homestead-7: Guest Additions Version: 6.0.0 r127566 homestead-7: VirtualBox Version: 5.1 ==> homestead-7: Setting hostname... ==> homestead-7: Configuring and enabling network interfaces... ==> homestead-7: Mounting shared folders... homestead-7: /vagrant => /home/yo/Homestead homestead-7: /home/vagrant/projects => /home/yo/projects ==> homestead-7: Running provisioner: file... homestead-7: /home/yo/Homestead/aliases => /tmp/bash_aliases ==> homestead-7: Running provisioner: shell... homestead-7: Running: inline script ==> homestead-7: Running provisioner: shell... homestead-7: Running: inline script ==> homestead-7: Running provisioner: shell... homestead-7: Running: inline script ==> homestead-7: Running provisioner: shell... homestead-7: Running: /tmp/vagrant-shell20190203-9359-1sy9evc.sh ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating Certificate: socket-wrench.test ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating Site: socket-wrench.test ==> homestead-7: Running provisioner: shell... homestead-7: Running: inline script ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Checking for old Schedule ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating Certificate: laravel.test ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating Site: laravel.test ==> homestead-7: Running provisioner: shell... homestead-7: Running: inline script ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Checking for old Schedule ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Clear Variables ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Restarting Cron ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Restarting Nginx ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating MySQL Database: socket_wrench ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating Postgres Database: socket_wrench ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating MySQL Database: homestead ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Creating Postgres Database: homestead ==> homestead-7: Running provisioner: shell... homestead-7: Running: script: Update Composer homestead-7: Updating to version 1.8.3 (stable channel). homestead-7: homestead-7: homestead-7: [ErrorException] homestead-7: rename(/home/vagrant/.composer/cache/composer-temp.phar,/usr/local/bin/composer): Permission denied homestead-7: homestead-7: homestead-7: self-update [-r|--rollback] [--clean-backups] [--no-progress] [--update-keys] [--stable] [--preview] [--snapshot] [--set-channel-only] [--] [] The SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed. The output for this command should be in the log above. Please read the output to determine what went wrong. yo@yo-Lenovo-G510:~/Homestead$

    Проверяем:

    Рис. 7 отображение залогиненного пользователя после применения настроек Homestead.yaml
    Рис. 7 отображение залогиненного пользователя после применения настроек Homestead.yaml

    RBAC (Role-Based Access Control) library - добавление системы разделения прав на основе ролей пользователей.

    Источник

    Мануал

    bash:
    yo@yo-Lenovo-G510:~/Homestead$ vagrant ssh Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-43-generic x86_64) _ _ _ | | | | | | | |__ ___ _ __ ___ ___ ___| |_ ___ __ _ __| | | '_ \ / _ \| '_ ` _ \ / _ \/ __| __/ _ \/ _` |/ _` | | | | | (_) | | | | | | __/\__ \ || __/ (_| | (_| | |_| |_|\___/|_| |_| |_|\___||___/\__\___|\__,_|\__,_| * Homestead 8.0.0 released! PHP 7.3 is now the default! * Settler v7.0.0 released! Make sure you update * Need PHP 5.6 or 7.0? Homestead 7.x Settler 6.4.0 0 packages can be updated. 0 updates are security updates. Last login: Sun Feb 3 08:56:49 2019 from 10.0.2.2 vagrant@homestead:~$ vagrant@homestead:~/projects/laravel$ composer require centeron/laravel-roles-permissions Using version ^1.0 for centeron/laravel-roles-permissions ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 1 install, 0 updates, 0 removals - Installing centeron/laravel-roles-permissions (1.0.4): Downloading (100%) Writing lock file Generating optimized autoload files > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover --ansi Discovered Package: beyondcode/laravel-dump-server Discovered Package: centeron/laravel-roles-permissions Discovered Package: fideloper/proxy Discovered Package: laravel/nexmo-notification-channel Discovered Package: laravel/slack-notification-channel Discovered Package: laravel/tinker Discovered Package: nesbot/carbon Discovered Package: nunomaduro/collision Package manifest generated successfully. vagrant@homestead:~/projects/laravel$ vagrant@homestead:~/projects/laravel$ php artisan vendor:publish --provider="Centeron\Permissions\ServiceProvider" --tag="migrations" Publishing complete. vagrant@homestead:~/projects/laravel$ php artisan migrate Migrating: 2018_09_28_000000_create_permission_tables Migrated: 2018_09_28_000000_create_permission_tables vagrant@homestead:~/projects/laravel$

    Добавляю трейт Centeron\Permissions\Traits\HasAuthItems к модели пользователей User:

    /home/yo/projects/laravel/app/User.php:
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18


      
    namespace App;

      use 
    Illuminate\Notifications\Notifiable;
      use 
    Illuminate\Contracts\Auth\MustVerifyEmail;
      use 
    Illuminate\Foundation\Auth\User as Authenticatable;

      use 
    Centeron\Permissions\Traits\HasAuthItems;// add RBAC

      
    class User extends Authenticatable
      
    {
        
    // use Notifiable;
        
    use NotifiableHasAuthItems;// add RBAC

      
    ...

      

    Пропишем в файле '/home/yo/projects/laravel/resources/views/home.blade.php' следующий код из мануала (проверка на допуски с помощью директив шаблонизатора Blade):

    /home/yo/projects/laravel/resources/views/home.blade.php:
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32

      
    @extends('layouts.app')

      @
    section('content')
      <
    div class="container">

      ...

        @
    authHasAny('Edit post''View post')
          
    // Showing info if a user can edit or view post
        
    @authEnd

        
    @authHasAll('Edit post''View post')
          
    // Showing info if a user can edit and view post
        
    @authElse
          
    // Otherwise
        
    @authEnd


        
    @authCanAny(['Edit post''View post'], [1])
          
    // Showing info if a user can edit or view post with ID=1
        
    @authEnd

        
    @authCanAll(['Edit post''View post'], [1])
          
    // Showing info if a user can edit and view post with ID=1
        
    @authElse
          
    // Otherwise
        
    @authEnd

      
    </div>
      @
    endsection