Report abuse

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
#!/bin/bash

# web server stack (script by angel333)
# ( http://ondrejsimek.com/2009/08/nginx-php-php-fpm-apc-memcached-stack/ )
#
# contains
# - nginx
# - php
#   - apc
#   - php-fpm
#   - memcache extension
# - memcached

PREFIX=`pwd`

mkdir sources
cd sources

# download all sources
echo 'downloading nginx..'
wget -c http://sysoev.ru/nginx/nginx-0.8.9.tar.gz -q
echo 'downloading php..'
wget -c http://php.net/get/php-5.3.0.tar.gz/from/us.php.net -q
echo 'downloading php-fpm..'
wget -c http://php-fpm.org/downloads/php-5.3.0-fpm-0.5.12.diff.gz -q
echo 'downloading apc..'
wget -c http://pecl.php.net/get/APC-3.1.3p1.tgz -q
echo 'downloading memcache php extension'
wget -c http://pecl.php.net/get/memcache-2.2.5.tgz
echo 'downloading memcached..'
wget -c http://memcached.googlecode.com/files/memcached-1.4.0.tar.gz -q

# .. extract..
echo 'extracting all sources..'
tar xzf nginx-0.8.9.tar.gz
tar xzf php-5.3.0.tar.gz
tar xzf APC-3.1.3p1.tgz
tar xzf memcache-2.2.5.tgz
tar xzf memcached-1.4.0.tar.gz

# php
echo 'applying php-fpm patch..'
gzip -cd php-5.3.0-fpm-0.5.12.diff.gz | patch -d php-5.3.0 -p1 > /dev/null
cd php-5.3.0
echo 'configuring php..'
./configure \
	--prefix=$PREFIX \
	--enable-mbstring \
	--enable-fpm \
	--without-sqlite \
	--without-sqlite3 \
	--without-pdo-sqlite \
	--with-mysql=shared \
	--with-mysqli=shared \
	--with-gd=shared \
	--with-mhash \
	> /dev/null
echo 'compiling php..'
make > /dev/null
echo 'installing php..'
make install > /dev/null
echo 'extension=mysql.so' >> ../../lib/php.ini
echo 'extension=mysqli.so' >> ../../lib/php.ini
echo 'extension=gd.so' >> ../../lib/php.ini
cd ..

# apc
cd APC-3.1.3p1
echo 'phpizing apc..'
../../bin/phpize
echo 'configuring apc..'
./configure \
	--with-php-config=../../bin/php-config \
	--enable-apc \
	> /dev/null
echo 'compiling apc..'
make > /dev/null
echo 'installing apc..'
make install > /dev/null
echo 'extension=apc.so' >> ../../lib/php.ini
cd ..

# memcache php extension
cd memcache-2.2.5
echo 'phpizing memcache pecl extension..'
../../bin/phpize
echo 'configuring memcache pecl extension..'
./configure \
	--with-php-config=../../bin/php-config \
	--enable-memcache \
	> /dev/null
echo 'compiling memcache pecl extension..'
make > /dev/null
echo 'installing memcache pecl extension..'
make install > /dev/null
echo 'extension=memcache.so' >> ../../lib/php.ini
cd ..

# nginx
cd nginx-0.8.9
echo 'configuring nginx..'
./configure \
	--prefix=$PREFIX \
	--conf-path=$PREFIX/etc/nginx/nginx.conf \
	--http-client-body-temp-path=$PREFIX/tmp/nginx/client_body_temp \
	--http-proxy-temp-path=$PREFIX/tmp/nginx/proxy_temp \
	--http-fastcgi-temp-path=$PREFIX/tmp/nginx/fastcgi_temp \
	--without-http_charset_module \
	--without-http_ssi_module \
	--without-http_userid_module \
	--without-http_autoindex_module \
	--without-http_geo_module \
	--without-http_referer_module \
	--without-http_proxy_module \
	--without-http_memcached_module \
	--without-http_limit_zone_module \
	--without-http_limit_req_module \
	--without-http_empty_gif_module \
	--without-http_browser_module \
	--without-http_upstream_ip_hash_module \
	--without-mail_pop3_module \
	--without-mail_imap_module \
	--without-mail_smtp_module \
	--with-pcre \
	> /dev/null
echo 'compiling nginx..'
make > /dev/null
echo 'installing nginx..'
make install > /dev/null
cd ..

# memcached
cd memcached-1.4.0
echo 'configuring memcached..'
./configure \
	--prefix=$PREFIX \
	> /dev/null
echo 'compiling memcached..'
make > /dev/null
echo 'installing memcached..'
make install > /dev/null
cd ..



cd ..

echo 'tidying up..'
rm -rf sources
rm -rf man
rm -rf share/man
rm html/*

echo 'modifying nginx configuration'
cd etc/nginx
rm koi-win win-utf koi-utf *.default
sed '/FastCGI server/,/}/ { /location/,/}/ s/#// }' < nginx.conf > out1
sed 's/\(listen *\)80;/\18080;/' < out1 > out2
sed 's/\(index\.html index\.htm\)/\1 index.php/' < out2 > out3
sed 's/\/scripts/\$document_root/' < out3 > out4
mv out4 nginx.conf
rm out*
cd ../..
mkdir tmp
mkdir tmp/nginx

# default index file
echo 'creating default index file..'
echo '<?phpinfo();' > html/index.php

echo 'done!'