LoginSignup
1
1

More than 5 years have passed since last update.

Mecabインストールメモ (Ubuntu + Apache + PHP)

Posted at

環境

Host OS: macOS High Sierra 10.13.6
Virtual Machine: VirtualBox 5.2.26 r128414
Guest OS: Ubuntu 18.04.1.0 LTS amd64
PHP: PHP 7.2

Mecabのインストール方法

VM, Apache, PHPの用意

今回は、VM, Apache, PHP設定の詳細は省きます。
気が向いたら追記したいと思います。
とりあえず、導入したパッケージは記載しておきます。

sudo apt install apache2 -y
sudo apt install php7.2 -y
sudo apt install php7.2-dev -y
sudo apt install php-mbstring -y

mecab本体の用意

sudo apt install mecab -y         
sudo apt install mecab-ipadic -y
sudo apt install libmecab-dev -y 

php-mecabの用意

(展開場所はお好きに)

sudo mkdir -p /opt/php-mecab
sudo git clone https://github.com/rsky/php-mecab.git
phpize
sudo ./configure
make
make install

mecab.iniを作成

/etc/php/7.2/mods-available/mecab.ini
extension=mecab.so
  • phpコマンド単体でMecabが使えるようにさっきのファイルにシンボリックリンクを貼る
ln -s /etc/php/7.2/mods-available/mecab.ini /etc/php/7.2/cli/conf.d/20-mecab.ini
  • apache2で利用できるようにする
ln -s /etc/php/7.2/mods-available/mecab.ini /etc/php/7.2/apache2/conf.d/20-mecab.ini
sudo service apache2 restart
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1