-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathchapter.www.nginx.xml
301 lines (263 loc) · 7.09 KB
/
chapter.www.nginx.xml
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<?xml version="1.0" encoding="UTF-8"?>
<chapter id="nginx">
<title>nginx</title>
<screen>
pkg_add -r nginx
location / {
root /usr/local/www/nginx;
index index.html index.htm;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/www/nginx$fastcgi_script_name;
include fastcgi_params;
}
</screen>
<section>
<title>port install</title>
<screen>
# cd /usr/ports/www/nginx
# make install
HTTP_MODULE
HTTP_REWRITE_MODULE
HTTP_STATUS_MODULE
</screen>
<section>
<title>php</title>
<para>ports 安装 php-fpm 适合 php-5.2.10, 高于这个版本请跳过这节, 采用编译安装。</para>
<screen>
# cd /usr/ports/lang/php5
# make install
</screen>
<para>extensions</para>
<screen>
# cd /usr/ports/lang/php5-extensions/
# make install
# ln -s /usr/local/etc/php.ini-production /usr/local/etc/php.ini
</screen>
<para>php-fpm - FastCGI Process Manager</para>
<para>homepage: http://php-fpm.org/downloads/freebsd-port/</para>
<screen>
<![CDATA[
# tar xvzf php-5.2.10-fpm-0.5.13.tar.gz --directory=/usr/ports/lang
x php5-fpm/
x php5-fpm/files/
x php5-fpm/Makefile
x php5-fpm/distinfo
x php5-fpm/pkg-descr
x php5-fpm/pkg-plist
x php5-fpm/files/php-fpm.sh.in
x php5-fpm/files/patch-scripts::phpize.in
x php5-fpm/files/patch-TSRM_threads.m4
x php5-fpm/files/patch-Zend::zend.h
x php5-fpm/files/patch-Zend_zend_list.c
x php5-fpm/files/patch-Zend_zend_list.h
x php5-fpm/files/patch-ext_standard_array.c
x php5-fpm/files/patch-ext_standard_basic_functions.c
x php5-fpm/files/patch-ext_standard_dns.h
x php5-fpm/files/patch-ext_standard_image.c
x php5-fpm/files/patch-php.ini-dist
x php5-fpm/files/patch-php.ini-recommended
x php5-fpm/files/patch-main::php_config.h.in
x php5-fpm/files/patch-main_SAPI.c
x php5-fpm/files/patch-acinclude.m4
x php5-fpm/files/patch-configure.in
# cd /usr/ports/lang/php5-fpm/ && make install
]]>
</screen>
<section>
<title>php-fpm</title>
<screen>
<![CDATA[
Unix user of processes
<value name="user">www</value>
Unix group of processes
<value name="group">www</value>
]]>
</screen>
</section>
</section>
<section>
<title>/etc/rc.conf</title>
<screen>
vim /etc/rc.conf
php_fpm_enable="YES"
nginx_enable="YES"
</screen>
</section>
<section>
<title>/usr/local/etc/nginx/nginx.conf</title>
<screen>
ee /usr/local/etc/nginx/nginx.conf
location / {
root /www;
index index.html index.htm index.php;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www$fastcgi_script_name;
include fastcgi_params;
}
</screen>
</section>
<section>
<title>start</title>
<screen>
/usr/local/etc/rc.d/php-fpm start
/usr/local/etc/rc.d/nginx start
</screen>
</section>
</section>
<section id="php-fpm">
<title>编译安装 php 与 php-fpm</title>
<para><tip>PHP 5.3.3 后续版本已经集成php-fpm 不需要打补丁再安装.</tip></para>
<section>
<title>php-5.2.x</title>
<para>http://php-fpm.org/downloads/</para>
<screen>
<![CDATA[
[root@freebsd1:~] cd /usr/src/
[root@freebsd1:/usr/src]
wget http://php-fpm.org/downloads/php-5.2.14-fpm-0.5.14.diff.gz
wget http://www.php.net/get/php-5.2.14.tar.gz/from/cn.php.net/mirror
[root@freebsd1:/usr/src] tar zxf php-5.2.14.tar.gz
gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1
[root@freebsd1:/usr/src] cd php-5.2.14
./configure --prefix=/usr/local/php-5.2.14 \
--with-config-file-path=/usr/local/php-5.2.14/etc \
--enable-fastcgi --enable-fpm \
--with-curl \
--with-gd \
--with-jpeg-dir=/usr/lib64 \
--with-iconv \
--with-mcrypt \
--with-zlib \
--with-pear \
--with-xmlrpc \
--with-openssl \
--with-mysql \
--with-mysqli \
--with-pdo-mysql \
--enable-zip \
--enable-sockets \
--enable-soap \
--enable-mbstring \
--enable-magic-quotes \
--enable-inline-optimization \
--enable-xml \
--enable-ftp
make && make install
]]>
</screen>
<para>配置php.ini与php-fpm.conf</para>
<screen>
<![CDATA[
cp php.ini-dist /usr/local/php-5.2.14/etc/php.ini
/usr/local/php-5.2.14/etc/php.ini
include_path = ".:/www/includes:/usr/local/php-5.2.14/lib/php"
vim /usr/local/php-5.2.14/etc/php-fpm.conf
<value name="owner">www</value>
<value name="group">www</value>
<value name="user">www</value>
<value name="group">www</value>
/usr/local/php-5.2.14/sbin/php-fpm start
]]>
</screen>
</section>
<section>
<title>php-5.3.x</title>
<screen>
安装zlib
===========================================================
./configure
make test
make install
安装gd
===========================================================
cd /usr/ports/graphic/gd
make install
安装libpng
===========================================================
cd /usr/ports/graphics/png
make install
===========================================================
安装jpeg
===========================================================
cd /usr/ports/graphics/jpeg
make install
===========================================================
安装freetype
===========================================================
cd /usr/ports/print/freetype
make install
</screen>
<screen>
./configure --prefix=/usr/local/php-5.3.5 \
--with-config-file-path=/usr/local/php-5.3.5/etc \
--with-config-file-scan-dir=/usr/local/php-5.3.5/etc/conf.d \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-pear \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-zlib \
--with-xmlrpc \
--with-xsl \
--with-openssl \
--with-mysql \
--with-mysqli \
--with-pdo-mysql \
--disable-debug \
--enable-zip \
--enable-sockets \
--enable-soap \
--enable-mbstring \
--enable-magic-quotes \
--enable-inline-optimization \
--enable-memory-limit
--enable-xml \
--enable-ftp \
--enable-exif \
--enable-wddx \
--enable-bcmath \
--enable-calendar \
--enable-sqlite-utf8 \
--enable-shmop \
--enable-dba \
--enable-sysvsem \
--enable-sysvshm \
--enable-sysvmsg
make
make install
</screen>
<para>php.ini</para>
<screen>
include_path=.:/usr/local/php-5.3.5/lib/php
</screen>
<para>php-fpm.conf</para>
<screen>
cp /usr/local/php-5.3.5/etc/php-fpm.conf.default /usr/local/php-5.3.5/etc/php-fpm.conf
cp /usr/src/php-5.3.5/sapi/fpm/init.d.php-fpm /usr/local/etc/rc.d/php-fpm
chmod +x /usr/local/etc/rc.d/php-fpm
vim /usr/local/php-5.3.5/etc/php-fpm.conf
pid = run/php-fpm.pid
user = www
group = www
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
</screen>
</section>
</section>
</chapter>