개발노트
목록
[PHP] 문자를 자르는 mb_strimwidth 모듈 설치
yuminstallphp-mbstring
PHP 2024.03.25 164 회 읽음
PHP 24.03.25 164


서버를 직접 운영하면서 PHP 명령어가 실행이 되지 않는 경우가 있습니다.

mb_strimwidth 라는 함수는 문자를 자를 때 시작 점과 문자 길이를 지정할 수 있고 생략 단어를 끝에 추가하면서 언어셋도 지정이 가능한 장점이 있습니다.

오늘 실행해보니 에러 코드가 표시되네요.

에러 메시지는 "Call to undefined function mb_strimwidth()" 같이 표시되지만 에러 표시를 숨겨 놓은 경우라면 화면에 표시되지 않아 오류를 찾기 어려울 수 있습니다.

php-mbstring 패키지가 설치되어 있지 않기에 yum install php-mbstring 명령어를 이용하여 설치 해 줍니다.


#yum install php-mbstring

Last failed login: Mon Mar 25 20:52:21 KST 2024 from 36.64.232.117 on ssh:notty
There were 9197 failed login attempts since the last successful login.
Last login: Sun Mar 24 10:14:25 2024 from 112.149.242.99
[root@gtfun ~]# yum install php-mbstring
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * epel: ftp.kaist.ac.kr
 * extras: mirror.kakao.com
 * remi-php74: cdn.centos.no
 * remi-safe: cdn.centos.no
 * updates: mirror.kakao.com
Resolving Dependencies
--> Running transaction check
---> Package php-mbstring.x86_64 0:7.4.33-10.el7.remi will be installed
--> Processing Dependency: libonig.so.105()(64bit) for package: php-mbstring-7.4.33-10.el7.remi.x86_64
--> Running transaction check
---> Package oniguruma5php.x86_64 0:6.9.9-1.el7.remi will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================================================================
 Package                                     Arch                                 Version                                            Repository                                Size
====================================================================================================================================================================================
Installing:
 php-mbstring                                x86_64                               7.4.33-10.el7.remi                                 remi-php74                               528 k
Installing for dependencies:
 oniguruma5php                               x86_64                               6.9.9-1.el7.remi                                   remi-safe                                209 k
Transaction Summary
====================================================================================================================================================================================
Install  1 Package (+1 Dependent package)
Total download size: 736 k
Installed size: 2.8 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): oniguruma5php-6.9.9-1.el7.remi.x86_64.rpm                                                                                                             | 209 kB  00:00:00     
(2/2): php-mbstring-7.4.33-10.el7.remi.x86_64.rpm                                                                                                            | 528 kB  00:00:00     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                               1.2 MB/s | 736 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : oniguruma5php-6.9.9-1.el7.remi.x86_64                                                                                                                            1/2 
  Installing : php-mbstring-7.4.33-10.el7.remi.x86_64                                                                                                                           2/2 
  Verifying  : php-mbstring-7.4.33-10.el7.remi.x86_64                                                                                                                           1/2 
  Verifying  : oniguruma5php-6.9.9-1.el7.remi.x86_64                                                                                                                            2/2 
Installed:
  php-mbstring.x86_64 0:7.4.33-10.el7.remi                                                                                                                                          
Dependency Installed:
  oniguruma5php.x86_64 0:6.9.9-1.el7.remi                                                                                                                                           
Complete!


설치가 완료되었으면 아파치 설정 테스트를 해주고 재 시작은 하면 됩니다.

# apachectl -t
# apachectl restart


phpinfo를 출력하여 설치된 패키지를 확인할 수 있으며 기존 서버에서 사용하는 정보를 확인하여 추가 패키지를 설치하는 게 좋습니다.

목록