Contents
  1. 1. Laravel 所需的 PHP Extension
    1. 1.1. 尚未開啟前,顯示以下錯誤訊息:
    2. 1.2. 檢視目前開啟的 PHP Configuration File
      1. 1.2.1. 設定 php.ini
      2. 1.2.2. 開始安裝 php-mbstring
    3. 1.3. 使用 yum search 檢查有哪些版本:
    4. 1.4. 補充:在 Apache、Nginx 上面運行 PHP

Laravel 所需的 PHP Extension

  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension

尚未開啟前,顯示以下錯誤訊息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-> # composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for laravel/framework v5.3.21 -> satisfiable by laravel/framework[v5.3.21].
- laravel/framework v5.3.21 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
Problem 2
- Installation request for phpunit/phpunit 5.6.2 -> satisfiable by phpunit/phpunit[5.6.2].
- phpunit/phpunit 5.6.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
To enable extensions, verify that they are enabled in those .ini files:
- /etc/php.ini
- /etc/php.d/bz2.ini
- /etc/php.d/calendar.ini
- /etc/php.d/ctype.ini
- /etc/php.d/curl.ini
- /etc/php.d/exif.ini
- /etc/php.d/fileinfo.ini
- /etc/php.d/ftp.ini
- /etc/php.d/gettext.ini
- /etc/php.d/gmp.ini
- /etc/php.d/iconv.ini
- /etc/php.d/json.ini
- /etc/php.d/opcache.ini
- /etc/php.d/phar.ini
- /etc/php.d/shmop.ini
- /etc/php.d/simplexml.ini
- /etc/php.d/sockets.ini
- /etc/php.d/tokenizer.ini
- /etc/php.d/xml.ini
- /etc/php.d/zip.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

檢視目前開啟的 PHP Configuration File

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed: /etc/php.d/bz2.ini,
/etc/php.d/calendar.ini,
/etc/php.d/ctype.ini,
/etc/php.d/curl.ini,
/etc/php.d/exif.ini,
/etc/php.d/fileinfo.ini,
/etc/php.d/ftp.ini,
/etc/php.d/gettext.ini,
/etc/php.d/gmp.ini,
/etc/php.d/iconv.ini,
/etc/php.d/json.ini,
/etc/php.d/opcache.ini,
/etc/php.d/phar.ini,
/etc/php.d/shmop.ini,
/etc/php.d/simplexml.ini,
/etc/php.d/sockets.ini,
/etc/php.d/tokenizer.ini,
/etc/php.d/xml.ini,
/etc/php.d/zip.ini

設定 php.ini

Loaded Configuration File: /etc/php.ini

根據 Problem 1 描述,需要安裝 ext-mbstring

可先檢查目前裝了哪些 PHP 的 Modules (檢視後的確沒有 ext-mbstring 這個模組)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
-> # php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
json
libxml
openssl
pcntl
pcre
Phar
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
standard
tokenizer
xml
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache

開始安裝 php-mbstring

1
$ yum install php-mbstring

錯誤訊息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
-> # yum install php-mbstring
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: download.nus.edu.sg
* epel: epel.mirror.angkasa.id
* extras: mirror.0x.sg
* ius: mirrors.ircam.fr
* remi-safe: mirror.innosol.asia
* updates: download.nus.edu.sg
* webtatic: uk.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package php-mbstring.x86_64 0:5.4.16-36.3.el7_2 will be installed
--> Processing Dependency: php-common(x86-64) = 5.4.16-36.3.el7_2 for package: php-mbstring-5.4.16-36.3.el7_2.x86_64
--> Running transaction check
---> Package php-common.x86_64 0:5.4.16-36.3.el7_2 will be installed
--> Processing Conflict: php70w-common-7.0.12-1.w7.x86_64 conflicts php-common < 7.0
--> Finished Dependency Resolution
Error: php70w-common conflicts with php-common-5.4.16-36.3.el7_2.x86_64
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

可能原因:

  • php-common 使用的是 5.4
  • 需要安裝 php-mbstring for php7

使用 yum search 檢查有哪些版本:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
-> # yum search php-mbstring
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: download.nus.edu.sg
* epel: epel.mirror.angkasa.id
* extras: mirror.0x.sg
* ius: syd.mirror.rackspace.com
* remi-safe: mirrors.thzhost.com
* updates: download.nus.edu.sg
* webtatic: uk.repo.webtatic.com
======================================================================================== N/S matched: php-mbstring ========================================================================================
php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
php56-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
php70-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
php71-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
Name and summary matches only, use "search all" for everything.

安裝 php70-php-mbstring.x86_64
-> # yum install php70-php-mbstring.x86_64

不論是重新編譯或者安裝 php-mbstring 套件, 完成後都要重新啟動 HTTPD 伺服器才會生效。

重新啟動
-> # service httpd restart

yum 用法整理:
http://www.vixual.net/blog/archives/101

補充:在 Apache、Nginx 上面運行 PHP

Apache 需要安裝 mod_php 這個 Apache module
Nginx 需要安裝 PHP-FPM 來運行 PHP code

Contents
  1. 1. Laravel 所需的 PHP Extension
    1. 1.1. 尚未開啟前,顯示以下錯誤訊息:
    2. 1.2. 檢視目前開啟的 PHP Configuration File
      1. 1.2.1. 設定 php.ini
      2. 1.2.2. 開始安裝 php-mbstring
    3. 1.3. 使用 yum search 檢查有哪些版本:
    4. 1.4. 補充:在 Apache、Nginx 上面運行 PHP