PHP MongoDB 확장 모듈을 설치하는 방법(mongodb.so 모듈)
MongoDB PHP 확장 모듈 소스 코드 다운로드
git clone https://github.com/mongodb/mongo-php-driver.git
빌드 및 설치
cd mongo-php-driver/
git submodule update --init
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make all
make install
--output--
PATH="$PATH:/sbin" ldconfig -n /usr/local/src/mongo-php-driver/modules
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/src/mongo-php-driver/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing shared extensions: /usr/local/php/lib/php/extensions/debug-zts-20180731/
확장 프로그램 디렉토리 확인
/usr/local/php/bin/php -i
$ /usr/local/php/bin/php -i | grep extension_dir
extension_dir => /usr/lib64/php/modules => /usr/lib64/php/modules
MongoDB 확장 모듈을 활성화
cp /usr/local/src/mongo-php-driver/modules/mongodb.so /usr/lib64/php/modules/.
MongoDB 확장 모듈 확인
/usr/local/php/bin/php -m | grep mongodb
mongodb
웹 서버 재시작
- PHP 설정을 변경한 후에는 웹 서버를 다시 시작하여 변경 사항이 적용되도록 해야 합니다. 아래 명령을 사용하여 웹 서버를 재시작합니다. 웹 서버 종류에 따라 명령이 다를 수 있습니다.
이제 PHP와 MongoDB 확장 모듈이 연동되었으며, PHP 코드에서 MongoDB를 사용할 수 있게 됩니다. MongoDB PHP 확장 모듈을 사용하여 MongoDB 데이터베이스에 연결하고 데이터를 조작할 수 있습니다.
몽고디비
'리눅스' 카테고리의 다른 글
| [draft] 우분투에서 Gradle을 설치하는 방법 (0) | 2025.11.11 |
|---|---|
| [draft] MySQL에서 특정 사용자가 특정 외부 IP 주소에서만 접속할 수 있도록 설정하는 방법 (0) | 2025.11.11 |
| [draft] keepalived, haproxy 설치 및 설정하기 (0) | 2025.11.11 |
| [draft] vscode unins000.exe 액세스 거부 오류 (0) | 2025.11.11 |
| [draft] SSL 인증서와 개인 키를 하나의 파일로 합치는 방법 (0) | 2025.11.11 |