安装和配置
采用composer进行安装,用composer --version
命令判断composer
是否安装成功(如没有自行百度安装,我已安装好,步骤不记得),如下面就是安装好了
lijiwei@lijiweideMacBook-Air ~ % composer --version
Composer version 1.10.9 2020-07-16 12:57:00
安装好composer
后,进入到存放项目的根目录,我的是mac
,然后服务器用的是nginx
,所以我的根目录在/usr/local/var/www
下面,进入后执行composer create-project --prefer-dist laravel/laravel laravel
命令即可进行下载
lijiwei@lijiweideMacBook-Air www % composer create-project --prefer-dist laravel/laravel laravel
Creating a "laravel/laravel" project at "./laravel"
Warning from https://mirrors.aliyun.com/composer: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
Installing laravel/laravel (v8.5.13)
- Installing laravel/laravel (v8.5.13): Downloading (100%)
Created project in /usr/local/var/www/laravel
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Warning from https://mirrors.aliyun.com/composer: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
Updating dependencies (including require-dev)
Package operations: 105 installs, 0 updates, 0 removals
- Installing voku/portable-ascii (1.5.6): Downloading (100%)
- Installing symfony/polyfill-php80 (v1.22.1): Loading from cache
- Installing symfony/polyfill-mbstring (v1.22.1): Loading from cache
- Installing symfony/polyfill-ctype (v1.22.1): Loading from cache
- Installing phpoption/phpoption (1.7.5): Loading from cache
- Installing graham-campbell/result-type (v1.0.1): Loading from cache
- Installing vlucas/phpdotenv (v5.3.0): Downloading (100%)
- Installing symfony/css-selector (v5.2.4): Downloading (100%)
- Installing tijsverkoyen/css-to-inline-styles (2.2.3): Loading from cache
- Installing symfony/var-dumper (v5.2.5): Downloading (100%)
...
...
...
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/sail
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
74 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan key:generate --ansi
Application key set successfully.
由上面代码可见,Laravel
已经装好了,但是上面还有些警告
警告的原因经查是
composer版本过低
,我们可以用composer self-update
命令解决一下,如果中途还报红,那就多试几次。下载好后,我们可以用
PhpStrom
打开项目之后为了写代码更爽一点,就在
Phpstrom的设置
里,添加 Laravel 插件
,然后重启一下就好了.再然后,我们可以在项目中执行 php artisan serve
命令,然后会自动给我们出现一个访问项目的域名http://127.0.0.1:8000
lijiwei@lijiweideMacBook-Air laravel % php artisan serve
Starting Laravel development server: http://127.0.0.1:8000
[Fri Mar 12 00:14:18 2021] PHP 7.4.6 Development Server (http://127.0.0.1:8000) started
在浏览器中就可以用域名来访问了