Wednesday, April 17, 2013

nginx+php5fpm

# Add a www with this block
server {
listen 80;
server_name bedom.com;
rewrite ^(.*)$ $scheme://www.bedom.com$1;
}
# Remove a www with this block instead
server {
listen 80;
server_name www.bedom.com;
rewrite ^(.*)$ $scheme://bedom.com$1;
}
[virtualhost]
listen = /var/run/php5-fpm/virtualhost.socket
listen.backlog = -1
; Unix user/group of processes
user = username
group = www-data
; Choose how the process manager will control the number of child processes.
pm = dynamic
pm.max_children = 75
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_requests = 500
; Pass environment variables
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
; host-specific php ini settings here
; php_admin_value[open_basedir] = /var/www/virtualhost/htdocs:/tmp
view raw fpm-pool.conf hosted with ❤ by GitHub
upstream phpfcgi {
server unix:/var/run/php5-fpm/virtualhost.socket; #for PHP-FPM running on UNIX socket
}
server {
listen 80;
server_name virtualhost;
rewrite ^(.*)$ $scheme://www.virtualhost1;
}
server {
listen 80;
server_name www.virtualhost;
root /var/www/virtualhost/web;
error_log /var/log/nginx/virtualhost.error.log;
access_log /var/log/nginx/virtualhost.access.log;
# strip app.php/ prefix if it is present
rewrite ^/index\.php/?(.*)$ /$1 permanent;
location / {
index index.php;
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /index.php/$1 last;
}
# pass the PHP scripts to FastCGI server from upstream phpfcgi
location ~ ^/(index|index_dev)\.php(/|$) {
fastcgi_pass phpfcgi;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
}
view raw virtualhost hosted with ❤ by GitHub

No comments:

Post a Comment