過程
也不用說這麼多了,之前印象中在樹梅派上已經抓過composer
如果需要回憶的話可以參考 composer官方
以及 【Docker AWS PHP】AWS官方AMI docker image,laravel 5.4 開發環境建立
直接偷懶上了
pi@raspberrypi:/opt $ ./composer.phar global require "laravel/installer" Changed current directory to /home/pi/.config/composer Using version ^2.0 for laravel/installer ./composer.json has been created *中略 Generating autoload files pi@raspberrypi:/opt $安裝的挺身層的
執行一下看看
pi@raspberrypi:/opt $ /home/pi/.config/composer/vendor/laravel/installer/laravel -h Usage: list [options] [--] [看起來沒問題,切目錄過去直接執行吧] Arguments: namespace The namespace name Options: --raw To output raw command list --format=FORMAT The output format (txt, xml, json, or md) [default: "txt"] Help: The list command lists all commands: php /home/pi/.config/composer/vendor/laravel/installer/laravel list You can also display the commands for a specific namespace: php /home/pi/.config/composer/vendor/laravel/installer/laravel list test You can also output the information in other formats by using the --format option: php /home/pi/.config/composer/vendor/laravel/installer/laravel list --format=xml It's also possible to get raw list of commands (useful for embedding command runner): php /home/pi/.config/composer/vendor/laravel/installer/laravel list --raw
pi@raspberrypi:/var/www/html $ sudo /home/pi/.config/composer/vendor/laravel/installer/laravel new weijlab Crafting application... sh: 1: composer: not found忘記改$path...
省麻煩直接丟去給系統吃
pi@raspberrypi:/var/www/html $ sudo cp /opt/composer.phar /usr/local/bin/composer順便檢查一下
pi@raspberrypi:/var/www/html $ composer -V Composer version 1.4.2 2017-05-17 08:17:52看起來有了,在試一次
pi@raspberrypi:/var/www/html $ sudo /home/pi/.config/composer/vendor/laravel/installer/laravel new weijlab Crafting application... 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 Your requirements could not be resolved to an installable set of packages. Problem 1 - This package requires php ^7.1.3 but your PHP version (5.6.30) does not satisfy that requirement. * 下略版本...天啊...暈,要php7阿...
開工弄一下
pi@raspberrypi:/var/www/html $ sudo vim /etc/apt/sources.list 加上一句 deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi pi@raspberrypi:/var/www/html $ sudo vim /etc/apt/sources.list pi@raspberrypi:/var/www/html $ sudo apt-get update pi@raspberrypi:/var/www/html $ sudo apt-get install -t stretch php7.0中間會問你要不要改現在的設定到php7
改阿幹嘛不改,頭都洗下去了
Configuration file '/etc/apache2/envvars' ==> Modified (by you or by a script) since installation. ==> Package distributor has shipped an updated version. What would you like to do about it ? Your options are: Y or I : install the package maintainer's version N or O : keep your currently-installed version D : show the differences between the versions Z : start a shell to examine the situation The default action is to keep your current version. *** envvars (Y/I/N/O/D/Z) [default=N] ? y Installing new version of config file /etc/apache2/envvars ... Installing new version of config file /etc/apache2/mods-available/proxy_html.load ... Installing new version of config file /etc/apache2/mods-available/userdir.conf ... Installing new version of config file /etc/apache2/sites-available/default-ssl.conf ... Installing new version of config file /etc/cron.daily/apache2 ... Installing new version of config file /etc/init.d/apache2 ... Removing obsolete conffile /etc/bash_completion.d/apache2 ... insserv: warning: current start runlevel(s) (empty) of script `apache-htcacheclean' overrides LSB defaults (2 3 4 5). insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `apache-htcacheclean' overrides LSB defaults (0 1 6). Setting up libssl1.1:armhf (1.1.0f-3+deb9u2) ... Setting up php-common (1:49) ... Setting up php7.0-common (7.0.30-0+deb9u1) ... Creating config file /etc/php/7.0/mods-available/calendar.ini with new version Creating config file /etc/php/7.0/mods-available/ctype.ini with new version Creating config file /etc/php/7.0/mods-available/exif.ini with new version Creating config file /etc/php/7.0/mods-available/fileinfo.ini with new version Creating config file /etc/php/7.0/mods-available/ftp.ini with new version Creating config file /etc/php/7.0/mods-available/gettext.ini with new version Creating config file /etc/php/7.0/mods-available/iconv.ini with new version *下略確認版本後再裝一次
pi@raspberrypi:/var/www/html $ php -v PHP 7.0.30-0+deb9u1 (cli) (built: Jun 14 2018 13:50:25) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.30-0+deb9u1, Copyright (c) 1999-2017, by Zend Technologies pi@raspberrypi:/var/www/html $ sudo /home/pi/.config/composer/vendor/laravel/installer/laravel new weijlab In NewCommand.php line 44: The Zip PHP extension is not installed. Please install it and try again. new [--dev] [--force] [--] [想哭,再來裝個zip extension]
pi@raspberrypi:/var/www/html $ sudo apt-get install php7.0-zip在試一次
pi@raspberrypi:/var/www/html $ sudo rm -rf ./weijlab pi@raspberrypi:/var/www/html $ sudo /home/pi/.config/composer/vendor/laravel/installer/laravel new weijlab Crafting application... 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 Your requirements could not be resolved to an installable set of packages. Problem 1 - This package requires php ^7.1.3 but your PHP version (7.0.30) does not satisfy that requirement.這是跟你說你一定要php7.1.3了
要這麼新幹嘛...
那就降版吧...
依照 laravel 官方說明下指令
pi@raspberrypi:/var/www/html $ sudo /opt/composer.phar create-project --prefer-dist laravel/laravel weijlab "5.2.*" pi@raspberrypi:/var/www/html $ sudo /opt/composer.phar create-project --prefer-dist laravel/laravel weijlab "5.2.*" Do not run Composer as root/super user! See https://getcomposer.org/root for details Installing laravel/laravel (v5.2.31) - Installing laravel/laravel (v5.2.31): Downloading (100%) Created project in weijlab > php -r "copy('.env.example', '.env');" Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 - laravel/framework v5.2.9 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system. - laravel/framework v5.2.8 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system. - laravel/framework v5.2.7 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.補上mbstring跟dom...
其實我都不知道自己在裝什麼了
pi@raspberrypi:/var/www/html $ sudo apt-get install php7.0-mbstring php7.0-dom再來一次
pi@raspberrypi:/var/www/html $ sudo rm -rf ./weijlab pi@raspberrypi:/var/www/html $ sudo /opt/composer.phar create-project --prefer-dist laravel/laravel weijlab "5.2.*" *中略 sebastian/global-state suggests installing ext-uopz (*) phpunit/phpunit-mock-objects suggests installing ext-soap (*) phpunit/php-code-coverage suggests installing ext-xdebug (>=2.2.1) phpunit/phpunit suggests installing phpunit/php-invoker (~1.1) Writing lock file Generating autoload files > Illuminate\Foundation\ComposerScripts::postUpdate > php artisan optimize Generating optimized class loader > php artisan key:generate Application key [base64:KppNg8Dhn77NCzLUn9d7wMK3O2wuH6W519BBoCHK580=] set successfully.看起來可以了
打開網頁直接顯示500...看來有什麼出錯了
追蹤一下log
pi@raspberrypi:/var/www/html $ tail -n 50 /var/log/apache2/error.log [Sun Jul 29 03:42:09.769374 2018] [:error] [pid 5963] [client 192.168.1.254:2405] PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/html/weijlab/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /var/www/html/weijlab/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\nStack trace:\n#0 /var/www/html/weijlab/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\\Handler\\StreamHandler->write(Array)\n#1 /var/www/html/weijlab/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\\Handler\\AbstractProcessingHandler->handle(Array)\n#2 /var/www/html/weijlab/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\\Logger->addRecord(400, Object(UnexpectedValueException), Array)\n#3 /var/www/html/weijlab/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\\Logger->error(Object(UnexpectedValueException), Array)\n#4 /var/www/html/weijlab/vendor/laravel/framework/src/Illuminate/Log/Writer.php(113): Illuminate\\Log\\Writer->writeLog('error', Object(UnexpectedValueEx in /var/www/html/weijlab/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107, referer: https://weijweb.com/weijlab/ [Sun Jul 29 03:42:09.779579 2018] [:error] [pid 5963] [client 192.168.1.254:2405] PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/html/weijlab/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /var/www/html/weijlab/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\nStack trace:\n#0 /var/www/html/weijlab/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\\Handler\\StreamHandler->write(Array)\n#1 /var/www/html/weijlab/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\\Handler\\AbstractProcessingHandler->handle(Array)\n#2 /var/www/html/weijlab/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\\Logger->addRecord(400, Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#3 /var/www/html/weijlab/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\\Logger->error(Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#4 /var/www/html/weijlab/vendor/laravel/framework/src/Illuminate/Log/Writer.php(113): Illumin in /var/www/html/weijlab/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107, referer: https://weijweb.com/weijlab/看起來是laravel logs目錄權限問題
動手修改下
因為剛剛用了sudo安裝,也順便把整個資料夾權限交給pi使用者
pi@raspberrypi:/var/www/html $ sudo chmod -R 777 /var/www/html/weijlab/storage/logs pi@raspberrypi:/var/www/html $ sudo chown -R pi ./weijlab 追蹤一下還有沒有其他錯誤 pi@raspberrypi:/var/www/html $ tail -n 50 /var/log/apache2/error.log直接開網頁檢查吧
看起來log沒東西出現了,網頁也運作得很好
就先到這吧,開始考慮用slim了 XDDD
留言
張貼留言