PGメモ

非エンジニアの記録

PHP5.4.23をCentOS5.9にインストール

まっさらなところからインストールします
CentOS5.9

# yum install httpd httpd-devel mysql-server mysql mysql-devel libxml2 libxml2-devel libmcrypt-devel

過去に囚われないためアンインストール

# yum remove php*

remiを下記から持ってきます
http://rpms.famillecollet.com/

# wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
# rpm -Uvh remi-release-5.rpm
# yum --enablerepo=remi install php php-cli php-common php-devel php-gd php-mbstring php-mysql php-pdo php-mcrypt php-pear
# php -v
PHP 5.4.23 (cli) (built: Dec 11 2013 06:58:03) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

CentOS5.9にReviewBoardをインストール

必要なものを入れます

# yum install mysql-devel httpd-devel python-devel
# easy_install mysql-python
# easy_install Review Board
# easy_install RbTools
# wget http://modwsgi.googlecode.com/files/mod_wsgi-3.3.tar.gz
# tar zxvf mod_wsgi-3.3.tar.gz
# cd mod_wsgi-3.3
# ./configure
# make & make install

httpd.confに追記

LoadModule wsgi_module modules/mod_wsgi.so
# rb-site install /var/www/reviewboard/
<VirtualHost 192.168.xxx.xxx:80>
        ServerName reviewboard.local
        DocumentRoot "/var/www/reviewboard/htdocs"

        # Error handlers
        ErrorDocument 500 /errordocs/500.html
        WSGIPassAuthorization On
        WSGIScriptAlias / "/var/www/reviewboard/htdocs/reviewboard.wsgi"
        <Directory "/var/www/reviewboard/htdocs">
                AllowOverride All
                Options -Indexes +FollowSymLinks
                Allow from all
        </Directory>

        # Prevent the server from processing or allowing the rendering of
        # certain file types.
        <Location "/media/uploaded">
                SetHandler None
                Options None
                AddType text/plain .html .htm .shtml .php .php3 .php4 .php5 .phps .asp                            AddType text/plain .pl .py .fcgi .cgi .phtml .phtm .pht .jsp .sh .rb                 <IfModule mod_php5.c>                        php_flag engine off                </IfModule>        </Location>

        # Alias static media requests to filesystem
        Alias /media "/var/www/reviewboard/htdocs/media"
        Alias /static "/var/www/reviewboard/htdocs/static"
        Alias /errordocs "/var/www/reviewboard/htdocs/errordocs"
        Alias /favicon.ico "/var/www/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>

CentOS5.9にPython2.7を入れる

ReviewBoardを入れたい。
そのためにはPythonのバージョンを2.7にしたい。

# yum install zlib zlib-devel tk-devel tcl-devel sqlite-devel ncurses-devel gdbm-devel readline-devel bzip2-devel db4-devel openssl-devel mod-ssl
# wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2
# tar xvf Python-2.7.5.tar.bz2
# cd Python-2.7.5
# ./configure --with-threads --enable-shared --prefix=/usr/local --enable-ssl

opensslの位置を調べておく

# find / -name openssl
/usr/bin/openssl
/usr/lib/openssl
/usr/include/openssl

sslを読み込むようにするため./Module/Setupを編集
これを

#SSL=/usr/local/ssl
#_ssl _ssl.c \
#        -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
#        -L$(SSL)/lib -lssl -lcrypto

こう

SSL=/usr
_ssl _ssl.c \
        -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
        -L$(SSL)/lib -lssl -lcrypto
# make & make altinstall
# cd /lib/
# ln /usr/local/lib/libpython2.7.so.1.0 libpython2.7.so.1.0
# python2.7 -V
Python 2.7.3

しかし古いPythonが残る。これは事件。

# python -V
Python 2.4

pythonでも2.7が動くように。

# ln -s /usr/local/bin/python2.7 /usr/local/bin/python

ログインしなおすと

# python -V
Python 2.7.3

もし下記のようなエラーが出たら

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site

~/.bashrcにaliasを書けば解決します。

CentOS5.9にPhabricatorをインストール

