????????? nginx+phpfpm+eaccelerator+memcache ?? FreeBSD

????? ?????? FreeBSD 10.2

??????? ??????? ?????

1
 portsnap fetch update

????????????? ?????????? ?????? nginx ?? ??????:

1
 cd /usr/ports/www/nginx
1
 make install clean

????????? ? ????????????:

1
 echo 'nginx_enable=YES' >> /etc/rc.conf

WWW-??????????: /usr/local/www/nginx/
???? ????????????: /usr/local/etc/nginx/nginx.conf
???? ??????: /var/log/nginx-error.log
???? ???????: /var/log/nginx-access.log

?????? PHP-FPM (??????? ? php 5.3 ????? ?? ????? php-fpm ?????????????)

1
2
cd /usr/ports/lang/php56
make install clean

?????? ??????????

1
2
3
<blockquote>cd /usr/ports/lang/php56-extensions
 
make all install clean

????????? PHP-FPM ? ????????????

1
echo 'php_fpm_enable=YES' >> /etc/rc.conf

??????????? PHP ? NGINX

? ????? ?????? ?????? ?? ?????????, ? ?????? ????:

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
user www;
worker_processes 1;
 
pid /var/run/nginx.pid;
error_log /var/log/nginx-error.log;
 
events {
worker_connections 1024;
use kqueue;
}
 
http {
include mime.types;
default_type application/octet-stream;
 
# log options
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';
 
# nginx options
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
server_tokens off;
 
# fastcgi
fastcgi_intercept_errors on;
 
# virtual server
server {
listen 80;
server_name localhost;
 
access_log /var/log/nginx-access.log;
 
 
# server root directory
location / {
root /usr/local/www/nginx;
index index.php index.html index.htm;
}
 
# php
location ~ \.php$ {
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;
}
 
}
}

????? ??????????? ???????????? php-fpm

??-??????? ?? ????? ??? ‘/usr/local/etc/php-fpm.conf’.
??????? ? ????? ??????:

1
2
3
4
5
<blockquote>; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www
group = www

????????? ???????????? ? ?????? ??? ??????? ????? ??????????, ?????? ???? www.

?????? memcache

1
2
cd /usr/ports/databases/pecl-memcache
make install clean

eacceleretor

1
2
cd /usr/ports/www/eaccelerator
make install clean

??????? ? /usr/local/etc/php/extensions.ini, ? ????????? ?????? ???????????? ???? ???????:

1
2
extension=memcache.so
extension=eaccelerator.so

??????? ????? ??? ???? eAccelerator, ?????? ????? ? ????????? ??????????.

1
2
3
mkdir /tmp/eaccelerator
chown www /tmp/eaccelerator
chmod 0700 /tmp/eaccelerator

????????:

1
2
/usr/local/etc/rc.d/php-fpm start
/usr/local/etc/rc.d/nginx start

????????? php, ??????? php info:

1
nano usr/local/www/nginx/info.php

??? ??? ???????:

1
2
3
<?php
phpinfo();
?>

????????? http://???_???????/info.php
? ?????? ???????? ? ????? ? php, ??????? ? etc.
????? ?????? MariaDB (???-?? ????? MySQL)
? ????????????? ? ??????????? ???????? ?? ?????, ?????? ??????:

1
pkg install databases/mariadb55-server

????????????

1
echo 'mysql_enable=YES' >> /etc/rc.conf // ??-??, ?????? mysql_enable

???????? ???? ???????????? ??? ??????? ???????:

1
cp /usr/local/share/mysql/my-medium.cnf /usr/local/etc/my.cnf

????????:

1
service mysql-server start

????????? ?????? ??? root-a

1
mysqladmin -u root passwordPASSWORD

?????????:

1
mysql -u root -p

??????? ??:

1
CREATE DATABASE blog;

??????.

p.s. ??? ??? ????? ???????? ??????? ???? ???????????? unix-?????, ???? ??? ?????? ?? ????? ???????.
? nginx ???? ??????? ???:

1
fastcgi_pass unix:/tmp/php-fpm.sock;

? php-fpm:

1
listen = /tmp/php-fpm.sock

? ????????????????? ??????:

1
2
3
listen.owner = www
listen.group = www
listen.mode = 0660

????? ????????? 502 Bad Gateway

p.s. ??? MariaDB ?????????? ??????? ?????????? ????????????, ?????? ??? root’?? ?? ?????????.

0 Comments

Leave a Reply