-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfreebsd.php.xml
314 lines (271 loc) · 7.41 KB
/
freebsd.php.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
302
303
304
305
306
307
308
309
310
311
312
313
314
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V5.0//EN"
"/usr/share/xml/docbook/schema/dtd/5.0/docbook.dtd" [
<!ENTITY article.author.xml SYSTEM "../common/article.author.xml">
<!ENTITY book.info.legalnotice.xml SYSTEM "../common/book.info.legalnotice.xml">
<!ENTITY book.info.abstract.xml SYSTEM "../common/book.info.abstract.xml">
]>
<article xml:base="http://netkiller.github.io/journal/"
xmlns="http://docbook.org/ns/docbook" xml:lang="zh-cn">
<articleinfo>
<title>FreeBSD 10 + Nginx 1.4.4 + PHP 5.5.9 + MySQL 5.6.15</title>
<subtitle>How to Install Nginx and PHP-FPM on FreeBSD 10</subtitle>
&article.author.xml;
<pubdate>$Date$</pubdate>
<releaseinfo>$Id$</releaseinfo>
&book.info.legalnotice.xml;
<abstract>
<para>FreeBSD 10.0 的 pkg 无法安装php-fpm 最终采用 posts 编译安装</para>
<para>http://netkiller.github.io/journal/freebsd.php.html</para>
</abstract>
&book.info.abstract.xml;
<keywordset>
<keyword>FreeBSD 10.0</keyword>
<keyword>PHP 5.5.9</keyword>
<keyword>MySQL 5.6.15</keyword>
</keywordset>
</articleinfo>
<section>
<title>PHP 5.5.9</title>
<para>文本格式回复</para>
<screen>
cd /usr/ports/lang/php55
make install clean; rehash
</screen>
<para>开启下面三个 PHP 编译选项</para>
<screen>
<![CDATA[
[X] CLI Build CLI version
[X] CGI Build CGI version
[X] FPM Build FPM version (experimental)
]]>
</screen>
<para>php.ini</para>
<screen>
# cp /usr/local/etc/php.ini-development /usr/local/etc/php.ini
</screen>
<para>FreeBSD启动是自动开启php-fpm服务</para>
<screen>
<![CDATA[
cat >> /etc/rc.conf <<EOF
php_fpm_enable="YES"
EOF
]]>
</screen>
<para>安装PHP扩展</para>
<screen>
cd /usr/ports/lang/php55-extensions
make install clean; rehash
</screen>
<para>FPM启动脚本</para>
<screen>
# /usr/local/etc/rc.d/php-fpm start
</screen>
</section>
<section>
<title>MySQL 5.6.15</title>
<para>安装 mysql server 与 client</para>
<screen>
<![CDATA[
pkg install mysql56-server
pkg install mysql56-client
]]>
</screen>
<para>设置mysql root密码</para>
<screen>
/usr/local/etc/rc.d/mysql-server onestart
/usr/local/bin/mysqladmin -u root password 'newpassword'
</screen>
<para>FreeBSD 启动时开启MySQL服务</para>
<screen>
<![CDATA[
cat >> /etc/rc.conf <<EOF
mysql_enable="YES"
EOF
]]>
</screen>
<para>MySQL 启动脚本</para>
<screen>
# /usr/local/etc/rc.d/mysql-server
</screen>
</section>
<section>
<title>Nginx 1.4.4</title>
<para>所特殊需求,所以采用pkg安装</para>
<screen>
# pkg install nginx
</screen>
<para>如果需要特别编译模块可以使用ports安装</para>
<screen>
cd /usr/ports/www/nginx
make install clean; rehash
</screen>
<para>服务开启</para>
<screen>
<![CDATA[
cat >> /etc/rc.conf <<EOF
nginx_enable="YES"
EOF
]]>
</screen>
<para>Nginx 启动脚本的位置</para>
<screen>
# /usr/local/etc/rc.d/nginx start
</screen>
<example>
<title>Nginx 配置文件</title>
<para>/usr/local/etc/nginx/nginx.conf</para>
<screen>
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
include /usr/local/etc/nginx/conf.d/*.conf;
}
</screen>
<para>/usr/local/etc/nginx/conf.d/host.domain.conf</para>
<screen>
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/local/www/nginx;
index index.html index.php;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
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;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
</screen>
</example>
</section>
<section>
<title>phalcon 框架</title>
<para>使用pkg安装phalcon依赖php-5.4,所以需要使用ports编译安装</para>
<screen>
cd /usr/ports/www/phalcon
make install
</screen>
<para>确认安装成功</para>
<screen>
# php -m | grep phalcon
phalcon
</screen>
<para>配置nginx.conf</para>
<screen>
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /www/phalcon/public;
index index.html index.php;
if ($request_filename !~ (js|css|images|robots/.txt|.*\.html|index/.php) ) {
rewrite ^/(.*)$ /index.php?_url=/$1 last;
break;
}
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
#location ~ /index.php/ {
root /www/phalcon/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/phalcon/public$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
</screen>
</section>
</article>