LinuxでのMovableTypeインストール
概要
Linux環境でのMovableTypeのインストールを記載
PSGIを使用しています。かなりややこしい
まずはCGIでの対応
plenvでバージョンを5.18系に切り替え
plenv install 5.18.1
plenv global 5.18.1
plenv versions
plenv install-cpanm
apacheでプロキシサーバを使用するようにする
vim /etc/httpd/conf.modules.d/00-proxy.conf
----
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
----
mt6のデータをダウンロードして解凍
cgi、psgiに設定
#!/usr/bin/perl -w
を↓に変更
#!/usr/bin/env perl
mtを配置
mv /usr/local/src/MT-6.0rc2 /var/www/cgi-bin/mt
とりあえず実行権限を付与
cd /var/www/cgi-bin/mt
chmod +x *.cgi *.psgi
ドキュメント用のディレクトリを作成して、mtの中のmt-staticを移動
mkdir -p /var/www/vhosts/dev1.example.com/html
mv /var/www/cgi-bin/mt/mt-static /var/www/vhosts/dev1.example.com/html/
apacheにバーチャルホストを定義して、保存
vim /etc/httpd/conf.d/vhost_dev1.example.com.conf
----
<VirtualHost *>
ServerAdmin dev1.example.com
ServerName dev1.example.com
ServerAlias dev1.example.com
DocumentRoot "/var/www/vhosts/dev1.example.com/html"
ErrorLog "logs/dev1.example.com-error.log"
CustomLog "logs/dev1.example.com-access.log" combined
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/vhosts/dev1.example.com/html">
AllowOverride All
Require all granted
</Directory>
<Directory "/var/www/cgi-bin">
AllowOverride None
Require all granted
</Directory>
#ProxyPass /cgi-bin/mt/ http://localhost:8000/cgi-bin/mt/
#ProxyPassReverse /cgi-bin/mt/ http://localhost:8000/cgi-bin/mt/
</VirtualHost>
----
データベースを作成
[root@localhost mt]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.34 MySQL Community Server (GPL) by Remi
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database mt6_db;
Query OK, 1 row affected (0.00 sec)
mysql> quit;
Bye
[root@localhost mt]#
apacheの再起動
権限を変更
chown apache.apache -R /var/www/vhosts/dev1.example.com
chown apache:apache -R /var/www/vhosts/
chown apache:apache -R /var/www/cgi-bin/
PSGI設定として必要なモジュールをインストール
cpanm Cwd
cpanm Plack
cpanm Task::Plack
cpanm XMLRPC::Transport::HTTP::Plack
cpanm Crypt::SSLeay --force
cpanm SOAP::Transport::TCP
cpanm XMLRPC::Transport::HTTP
cpanm CGI::Parse::PSGI
cpanm CGI::PSGI
cpanm Starman
cpanm Cache::Memcached::Fast
cpanm Imager
cpanm DBI
cpanm DBD::mysql
memcached設定
yum install -y memcached
chkconfig memcached on
service memcached start
Supervisor設定
ディレクトリを作成
起動用ファイルを作成
vim /var/www/tools/mt.sh
----
#!/bin/sh
cd /var/www/cgi-bin/mt
exec /root/.plenv/shims/starman --listen :8000 --workers 2 --error-log /var/log/starman/mt.log --pid /var/www/tools/mt.pid ./mt.psgi
----
実行権限を付与
chown apache:apache -R /var/www/tools/
chmod +x /var/www/tools/mt.sh
ログ出力用ディレクトリを作成
mt-config.cgiの変更
CGIPath http://dev1.example.com/cgi-bin/mt/ # ←変更
StaticWebPath http://dev1.example.com/mt-static/ # ←変更
PidFilePath /var/www/tools/mt.pid
ImageDriver Imager # ←追加
MemcachedNamespace dev1.example.com # ←追加
MemcachedDriver Cache::Memcached::Fast # ←追加
MemcachedServers localhost:11211 # ←追加
Supervisorをインストール
yum -y --enablerepo=epel install supervisor
設定ファイル編集
vim /etc/supervisord.conf 最後に追加
----
[program:mt]
user=root
command=/var/www/tools/mt.sh
autostart=true
autorestart=true
stopsignal=QUIT
----
自動起動設定
chkconfig --level 2345 supervisord on
service supervisord start
apacheにバーチャルホストを変更
vim /etc/httpd/conf.d/vhost_dev1.example.com.conf
----
<VirtualHost *>
ServerAdmin dev1.example.com
ServerName dev1.example.com
ServerAlias dev1.example.com
DocumentRoot "/var/www/vhosts/dev1.example.com/html"
ErrorLog "logs/dev1.example.com-error.log"
CustomLog "logs/dev1.example.com-access.log" combined
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/vhosts/dev1.example.com/html">
AllowOverride All
Require all granted
</Directory>
<Directory "/var/www/cgi-bin">
AllowOverride None
Require all granted
</Directory>
ProxyPass /cgi-bin/mt/ http://localhost:8000/cgi-bin/mt/
ProxyPassReverse /cgi-bin/mt/ http://localhost:8000/cgi-bin/mt/
</VirtualHost>
----
apacheの再起動
おまけ
ログファイルの場所
/var/log/starman
/var/log/supervisor
サンプル実行A
cd /var/www/cgi-bin/mt
plackup mt.psgi
サンプル実行B
cd /var/www/cgi-bin/mt
/root/.plenv/shims/starman --listen 8000 --workers 2 --error-log /var/log/starman/mt.log --pid /var/www/tools/mt.pid /var/www/cgi-bin/mt/mt.psgi
停止
最終更新:2013年10月06日 22:47