1、通过composer安装laravel

# 默认安装(会在当前目录下生成一个名称为laravel的目录)
composer create-project laravel/laravel --prefer-dist

# 指定版本
composer create-project laravel/laravel=5.1.* --prefer-dist

# 安装到当前目录
composer create-project laravel/laravel=5.1.* ./ --prefer-dist

# 指定目录(会在当前目录下生成一个名称为larshop的目录)
composer create-project laravel/laravel=5.4.* larshop --prefer-dist

输出一下内容,就表示已经安装成功

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/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
> @php artisan key:generate --ansi
Application key set successfully.

2、通过安装好的Laravel创建项目

使用 Composer 下载 Laravel 安装包

# 全局安装laravel
composer global require "laravel/installer"

# 会在当前目录下创建一个larshop目录,即:D:\htdocs\larshop
D:\htdocs> laravel new larshop
laravle new -- 将项目创建在当前目录下。

3、安装所需包

D:\htdocs\larshop> composer install

会创建vendor目录,并开始下载安装项目所需的依赖包。

4、生成密钥

使用

php artisan key:generate

生成密钥,如果使用composer create-Project 生成的laravel项目,则不需要执行此步骤,因为composer会自动帮我们完成这一步骤。

D:\Winap\htdocs\api.hdys.com>php artisan key:generate

Module compiled with module API=20121212
PHP    compiled with module API=20131226
These options need to match
 in Unknown on line 0

Application key [base64:C9Gb15t1H1upJOvHLTkcksbQBm8+Lj9679h3Mq6NFTk=] set successfully.

否则会报下面的错误

RuntimeException in EncryptionServiceProvider.php line 45:No supported encrypter found. The cipher and / or key length are invalid.

5、目录权限

如果报下面错误,表示相关目录权限不够

The stream or file "/Users/yourusername/Workspace/htdocs/vijeecn/storage/logs/laravel-2019-04-19.log" could not be opened: failed to open stream: Permission denied

chmod -R 777 storage

chmod -R 777 bootstrap/cache

6、nginx配置

set $rootHtml '/Users/unipcn/Workspace/htdocs/ihms/public';
location / {
    root   $rootHtml;
    index  index.html index.htm index.php;
    try_files $uri $uri/ /index.php?$query_string;
}