pythonクローラを入れるサーバの環境構築
|MySQLのインストール
先にもろもろパッケージを。
# yum -y install cmake
# yum -y install gcc
# yum -y install gcc-c++
# yum -y install ncurses-devel
ユーザ追加
# groupadd mysql
# useradd -g mysql mysql
MySQLインストール
# cd /usr/local/src/mysql
# wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.16.tar.gz/from/ftp://ftp.iij.ad.jp/pub/db/mysql/
# cd mysql-5.5.16
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
# cd mysql-5.5.13
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
# make
# make install
cp my-huge.cnf /etc/my.cnf
my-small.cnf :64MB以下のメモリを搭載したPC
my-medium.cnf :128MB以下のメモリを搭載したPC
my-large.cnf :512MB以下のメモリを搭載したPC
my-huge.cnf :1GB〜2GB以下のメモリを搭載したPC
my-innodb-heavy-4G.cnf :4GBのメモリとInnoDBで作成されたデータベースに
よって構築されたPC
初期化
# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --skip-name-resolv --collation-server=utf8_general_ci
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h www38146u.sakura.ne.jp password 'new-password'
Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/local/mysql/scripts/mysqlbug script!
起動
/usr/local/mysql/support-files/mysql.server start
しかしここでエラー
ログを見てみるとこんなかんじ
[ERROR] COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8'
[ERROR] Aborting
/etc/my.cnfの[mysqld]に以下を追加
collation-server = utf8_general_ci
再起動して、今度は成功。
|python2.7のインストール
# wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
# tar jxvf Python-2.7.2.tar.bz2
# cd Python-2.7.2
# ./configure --prefix=/usr/local/python
あとあとクローラを入れて実行する際に
zlibが見つからないと怒られたのでオプションで追加。
# ./configure --prefix=/usr/local/python --with-zlib
# make
# make install
#vi ルートのホームディレクトリ/.bash_profile
alias python='/usr/local/python/bin/python'
を追記。
反映
# source /root/.bashrc
|apacheのインストール
# wget http://ftp.jaist.ac.jp/pub/apache//httpd/httpd-2.2.21.tar.gz
# tar zxvf httpd-2.2.21.tar.gz
# ./configure --prefix=/usr/local/apache2 --enable-ssl=shared --enable-rewrite=shared --enable-proxy=shared --enable-proxy-ajp=shared --enable-so
# make
# make install
# cp /usr/local/src/apache/httpd-2.2.21/build/rpm/httpd.init /etc/init.d/httpd
# vi /etc/init.d/httpd
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
pidfile=${PIDFILE-/usr/local/apache2/logs/${prog}.pid}
httpd=/usr/local/apache2/bin/httpd
CONFFILE=/usr/local/apache2/conf/httpd.conf
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# chkconfig --add httpd
# chkconfig --level 2345 httpd on
とりあえず今日はここまで。
参考
http://d.hatena.ne.jp/morningmist7/20080303/1204528839
http://wiki.minaco.net/index.php?Python%2F%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%2FLinux%2FPython