laravel5.8筆記一:安裝與服務器環境配置

laravel版本:5.8php

環境要求:css

PHP >= 7.1.3html

OpenSSL PHP 擴展nginx

PDO PHP 擴展laravel

Mbstring PHP 擴展git

Tokenizer PHP 擴展github

XML PHP 擴展json

Ctype PHP 擴展服務器

JSON PHP 擴展php7

 

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]
相關文章
相關標籤/搜索