Рабочий конфиг ISPManager 5 в режиме (FastCGI)Nginx + PHP-FPM

Рубрики Linux

Конфигурация для WordPress

Документация: https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/

user-name — имя пользователя в ISPManager
domen-name — заменить на имя домена, например site.ru
ip-server — ip сервера


server {
server_name domen-name www.domen-name;
charset UTF-8;
index index.php index.html;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/domen-name/*.conf;
access_log /var/www/httpd-logs/domen-name.access.log;
error_log /var/www/httpd-logs/domen-name.error.log notice;
set $root_path /var/www/user-name/data/www/domen-name;
root $root_path;
gzip on; # включаем сжатие gzip
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
location ~ /\. {
deny all; # запрет для скрытых файлов
}
location ~* /(?:uploads|files)/.*\.php$ {
deny all; # запрет для загруженных скриптов
}
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off;
log_not_found off;
expires max; # кеширование статики
}
location / {
try_files $uri $uri/ /index.php?$args; # permalinks
}
location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(.*)$;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/www/php-fpm/user-name.sock;
fastcgi_index index.php;

fastcgi_param DOCUMENT_ROOT $root_path;
fastcgi_param SCRIPT_FILENAME $root_path$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $root_path$fastcgi_script_name;

include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
## Disable viewing .htaccess & .htpassword
location ~ /\.ht {
deny all;
}
listen ip-server;
}
server {
server_name domen-name www.domen-name;
ssl_certificate «/var/www/httpd-cert/user-name/domen-name_le2.crtca»;
ssl_certificate_key «/var/www/httpd-cert/user-name/domen-name_le2.key»;
ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
charset UTF-8;
index index.php;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/domen-name/*.conf;
access_log /var/www/httpd-logs/domen-name.access.log;
error_log /var/www/httpd-logs/domen-name.error.log notice;
set $root_path /var/www/user-name/data/www/domen-name;
root $root_path;
gzip on; # включаем сжатие gzip
gzip_disable «msie6»;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
location ~ /\. {
deny all; # запрет для скрытых файлов
}
location ~* /(?:uploads|files)/.*\.php$ {
deny all; # запрет для загруженных скриптов
}
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off;
log_not_found off;
expires max; # кеширование статики
}
location / {
try_files $uri $uri/ /index.php?$args; # permalinks
}
location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(.*)$;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/www/php-fpm/user-name.sock;
fastcgi_index index.php;
fastcgi_param DOCUMENT_ROOT $root_path;
fastcgi_param SCRIPT_FILENAME $root_path$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $root_path$fastcgi_script_name;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
## Disable viewing .htaccess & .htpassword
location ~ /\.ht {
deny all;
}
listen ip-server ssl http2;
}