C jak configure

Kwiecień 18, 2008

eaccelerator – dopalacz php

Filed under: konfiguracja — erendil @ 2:09 pm
Tags: , , ,

Ściągnąć i rozpakować instalkę ze strony http://www.eaccelerator.net

Następnie jako root wydajemy kolejne polecenia:
export PHP_PREFIX="/usr/local"
$PHP_PREFIX/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
make
make test

Nie robimy make install, bo sami sobie skopiujemy co trzeba, tam gdzie trzeba. Jeśli wszystko przebiegnie ok to w ./modules powinien zostać utworzony plik o nazwie eaccelerator.so. Kopiujemy go gdziekolwiek, w moim wypadku ląduje on tu: /www/sbin/eaccelerator.so.

Na co zwrócić uwagę gdy pojawią się problemy? Przede wszystkim zobacz czy automake, autoheader i autoconf są na Twojej ścieżce poszukiwań. Wystarczy z konsoli napisać:

automak ( i nacisnąć Ctrl-D w shellu, jeśli system rozwinie to na automake to jesteś w domu.), jeśli nie…. to kombinuj (podpowiem ;) zmień shella na zsh, tak będzie najprościej. OK, mamy eaccelerator, teraz trzeba go podpiąć do php. Wyedytuj swój php.ini i dopisz w nim następującą sekcję:

zend_extension="/www/sbin/eaccelerator.so"
eaccelerator.shm_size="32"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

Opcje jak widać są ładnie opisane nie ma potrzeby tłumaczyć. Baczną uwagę należy zwrócić na pierwsze trzy:

zend_extension="/www/sbin/eaccelerator.so"
W tym katalogu musi znaleźć się nasz lib z eacceleratorem.

eaccelerator.shm_size="32"
Rozmiar przeznaczonej na cache pamięci(w MB),jak masz sporo RAM’u to zmień np. na 400, jak mało wpisz tam 0 – system sam dobierze stosowną wartość.

eaccelerator.cache_dir="/tmp/eaccelerator"
Nasz cache na dysku, żeby zadziałał musimy zrobić to:
mkdir /tmp/eaccelerator
chmod 0777 /tmp/eaccelerator

Przerestartować demony – koniec.
Jak sprawdzić czy eaccelerator działa? Najłatwiej odpytując funkcję phpinfo() via www.

Kwiecień 17, 2008

opcje konfiguracyjne do serwera www nginx

Filed under: konfiguracja — erendil @ 12:56 pm
Tags: , ,

Opcje konfiguracyjne do nginxa

--prefix=PATH set the installation prefix
--sbin-path=PATH set path to the nginx binary file
--conf-path=PATH set path to the nginx.conf file
--error-log-path=PATH set path to the error log
--pid-path=PATH set path to nginx.pid file
--lock-path=PATH set path to nginx.lock file
--user=USER set non-privilege user for the worker processes
--group=GROUP set non-privilege group for the worker processes
--builddir=DIR set the build directory
--with-rtsig_module enable rtsig module
--with-select_module enable select module
--without-select_module disable select module
--with-poll_module enable poll module
--without-poll_module disable poll module
--with-http_ssl_module enable ngx_http_ssl_module
--with-http_realip_module enable ngx_http_realip_module
--with-http_addition_module enable ngx_http_addition_module
--with-http_sub_module enable ngx_http_sub_module
--with-http_dav_module enable ngx_http_dav_module
--with-http_flv_module enable ngx_http_flv_module
--with-http_stub_status_module enable ngx_http_stub_status_module
--without-http_charset_module disable ngx_http_charset_module
--without-http_gzip_module disable ngx_http_gzip_module
--without-http_ssi_module disable ngx_http_ssi_module
--without-http_userid_module disable ngx_http_userid_module
--without-http_access_module disable ngx_http_access_module
--without-http_auth_basic_module disable ngx_http_auth_basic_module
--without-http_autoindex_module disable ngx_http_autoindex_module
--without-http_geo_module disable ngx_http_geo_module
--without-http_map_module disable ngx_http_map_module
--without-http_referer_module disable ngx_http_referer_module
--without-http_rewrite_module disable ngx_http_rewrite_module
--without-http_proxy_module disable ngx_http_proxy_module
--without-http_fastcgi_module disable ngx_http_fastcgi_module
--without-http_memcached_module disable ngx_http_memcached_module
--without-http_limit_zone_module disable ngx_http_limit_zone_module
--without-http_empty_gif_module disable ngx_http_empty_gif_module
--without-http_browser_module disable ngx_http_browser_module
--without-http_upstream_ip_hash_module disable ngx_http_upstream_ip_hash_module
--with-http_perl_module enable ngx_http_perl_module
--with-perl_modules_path=PATH set path to the perl modules
--with-perl=PATH set path to the perl binary
--http-log-path=PATH set path to the http access log
--http-client-body-temp-path=PATH set path to the http client request body temporary files
--http-proxy-temp-path=PATH set path to the http proxy temporary files
--http-fastcgi-temp-path=PATH set path to the http fastcgi temporary files
--without-http disable HTTP server
--with-mail enable POP3/IMAP4/SMTP proxy module
--with-mail_ssl_module enable ngx_mail_ssl_module
--without-mail_pop3_module disable ngx_mail_pop3_module
--without-mail_imap_module disable ngx_mail_imap_module
--without-mail_smtp_module disable ngx_mail_smtp_module
--add-module=PATH enable an external module
--with-cc=PATH set path to C compiler
--with-cpp=PATH set path to C preprocessor
--with-cc-opt=OPTIONS set additional options for C compiler
--with-ld-opt=OPTIONS set additional options for linker
--with-cpu-opt=CPU build for specified CPU, the valid values: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, sparc32, sparc64, ppc64
--without-pcre disable PCRE libarary usage
--with-pcre=DIR set path to PCRE library sources
--with-pcre-opt=OPTIONS set additional options for PCRE building
--with-md5=DIR set path to md5 library sources
--with-md5-opt=OPTIONS set additional options for md5 building
--with-md5-asm use md5 assembler sources
--with-sha1=DIR set path to sha1 library sources
--with-sha1-opt=OPTIONS set additional options for sha1 building
--with-sha1-asm use sha1 assembler sources
--with-zlib=DIR set path to zlib library sources
--with-zlib-opt=OPTIONS set additional options for zlib building
--with-zlib-asm=CPU use zlib assembler sources optimized for specified CPU, the valid values: pentium, pentiumpro
--with-openssl=DIR set path to OpenSSL library sources
--with-openssl-opt=OPTIONS set additional options for OpenSSL building
--with-debug enable the debugging logging

