laravel初始化与权限配置

准备工作:安装composer

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

创建新项目:项目名“codepub”

composer create-project --prefer-dist laravel/laravel codepub
# 进入新项目目录
cd codepub

目录权限配置
nobody是nginx的运行用户,嫌麻烦可以直接chmod 777 -R .
确保这两个目录有可写权限

[root@i codepub]# chown nobody:nobody storage -R
[root@i codepub]# chown nobody:nobody bootstrap/cache -R

这个时候运行会报错

RuntimeException in Encrypter.php line 43:
The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.

解决办法是(估计是在生成和配置一个密匙之类的,.env文件可以看到变化):

php artisan key:generate