1. Пересобираем php c флагом fpm.
[ebuild R ] dev-lang/php-5.5.25:5.5::gentoo USE="apache2 bcmath berkdb bzip2 cgi cli crypt ctype curl fileinfo filter fpm ftp gd gdbm hash iconv imap ipv6 json ldap mhash mysql mysqli nls opcache pdo phar posix readline session simplexml soap sockets sqlite ssl threads tokenizer unicode xml xmlreader xmlrpc xmlwriter zip zlib -calendar -cdb -cjk -debug -embed -enchant -exif (-firebird) -flatfile (-frontbase) -gmp -inifile -intl -iodbc -kerberos -ldap-sasl -libedit -libmysqlclient -mssql -oci8-instant-client -odbc -pcntl -postgres -qdbm -recode (-selinux) -sharedmem -snmp -spell (-sybase-ct) -systemd -sysvipc -tidy -truetype -vpx -wddx -xpm -xslt" 0 KiB
2. Устанавливаем nginx.
Code: Select all
emerge -v nginx
Открываем /etc/php/fpm-php5.6/php-fpm.conf ищем и меняем там:
Code: Select all
listen = /var/run/php5-fpm.sock
listen.owner = nginx
listen.group = nginx
user = nginx
group = nginx
4. Настройка конфигов сайтов:
Code: Select all
sinner etc # cat nginx/nginx.conf
user nginx nginx;
worker_processes 2;
error_log /var/log/nginx/error_log info;
events {
worker_connections 1024;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main
'$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';
client_header_timeout 10m;
client_body_timeout 10m;
send_timeout 10m;
client_max_body_size 50m;
limit_req_zone $binary_remote_addr zone=one:10m rate=5r/s;
connection_pool_size 256;
client_header_buffer_size 1k;
large_client_header_buffers 4 2k;
request_pool_size 4k;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;
output_buffers 1 32k;
postpone_output 1460;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 75 20;
ignore_invalid_headers on;
index index.html;
server {
listen 127.0.0.1;
server_name localhost;
access_log /var/log/nginx/localhost.access_log main;
error_log /var/log/nginx/localhost.error_log info;
root /var/www/localhost/htdocs;
}
# SSL example
#server {
# listen 127.0.0.1:443;
# server_name localhost;
# ssl on;
# ssl_certificate /etc/ssl/nginx/nginx.pem;
# ssl_certificate_key /etc/ssl/nginx/nginx.key;
# access_log /var/log/nginx/localhost.ssl_access_log main;
# error_log /var/log/nginx/localhost.ssl_error_log info;
# root /var/www/localhost/htdocs;
#}
include /etc/nginx/conf.d/*.conf;
}
Code: Select all
sinner etc # cat nginx/conf.d/the-sinner.net.conf
# Main site the-sinner.net (forum phpbb3)
#limit_req_zone $binary_remote_addr zone=one:10m rate=5r/s;
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80; ##default ipv6only=on; ## listen for ipv6
#listen *:443;
server_name the-sinner.net www.the-sinner.net;
access_log /var/log/nginx/the-sinner.net_access.log;
#include /etc/nginx/ssl.conf;
#set_real_ip_from 31.220.7.179;
#real_ip_header X-Real-IP;
autoindex on;
location / {
root /var/www/localhost/htdocs/www;
index index.php index.html;
#if (!-e $request_filename) {
# rewrite ^/install-master/(.*)$ /install-master/index.php;
#}
#try_files $uri $uri/ /index.php?$args;
}
#if ($http_x_ssl_protocol != "") {
# set $https_on On;
#}
location ~ \.php$ {
limit_req zone=one burst=20;
root /var/www/localhost/htdocs/www;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
#fastcgi_param HTTPS $https_on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param SERVER_PORT $http_x_port;
}
}
Code: Select all
/etc/init.d/php-fpm start
/etc/init.d/nginx start