Atiti. Php Laravel 5.1 環境搭建以及 error 排除

Atiti. Php Laravel 5.1 環境搭建以及  error 排除php

 

 

 

1. php_5.6.11_apache2.41html

1.1. HttpdConf增長如下配置,添加php支持1mysql

1.2. 修改apache位置與項目位置以及權限1laravel

1.3. 修改php。Ini。增長mbstring,openssl,mysql,rewriting的支持 extension_dir = "C:\wamp\php_5.6.11_XiaZaiBa\ext"2git

2. 錯誤排除2redis

2.1. laravel 5.1 unexpected T_STRING Illuminate ContractsHttp Kernel lass2sql

2.2. httpd.exe: Syntax error on line 531 of C:/Apache24/conf/httpd.conf: Cannot load c:/php56/php5apache2_4.dll into server: \xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa33數據庫

2.3. started.httpd:Syntax error on line 60 of D:/apache2/conf/httpd.conf:Cannot load D:/apache2/modules/mod_actions.so into server:\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xa3\xbf\xe9\xa1\xa33express

2.4. Fatal error: Call to undefined function Illuminate\Foundation\Bootstrap\mb_internal_encoding4apache

2.5. apache documentroot指向htcdoc以外提示403錯誤的解決方法5

2.6. 開啓框架調試模式7

3. 配置Redis7

3.1.1. rediswindows官方下載|Redis for Windows下載 2.6.13 穩定版 - ...8

3.2. 數據庫配置8

4. --fihi是、9

 

1.  php_5.6.11_apache2.4

1.1. Httpd。Conf增長如下配置,添加php支持

LoadModule php5_module  "c:/wamp/php_5.6.11_XiaZaiBa/php5apache2_4.dll"

AddType application/x-httpd-php .php

 

PHPIniDir "C:\wamp\php_5.6.11_XiaZaiBa"

 

1.2. 修改apache位置與項目位置以及權限

Define SRVROOT "/Apache24"

DocumentRoot  "${SRVROOT}/htdocs/eform/public"

<Directory "${SRVROOT}/htdocs/eform/public">

    AllowOverride all

   Require all granted

</Directory>

還要修改Apache24\conf\extra\httpd-vhosts.conf

<VirtualHost _default_:80>
#DocumentRoot "${SRVROOT}/htdocs"
DocumentRoot "d:/www"
#ServerName www.example.com:80
</VirtualHost>
做者::  ★(attilax)>>>   綽號:老哇的爪子  全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿爾 拉帕努伊  漢字名:艾龍,  EMAIL:1466519819@qq.com

轉載請註明來源: http://www.cnblogs.com/attilax/

 

1.3. 修改php。Ini。增長mbstring,openssl,mysql,rewriting的支持
extension_dir = "C:\wamp\php_5.6.11_XiaZaiBa\ext"

- PHP >= 5.5.9 - OpenSSL PHP 擴展 - PDO PHP 擴展 - Mbstring PHP 擴展 - Tokenizer PHP 擴展

 

2. 錯誤排除

2.1. laravel 5.1 unexpected T_STRING Illuminate ContractsHttp Kernel lass

 

Parse error: syntax error, unexpected T_STRING in C:\wamp\www\eform\public\index.php on line 50

 

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);//This is line 50

the ::class is only supported since PHP 5.5

Also you must have mistakingly installed laravel 5.1+ because that's the only version to require php 5.5+

 

 

Laravel 5.1 requires PHP 5.5.9 

解決。下載  php_5.6.11_XiaZaiBa

裏面須要php5apache2_4.dl,須要apache2.4

 

在運行Apache24/bin目錄下運行httpd.exe -t時,若是出現以下錯誤提示信息:

2.2. httpd.exe: Syntax error on line 531 of C:/Apache24/conf/httpd.conf: Cannot load c:/php56/php5apache2_4.dll into server: \xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3

 

是因爲php5apache2_4.dll動態連接庫文件的版本與當前的php版本或Apache版本不匹配。32位64位。

經過loadpe查看 php5apache2_4.dll信息,是32位的,下載32爲的apathc2.4

 

2.3. started.httpd:Syntax error on line 60 of D:/apache2/conf/httpd.conf:Cannot load D:/apache2/modules/mod_actions.so into server:\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xa3\xbf\xe9\xa1\xa3

errors reported here must be corrected before service can be

緣由:

我也遇到了這個問題,確實是因爲配置ServerRoot不當致使的,仔細看了一下conf文件裏面有一個說明ServerRoot: The top of the directory tree under which the server‘s等等,應該是Apache文件夾只能放在磁盤根目錄下,不能放在文件夾中,否則會形成非目錄錯誤或樓主的問題。

 

Define SRVROOT "/Apache24"
ServerRoot "${SRVROOT}"
將${SRVROOT} 改爲你的apache安裝目錄
好比 個人安裝目錄是 在F盤中 因此改後是這樣的
Define SRVROOT "/Apache24"
ServerRoot "F:/Apache24"

 

2.4. Fatal error: Call to undefined function Illuminate\Foundation\Bootstrap\mb_internal_encoding


10down vote

had the same problem, solution is to enable the mbstring php extension:https://laracasts.com/discuss/channels/general-discussion/call-to-undefined-function