nginx + php + freebsd

Filed under: konfiguracja — erendil @ 12:38 pm
Tags: , ,

Nginx:
kompilujemy z następującymi opcjami, jeśli chcemy coś dodać to warto poczytać o opcjach konfiguracyjnych do nginx’a
./configure --prefix=/www --user=www --group=www --with-cc-opt="-I /usr/local/include/pcre"

Można zwiększyć liczbę deskryptorów do pliku dodając opcję:
--with-cc-opt="-D FD_SETSIZE=2048"

PHP 5.2.5
dokompilowujemy obsługę mysql itp. dodatki + fcgi(bez tego ani rusz)
./configure --with-mysql=/usr/local/mysql --with-gd --with-jpeg-dir=/usr/local/include --with-png-dir=/usr/local/include --with-zlib-dir=/usr/lib --with-freetype-dir=/usr/local/include --with-pear --enable-ftp --enable-soap --enable-exif --enable-cgi --enable-fastcgi

Skompilować z portów lighthttpd:
Nie instalować, w katalogu work jest to o co nam chodzi. Sam lighthttpd nam na nic(wolimy nginx’a ;) ) ale przyda nam się z niego spawn-fcgi
cp spawn-fcgi /usr/local/bin

Dopisać do startówek w /usr/local/etc/rc.d/a_php.sh
Poniżej zawartość tego pliku:

#!/bin/sh
SPAWNPATH="/usr/local/bin/spawn-fcgi"
PHPCGIPATH="/usr/local/bin/php-cgi"
PIDPATH="/var/run/php-cgi.pid"
case $1 in
start)
"$SPAWNPATH" -f "$PHPCGIPATH" -a 127.0.0.1 -p 9000 -P "$PIDPATH" -u www -C 5
;;
stop)
kill `cat $PIDPATH`
;;
restart)
kill -HUP `cat $PIDPATH`
;;
*)
echo $"Usage: $0 start|stop|restart"
exit 1
esac
exit 0

odpalić z reki
sh ./a_php.sh
uruchomi to 5 procesow fcgi na localhost:9000, a po restarcie będzie samo ładnie wstawało

zawartość nginx.conf
czyli sedno sprawy, zamiast domena.pl podstawiamy swoją domenkę, procesy nginx’a będą pracować z uprawnieniami usera www(oczywiście musimy go dodać) – jak? Najlepiej via pw (pw groupadd www -g 80, pw useradd www -u 80 -g 80 -d /dev/null -s /sbin/nologin). Simple ;)

user www;
worker_processes 5;
events {
worker_connections 4096;
}
http {
include conf/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name domena.pl;
access_log logs/domena.pl.access.log;
location / {
root docs/domena.pl;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
include /www/conf/domena.pl.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
location ~ /\.ht {
deny all;
}
}
}

Zawartość domena.pl.conf
Dzięki takiemu rozwiązaniu możemy sobie trochę pożonglować ustawieniami dla virtualek…

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
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_param SCRIPT_FILENAME /www/docs/domena.pl$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

test konfiguracji nginx’a
/www/sbin/nginx –t –c /www/conf/nginx.conf

odpalanie nginx’a
/www/sbin/nginx –c /www/conf/nginx.conf

I ta ostatnia linijka znów powinna na stałe trafić do /usr/local/etc/rc.d/naszestartoweconfy.sh

Theme: Rubric. Blog na WordPress.com.

Follow

Otrzymuj każdy nowy wpis na swoją skrzynkę e-mail.