まずは必要なものを入れます

# yum install httpd httpd-devel
# yum install php53 php53-devel php53-mysql php53-mbstring
# yum install mysql mysql-server

Phabricatorを入れます。Gitから落としてきます

# mkdir /var/www/phabricator
# mv /var/www/phabricator
# git clone git://github.com/facebook/libphutil.git
# git clone git://github.com/facebook/arcanist.git
# git clone git://github.com/facebook/phabricator.git
# mkdir -p phabricator/conf/custom
# cd phabricator/conf/custom
# vim myconfig.conf.php
<?php
return array(
    'phabricator.base-uri' => 'http://phabricator.example.com',
    'mysql.host' => 'localhost',
    'mysql.user' => 'phabricator',
    'mysql.pass' => 'pass',
    'metamta.default-address' => 'phabricator@example.com',
    'metamta.domain'          => 'example.com',
    'metamta.mail-adapter' => 'PhabricatorMailImplementationPHPMailerLiteAdapter'
) + phabricator_read_config_file('production');
?>
# vi ~/.bashrc
export PHABRICATOR_ENV=custom/myconfig
# . ~/.bashrc
# cd /opt/phabricator/phabricator
# ./bin/storage upgrade

php.iniの設定

date.timezone = Asia/Tokyo

httpd.confの設定を変更します

<VirtualHost 192.168.xxx.xxx:80>
    ServerAdmin admin
    DocumentRoot /var/www/phabricator/phabricator/webroot
    ServerName phabricator.local
    ErrorLog /etc/httpd/logs/phab.error.log
    CustomLog /etc/httpd/logs/phab.access_log common
    RewriteEngine on
    RewriteRule ^/rsrc/(.*)     -                       [L,QSA]
    RewriteRule ^/favicon.ico   -                       [L,QSA]
    RewriteRule ^(.*)$          /index.php?__path__=$1  [L,QSA]
    SetEnv PHABRICATOR_ENV custom/myconfig
    <Directory "/var/www/phabricator/phabricator/webroot">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    </Directory>
</VirtualHost>

アクセスする環境(windowsならhosts)に追記して
http://phabricator.localにアクセスできたらOK

CentOS5.9にApache2.4.6を入れる

古いバージョンが入っていたら迷わず削除

# yum remove httpd

まずはソースをダウンロード

# wget http://ftp.meisei-u.ac.jp/mirror/apache/dist//httpd/httpd-2.4.6.tar.gz

解凍

# tar -vzxf httpd-2.4.6.tar.g

configureをかます

# cd httpd-2.4.6
# ./configure

APRがない。

checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... no
configure: error: APR not found.  Please read the documentation.

ダウンロード&解凍

# wget http://ftp.kddilabs.jp/infosystems/apache//apr/apr-1.5.0.tar.gz
# wget http://ftp.kddilabs.jp/infosystems/apache//apr/apr-util-1.5.3.tar.gz
# tar -vzxf apr-1.5.0.tar.gz 
# tar -vzxf apr-util-1.5.3.tar.gz 
# cd apr-1.5.0
# ./configure
# make & make install
# cd apr-util-1.5.3
# ./configure --with-apr=/usr/local/apr
# make & make install

再度挑戦

# cd <PATH_TO_HTTPD_FILE>
# ./configure

むむ・・

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

入れます。

# yum -y install pcre-devel
# ./configure
# make & make install

無事入りました。

そして設定ファイルはここにあるので気をつけなはれや

/usr/local/apache2/conf/httpd.conf

Apache 2.2.7以下でBと同じものを使う

mod_rewriteの[B]。本家曰く

The [B] flag instructs RewriteRule to escape non-alphanumeric characters before applying the transformation.

mod_rewrite has to unescape URLs before mapping them, so backreferences will be unescaped at the time they are applied. Using the B flag, non-alphanumeric characters in backreferences will be escaped. For example, consider the rule:

エスケープしてくれるようですが、2.2.7以下では使えません。
別途関数を書く必要があるようです

http://snak.tdiary.net/20080118.html#p02