In my case (AMPPS), I had to disable and reenable it + apache restart.

 

 

Configuration File (php.ini) Path

C:\Windows

 

PHPIniDir "D:\wamp\bin\php\php5.4.3"

Configuration File (php.ini) Path

C:\Windows

Loaded Configuration File

C:\wamp\php_5.6.11_XiaZaiBa\php.ini

 

extension_dir = "ext"   cantloasd ,use   ./ext hesh cant ..

extension_dir = "C:\wamp\php_5.6.11_XiaZaiBa\ext"   zash ok le ..

 

 首先用phpinfo測試頁面看一下有沒有裝載mbstring, 

mbstring

Multibyte Support

enabled

Multibyte string engine

libmbfl

HTTP input encoding translation

disabled

libmbfl version

1.3.2

 

 

 

2.5. apache documentroot指向htcdoc以外提示403錯誤的解決方法

 

後來發現,原來又是Apache沒配置 好,是apache的mod_authz_host模塊在起控制做用。
1.若是不啓用vhosts 
只需修改 httpd.conf
默認Directory節以下,注意紅色部分,表示目錄/usr/local/apache/htdocs容許全部 主機訪問

 

1、訪問控制

在Apache2.2版本中,訪問控制是基於客戶端的主機名、IP地址以及客戶端請求中的其餘特徵,使用Order(排序), Allow(容許), Deny(拒絕),Satisfy(知足)指令來實現。

Apache2.4版本中,使用mod_authz_host這個新的模塊,來實現訪問控制,其餘受權檢查也以一樣的方式來完成。舊的訪問控制語句應當被新的受權認證機制所取代,即使Apache已經提供了mod_access_compat這一新模塊來兼容舊語句。

這裏有一些實例,用新方法取代舊語句實現相同的訪問控制

:常見訪問控制指令

複製代碼代碼以下:


Require all granted #容許全部
Require all denied #拒絕全部
Require env env-var [env-var] ... #容許,匹配環境變量中任意一個
Require method http-method [http-method] ... #容許,特定的HTTP方法
Require expr expression #容許,表達式爲true
Require user userid [ userid ] ... #容許,特定用戶
Require group group-name [group-name] ... #容許,特定用戶組
Require valid-user # #容許,有效用戶
Require ip 10 172.20 192.168.2 #容許 特定IP

 

在國外的網站上搜了好長時間終於找到問題了。
還要修改Apache24\conf\extra\httpd-vhosts.conf

<VirtualHost _default_:80>
#DocumentRoot "${SRVROOT}/htdocs"
DocumentRoot "d:/www"
#ServerName www.example.com:80
</VirtualHost>

但願對後來者有幫助

 

2.6. 開啓框架調試模式

Configapp.php

 

    'debug' => true,

//env('APP_DEBUG', false),

3. 配置Redis

前面咱們已經提到Redis能夠用做主數據庫,因此Laravel中Redis的配置信息位於config/database.php 中:

'redis' => [  'cluster' => false,  'default' => [    'host' => '127.0.0.1',    'port' => 6379,    'database' => 0,  ],

],

另外Redis若是是做爲緩存工具,還須要在 config/cache.php 配置 redis 選項:

'redis' => [

    'driver' => 'redis',

    'connection' => 'default',

],

這裏的 connection 對應 config/database 中 redis 的默認主機 default 配置。

完成上述配置以後咱們就能夠在應用代碼中使用Redis進行數據存取了。

3.0.1. rediswindows官方下載|Redis for Windows下載 2.6.13 穩定版 - ...

下載地址   大小: 1.13 MB   更新時間: 2013-06-13

 

 

 redis是一個key-value存儲系統.Memcached相似,它支持存儲的value類型相對更多,包括string(字符串)list(鏈表)set(集合)zset(sorted set --有序集合)...

www.newasp.net/soft/67...  - 百度快照

 

3.1. 數據庫配置

PHP數組,該配置文件提供了各類數據庫可能用到的配置。connections 裏包含了數據庫配置。修改'default' => 'mysql',參數能夠選擇須要使用的數據庫。

1. 'mysql' => [

2.     'driver'    => 'mysql',

3.     'host'      => env('DB_HOST', 'localhost'),

4.     'database'  => env('DB_DATABASE', 'forge'),

5.     'username'  => env('DB_USERNAME', 'forge'),

6.     'password'  => env('DB_PASSWORD', ''),

7.     'charset'   => 'utf8',

8.     'collation' => 'utf8_unicode_ci',

9.     'prefix'    => '',

10.     'strict'    => false,

11. ],

上面是默認的MySQL配置項,'host' => env('DB_HOST', 'localhost'),env()方法就是讀取.env文件中的配置項,它的第二個參數是默認值。固然也能夠經過'password' => 'password',直接配置,可是若是咱們把項目存放到GitHub上時,這麼作顯然是不安全的。能夠經過讀取.env配置文件中的配置,而後把.env配置文件設置爲不提交來解決,這也是經過.env配置文件來配置的一個好處。

打開項目根目錄下的.gitignore文件,能夠看到.env默認是不會被提交的。

 

 

參考

[Laravel 5 教程學習筆記] 6、環境與配置 _ Specs' Blog-就愛PHP.html

 

 

4. --fihi是、

相關文章
相關標籤/搜索