私人领地

laravel5.8笔记一:安装与服务器环境配置

laravel版本:5.8

环境要求:

PHP >= 7.1.3

OpenSSL PHP 扩展

PDO PHP 扩展

Mbstring PHP 扩展

Tokenizer PHP 扩展

XML PHP 扩展

Ctype PHP 扩展

JSON PHP 扩展

 

composer安装:

通过使用 Composer 安装 Laravel 安装器

composer global require "laravel/installer"

扩展:进入https://packagist.org/,搜索“laravel”,可以查看更多的laravel版本

 

laravel默认的命名安装,可能长时间没反应;因为他的镜像在国外 

 

Github安装:Laravel & Lumen 一键安装包下载

地址:https://www.golaravel.com/download/

Git源码地址:https://github.com/laravel/laravel

 

 

composer安装很慢的解决办法

方法一: 修改 composer 的全局配置文件(推荐方式),然后输入安装命令

composer config -g repo.packagist composer https://packagist.phpcomposer.com    // 配置命令
composer create-project laravel/laravel   // 安装命令

 

 

方法二: 修改当前项目的 composer.json 配置文件:

进入你的项目的根目录(也就是 composer.json 文件所在目录),执行如下命令:

composer config repo.packagist composer https://packagist.phpcomposer.com

 

方式三:手动全局模式

新建composer文件夹,然后创建composer.json  (推荐方式)

composer/composer.json代码(切换国内镜像)

{
    "config": {},
    "repositories": [
        {"type": "composer", "url": "https://packagist.phpcomposer.com"},
        {"packagist": false}
    ]
}

 

命令窗口进入到cd:  xxx/xx/composer 目录下,运行命令

composer create-project laravel/laravel laravel58    // 会在创建一个composer/laravel58文件夹,里面的是laravel文件

 

D:\phpStudy\PHPTutorial\WWW\composer>composer create-project laravel/laravel l58
Installing laravel/laravel (v5.8.0)
  - Installing laravel/laravel (v5.8.0): Loading from cache
Created project in l58
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 74 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-ctype (v1.10.0): Loading from cache
  - Installing phpoption/phpoption (1.5.0): Downloading (100%)
  - Installing vlucas/phpdotenv (v3.3.2): Downloading (100%)
  - Installing symfony/css-selector (v4.2.3): Downloading (100%)
  - Installing tijsverkoyen/css-to-inline-styles (2.2.1): Loading from cache
  - Installing symfony/polyfill-php72 (v1.10.0): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.10.0): Loading from cache
....
Discovered Package: [32mnunomaduro/collision[39m
[32mPackage manifest generated successfully.[39m
> @php artisan key:generate --ansi
[32mApplication key set successfully.[39m

D:\phpStudy\PHPTutorial\WWW\composer>

 

查看laravel版本

D:\phpStudy\PHPTutorial\WWW\composer\l58>php artisan -v
Laravel Framework 5.8.0

 安装完毕

 

 

 服务器环境配置

nginx配置

server {
        listen       80;
        server_name  claravel57.com l58.com;
        root   "D:/phpStudy/PHPTutorial/WWW/composer/l58/public";
        location / {
            index  index.html index.htm index.php;
            #autoindex  on;
            try_files $uri $uri/ /index.php?$query_string;    //  laravel访问/路由失效,要添加此处
        }
        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            #fastcgi_param  PATH_INFO  $fastcgi_path_info;
            #fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
}

nginx文件配置不好,会出现路由无法解析的情况。

 

Apache配置

如果 Laravel 附带的 .htaccess 文件不起作用,尝试下面的方法替代:

Options +FollowSymLinks -Indexes
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

 

posted @ 2019-02-27 10:15  狂奔的蜗牛Snails  阅读(3847)  评论(0编辑  收藏  举报