Dave Perrett

Setup 64bit CentOS (PHP5, MySQL, Memcached, Ketama)

database, linux, php, programming, web

I recently had to set up a few CentOS servers with PHP , MySQL , memcached and ketama, and ended up writing this script to do it. You can grab the whole thing from subversion (you’ll need the php folder as well).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
if [ ! -d src ]; then
    mkdir src
fi;
cd src


if [ ! -f php-5.2.5.tar.gz ]; then
    wget http://jp2.php.net/get/php-5.2.5.tar.gz/from/jp.php.net/mirror
    tar xvzf php-5.2.5.tar.gz
    sudo yum remove httpd
fi;

if [ ! -f memcached-1.2.5.tar.gz ]; then
    wget http://www.danga.com/memcached/dist/memcached-1.2.5.tar.gz
    tar xvzf memcached-1.2.5.tar.gz
fi;

if [ ! -d ketama ]; then
    svn co svn://svn.audioscrobbler.net/misc/ketama
    cd ketama/libketama
    sed -ri "s|PREFIX=/usr/local|PREFIX=/usr|" Makefile
fi;


sudo yum install \
    libxml2 libxml2-devel \
    openssl openssl-devel \
    pcre pcre-devel \
    bzip2 bzip2-devel \
    curl curl-devel \
    db4 db4-devel \
    libjpeg libjpeg-devel \
    libpng libpng-devel \
    freetype freetype-devel \
    gmp gmp-devel \
    libc-client-devel \
    openldap-devel \
    libmcrypt libmcrypt-devel \
    libmhash libmhash-devel \
    mysql-devel \
    ncurses-devel \
    unixODBC-devel \
    postgresql postgresql-devel \
    sqlite sqlite-devel \
    readline readline-devel \
    net-snmp net-snmp-devel \
    libtidy libtidy-devel \
    libxslt libxslt-devel \
    expat-devel \
    httpd-devel \
    libtool-ltdl libtool-ltdl-devel \
    krb5-libs krb5-devel \
    libevent libevent-devel \
    autoconf \
    bison \
    flex


if [ -d /usr/lib64 ]; then
    export LDFLAGS=-L/usr/lib64/mysql

    if [ ! -f /usr/lib/libexpat.so.32bit ]; then
        sudo mv /usr/lib/libexpat.so /usr/lib/libexpat.so.32bit
    fi;
    sudo rm -f /usr/lib/libexpat.so
    sudo ln -s /usr/lib64/libexpat.so /usr/lib/libexpat.so

    if [ ! -f /usr/lib/libdb-4.3.so.32bit ]; then
        sudo mv /usr/lib/libdb-4.3.so /usr/lib/libdb-4.3.so.32bit
    fi;
    sudo rm -f /usr/lib/libdb-4.3.so
    sudo ln -s /usr/lib64/libdb-4.3.so /usr/lib/libdb-4.3.so

    if [ ! -f /usr/lib/libltdl.so.32bit ]; then
        sudo mv /usr/lib/libltdl.so /usr/lib/libltdl.so.32bit
    fi;
    sudo rm -f /usr/lib/libltdl.so
    sudo ln -s /usr/lib64/libltdl.so /usr/lib/libltdl.so

fi;

cd ketama/libketama
make clean
make
sudo make install
cd ../../
curr_dir=`pwd`
echo ${curr_dir}
rm -f php-5.2.5/ext/ketama
ln -s ${curr_dir}/ketama/php_ketama ${curr_dir}/php-5.2.5/ext/ketama
if [ -d /usr/lib64 ]; then
    sudo rm -f /usr/lib64/libketama.so
    sudo ln -s /usr/lib/libketama.so /usr/lib64/
fi;

cd memcached-1.2.5
make clean
./configure
make
sudo make install
cd ../

cd php-5.2.5
make clean
rm -Rf autom4te.cache
./buildconf --force

