Install Nginx, PHP-FPM and Varnish on FreeBSD 8.2
# cd /usr/ports/www/nginx
# make install clean
Note: make sure you select important option such as:
HTTP_REWRITE_MODULE=on
HTTP_SSL_MODULE=on
and others as per your requirements.
# echo '### Nginx' << /etc/rc.conf
# echo 'nginx_enable="YES"' << /etc/rc.conf
# vim /usr/local/etc/nginx/nginx.conf
# /usr/local/etc/rc.d/nginx start
Change this line for nginx:
# vim /usr/local/etc/php.ini
cgi.fix_pathinfo = 0
Install php and php-fpm:
// For PHP5.3
# cd /usr/ports/lang/php5 ; make install
// For PHP5.2
# cd /usr/ports/lang/php52 ; make install
===< The following configuration options are available for php5-5.3.8:
CLI=on "Build CLI version"
CGI=on "Build CGI version"
FPM=on "Build FPM version (experimental)"
APACHE=off "Build Apache module"
AP2FILTER=off " Use Apache 2.x filter interface (experimental)"
DEBUG=off "Enable debug"
SUHOSIN=on "Enable Suhosin protection system"
MULTIBYTE=on "Enable zend multibyte support"
IPV6=off "Enable ipv6 support"
MAILHEAD=on "Enable mail header patch"
LINKTHR=on "Link thread lib (for threaded extensions)"
===< Use 'make config' to modify these settings
// For PHP5.3
# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
// For PHP5.2
# cp /usr/local/etc/php.ini-recommended /usr/local/etc/php.ini
Install PHP Extensions
// For PHP5.3
# cd /usr/ports/lang/php5-extensions ; make install
// For PHP5.2
# cd /usr/ports/lang/php52-extensions ; make install
Edit php-fpm.conf:
# vim /usr/local/etc/php-fpm.conf
; comment out following line and add the line below.
;listen = 127.0.0.1:9000
listen = /tmp/php-fpm.sock
request_terminate_timeout=30s
Edit rc.conf
# vim /etc/rc.conf
### php-fpm
php_fpm_enable="YES"
Change this line for nginx
# vim /usr/local/etc/php.ini
cgi.fix_pathinfo = 0
# /usr/local/etc/rc.d/php-fpm start
# tail /var/log/nginx-error.log
# tail /var/log/php-fpm.log
# tail /var/log/messages
Install Varnish
# cd /usr/ports/www/varnish ; make install clean
Reconfigure your web server to listen on localhost:8080
# echo 'varnishd_enable="YES"' << /etc/rc.conf
# echo 'varnishd_flags="-s malloc,1G -a 127.0.0.1:80 -b 127.0.0.1:8080"' << /etc/rc.conf
# echo 'varnishlog_enable="YES"' << /etc/rc.conf
# /usr/local/etc/rc.d/varnishd start
# /usr/local/etc/rc.d/varnishncsa onestart
# tail /var/log/varnishncsa.log
# /usr/local/bin/varnishtest
# /usr/local/bin/varnishstat
# ls -lh /usr/local/varnish/`hostname`
Install webbench
# cd /usr/ports/benchmarks/webbench ; make install clean
# webbench -c 3000 -t 60 http://test.local/index.php
Refernce To: http://gala4th.blogspot.com/2012/01/install-nginx-php-fpm-and-varnish-on.html
# cd /usr/ports/www/nginx
# make install clean
Note: make sure you select important option such as:
HTTP_REWRITE_MODULE=on
HTTP_SSL_MODULE=on
and others as per your requirements.
# echo '### Nginx' << /etc/rc.conf
# echo 'nginx_enable="YES"' << /etc/rc.conf
# vim /usr/local/etc/nginx/nginx.conf
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
server {
server_name mydomain1.com mydomain2.com mydomain3.com;
root /usr/local/www/nginx/drupal7; ## <-- Your only path reference.
client_max_body_size 20M; # Maximum allowed size for uploaded files
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# This matters if you use drush
location = /backup {
deny all;
}
# Very rarely should these ever be accessed outside of your lan
location ~* \.(txt|log)$ {
allow 192.168.0.0/16;
deny all;
}
location ~ \..*/.*\.php$ {
return 403;
}
location / {
# This is cool because no php is touched for static content
try_files $uri @rewrite;
}
location @rewrite {
# Some modules enforce no slash (/) at the end of the URL
# Else this rewrite block wouldn't be needed (GlobalRedirect)
rewrite ^/(.*)$ /index.php?q=$1;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
### NOTE: You should have "cgi.fix_pathinfo = 0" in php.ini
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
#fastcgi_pass 127.0.0.1:9000; #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
fastcgi_pass unix:/tmp/php-fpm.sock;
}
# Fighting with ImageCache? This little gem is amazing.
location ~ ^/sites/.*/files/imagecache/ {
try_files $uri @rewrite;
}
# Catch image styles for D7 too.
location ~ ^/sites/.*/files/styles/ {
try_files $uri @rewrite;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
# nginx status
location /NginxStatus {
stub_status on;
access_log on;
auth_basic NginxStatus;
auth_basic_user_file conf/htpasswd;
}
}
# /usr/local/etc/rc.d/nginx start
Change this line for nginx:
# vim /usr/local/etc/php.ini
cgi.fix_pathinfo = 0
Install php and php-fpm:
// For PHP5.3
# cd /usr/ports/lang/php5 ; make install
// For PHP5.2
# cd /usr/ports/lang/php52 ; make install
===< The following configuration options are available for php5-5.3.8:
CLI=on "Build CLI version"
CGI=on "Build CGI version"
FPM=on "Build FPM version (experimental)"
APACHE=off "Build Apache module"
AP2FILTER=off " Use Apache 2.x filter interface (experimental)"
DEBUG=off "Enable debug"
SUHOSIN=on "Enable Suhosin protection system"
MULTIBYTE=on "Enable zend multibyte support"
IPV6=off "Enable ipv6 support"
MAILHEAD=on "Enable mail header patch"
LINKTHR=on "Link thread lib (for threaded extensions)"
===< Use 'make config' to modify these settings
// For PHP5.3
# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
// For PHP5.2
# cp /usr/local/etc/php.ini-recommended /usr/local/etc/php.ini
Install PHP Extensions
// For PHP5.3
# cd /usr/ports/lang/php5-extensions ; make install
// For PHP5.2
# cd /usr/ports/lang/php52-extensions ; make install
Edit php-fpm.conf:
# vim /usr/local/etc/php-fpm.conf
; comment out following line and add the line below.
;listen = 127.0.0.1:9000
listen = /tmp/php-fpm.sock
request_terminate_timeout=30s
Edit rc.conf
# vim /etc/rc.conf
### php-fpm
php_fpm_enable="YES"
Change this line for nginx
# vim /usr/local/etc/php.ini
cgi.fix_pathinfo = 0
# /usr/local/etc/rc.d/php-fpm start
# tail /var/log/nginx-error.log
# tail /var/log/php-fpm.log
# tail /var/log/messages
Install Varnish
# cd /usr/ports/www/varnish ; make install clean
Reconfigure your web server to listen on localhost:8080
# echo 'varnishd_enable="YES"' << /etc/rc.conf
# echo 'varnishd_flags="-s malloc,1G -a 127.0.0.1:80 -b 127.0.0.1:8080"' << /etc/rc.conf
# echo 'varnishlog_enable="YES"' << /etc/rc.conf
# /usr/local/etc/rc.d/varnishd start
# /usr/local/etc/rc.d/varnishncsa onestart
# tail /var/log/varnishncsa.log
# /usr/local/bin/varnishtest
# /usr/local/bin/varnishstat
# ls -lh /usr/local/varnish/`hostname`
Install webbench
# cd /usr/ports/benchmarks/webbench ; make install clean
# webbench -c 3000 -t 60 http://test.local/index.php
Refernce To: http://gala4th.blogspot.com/2012/01/install-nginx-php-fpm-and-varnish-on.html
沒有留言:
張貼留言