변군이글루

[리눅스] PHP : mecab-ko 설치 및 사전 적용 본문

* 리눅스

[리눅스] PHP : mecab-ko 설치 및 사전 적용

변군 변군이글루 2021. 7. 16. 11:54
728x90
반응형

mecab-ko 설치 및 사전 적용

mecab-ko(mecab) 다운로드 및 설치

최신 버전 : https://bitbucket.org/eunjeon/mecab-ko/downloads/

wget https://bitbucket.org/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz

tar xvfz mecab-0.996-ko-0.9.2.tar.gz

cd mecab-0.996-ko-0.9.2

./configure

make && make install

mecab-ko-dic(한국어 사전) 다운로드 및 설치

최신 버전 : https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/

wget https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.1.1-20180720.tar.gz

tar xvfz mecab-ko-dic-2.1.1-20180720.tar.gz

cd mecab-ko-dic-2.1.1-20180720

./autogen.sh

./configure

make && make install

mecab 정상 작동 확인

mecab -d /usr/local/lib/mecab/dic/mecab-ko-dic{Enter}
변상철블로거{Enter}

{OUTPUT}
변상 NNG,행위,T,변상,*,*,*,*

mecab -d /usr/local/lib/mecab/dic/mecab-ko-dic
변상철블로거
변상	NNG,행위,T,변상,*,*,*,*
철	NNG,*,T,철,*,*,*,*
블로거	NNP,*,F,블로거,*,*,*,*
EOS

php-mecab 다운로드 및 설치

wget https://github.com/rsky/php-mecab/archive/master.zip

unzip master.zip

cd php-mecab-master/mecab/

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config --with-mecab=/usr/local/bin/mecab-config

make

make install
--output--
Installing shared extensions:     /usr/local/php/lib/php/extensions/debug-zts-20180731/

extension 디렉토리 확인

/usr/local/php/bin/php -i | grep extension_dir
extension_dir => /usr/lib64/php/modules => /usr/lib64/php/modules

mecab.so 모듈 복사

cp /usr/local/php/lib/php/extensions/debug-zts-20180731/mecab.so /usr/lib64/php/modules/.

php.ini 편집

echo "extension=mecab.so" >> /usr/local/apache2/conf/php.ini

 

mecab 모듈 확인 및 웹서버 재기동

$ /usr/local/php/bin/php -m | grep mecab
mecab

$ /usr/local/apache2/bin/apachectl restart

 

728x90
반응형
0 Comments
댓글쓰기 폼