'./configure'  \
    '--host=i686-redhat-linux-gnu' \
    '--build=i686-redhat-linux-gnu' \
    '--target=i386-redhat-linux' \
    '--prefix=/usr/local/php-5.2.5'  \
    '--bindir=/usr/bin' \
    '--sbindir=/usr/sbin' \
    '--sysconfdir=/etc' \
    '--datadir=/usr/share' \
    '--includedir=/usr/include' \
    '--libdir=/usr/lib' \
    '--libexecdir=/usr/libexec' \
    '--localstatedir=/var' \
    '--sharedstatedir=/usr/com' \
    '--mandir=/usr/share/man' \
    '--infodir=/usr/share/info' \
    '--cache-file=../config.cache' \
    '--with-libdir=lib' \
    '--with-config-file-path=/etc' \
    '--with-config-file-scan-dir=/etc/php.d' \
    '--disable-debug' \
    '--with-pic' \
    '--disable-rpath' \
    '--with-bz2' \
    '--with-curl' \
    '--with-exec-dir=/usr/bin' \
    '--with-freetype-dir=/usr/lib' \
    '--with-png-dir=/usr/lib' \
    '--enable-gd-native-ttf' \
    '--without-gdbm' \
    '--with-gettext' \
    '--with-gmp' \
    '--with-iconv' \
    '--with-jpeg-dir=/usr/lib' \
    '--with-openssl' \
    '--with-libexpat-dir=/usr/lib' \
    '--with-pcre-regex=/usr' \
    '--with-zlib' \
    '--with-layout=GNU' \
    '--enable-exif' \
    '--enable-ftp' \
    '--enable-magic-quotes' \
    '--enable-sockets' \
    '--enable-sysvsem' \
    '--enable-sysvshm' \
    '--enable-sysvmsg' \
    '--enable-track-vars' \
    '--enable-trans-sid' \
    '--enable-yp' \
    '--enable-wddx' \
    '--with-kerberos' \
    '--enable-ucd-snmp-hack' \
    '--with-unixODBC=shared,/usr' \
    '--enable-memory-limit' \
    '--enable-shmop' \
    '--enable-calendar' \
    '--enable-dbx' \
    '--enable-dio' \
    '--without-mime-magic' \
    '--without-sqlite' \
    '--with-libxml-dir=/usr/lib' \
    '--enable-force-cgi-redirect' \
    '--enable-pcntl' \
    '--with-imap=shared' \
    '--with-imap-ssl' \
    '--enable-mbstring=shared' \
    '--enable-mbstr-enc-trans' \
    '--enable-mbregex' \
    '--with-ncurses=shared' \
    '--with-gd=shared' \
    '--enable-bcmath=shared' \
    '--enable-dba=shared' \
    '--with-db4=/usr/lib' \
    '--with-xmlrpc=shared' \
    '--with-ldap=shared' \
    '--with-ldap-sasl' \
    '--with-mysql=shared,/usr/lib/mysql' \
    '--with-mysqli=shared,/usr/bin/mysql_config' \
    '--enable-dom=shared' \
    '--with-dom-xslt=/usr/lib' \
    '--with-pgsql=shared' \
    '--with-snmp=shared,/usr'\
    '--enable-soap=shared' \
    '--with-xsl=shared,/usr' \
    '--enable-xmlreader=shared' \
    '--enable-xmlwriter=shared' \
    '--enable-fastcgi' \
    '--enable-pdo=shared' \
    '--with-pdo-odbc=shared,unixODBC,/usr' \
    '--with-pdo-mysql=shared,/usr' \
    '--with-pdo-pgsql=shared,/usr' \
    '--with-pdo-sqlite=shared,/usr' '--enable-json=shared' \
    '--enable-zip=shared' \
    '--with-readline' \
    '--enable-dbase=shared' \
    '--with-mcrypt=shared,/usr' \
    '--with-mhash=shared,/usr' \
    '--with-tidy=shared,/usr' '--with-apxs2' \
    '--with-ketama'

sudo yum remove php php-dba php-ldap php-mysql php-mysqli php-pdo

make
sudo make install
cd ../
sudo cp ../php/php.conf /etc/httpd/conf.d/
sudo cp ../php/info.php /var/www/html/
sudo cp ../php/php.ini /etc/php.ini
sudo /usr/sbin/httpd -k stop

* PECL path problem - not sure why
sudo sed -ri "s|exec\(\"php-config --prefix\"\)|\"/usr/lib/20060613\"|" /usr/share/pear/PEAR/Builder.php
sudo pecl install --force memcache

sudo /usr/sbin/httpd -k start

cd ../