<VirtualHost *:81>
ServerName www.example.com
ServerAlias example.com
ServerAdmin [email protected]
DocumentRoot /var/www/example.com
<Directory /var/www/example.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory〉
ErrorLog /var/log/apache2/error.log
LogLevel warn
ServerSignature On
</VirtualHost>
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 64;
access_log /var/log/nginx/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_proxied any;
gzip_min_length 1100;
gzip_http_version 1.0;
gzip_buffers 4 8k;
gzip_comp_level 9;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
server {
listen 80;
server_name domain.ru;
access_log /var/log/nginx/domain.ru-nginx.access.log;
location / {
proxy_pass http://127.0.0.1:81/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 40m;
client_body_buffer_size 256k;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 120;
proxy_buffer_size 64k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#Static files location
location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|html|flv|mp3)$ {
root /var/www/domain.ru; }
}
$ sudo apt-get install php5-dev
$ sudo apt-get install make
$ sudo cd /tmp/
$ sudo wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2
$ sudo tar xvjf eaccelerator-0.9.5.3.tar.bz2
$ sudo cd eaccelerator-0.9.5.3
$ sudo phpize
$ sudo ./configure --enable-eaccelerator=shared
$ sudo make
$ sudo make install
$ sudo mkdir -p /var/cache/eaccelerator
$ sudo chmod 0777 /var/cache/eaccelerator
$ nano /etc/php5/apache2/php.ini
[PHP]
; eAccelerator configuration
; Note that eAccelerator may also be installed as a PHP extension or as a zend_extension
; If you are using a thread safe build of PHP you must use
; zend_extension_ts instead of zend_extension
extension = "eaccelerator.so"
eaccelerator.shm_size = "16"
eaccelerator.cache_dir = "/var/cache/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"
eaccelerator.allowed_admin_path = "/var/www/eaccelerator"
eaccelerator.shm_only = “1”
eaccelerator.shm_size = “128”
eaccelerator.allowed_admin_path = “/var/www/eaccelerator”
$ wget http://www.sphinxsearch.com/downloads/sphinx-0.9.8.1.tar.gz
$ tar –xzvf sphinx-0.9.8.tar.gz
$ cd sphinx-0.9.8
$ ./configure
$ make
$ make install
$ mkdir -p /var/db/sphinx/log
$ chmod -R 777 /var/db/
$ nano /usr/local/etc/sphinx.conf
#######################
##
#######################source lsParentSource
{
type = mysql
sql_host = your_database_host
sql_user = your_database_login
sql_pass = your_database_password
sql_db = your_database_name
sql_port = 3306sql_sock = /var/run/mysqld/mysqld.sock
mysql_connect_flags = 32 # 32-
sql_query_pre = SET NAMES utf8
sql_query_pre = SET SESSION query_cache_type=OFF
}source topicsSource : lsParentSource
{sql_query = \
SELECT t_fast.topic_id, t_fast.topic_title, UNIX_TIMESTAMP(t_fast.topic_date_add) as topic_date_add, \
tc.topic_text, t_fast.topic_publish \
FROM prefix_topic as t_fast, prefix_topic_content AS tc \
WHERE t_fast.topic_id=tc.topic_id AND t_fast.topic_id>=$start AND t_fast.topic_id<=$endsql_query_range = SELECT MIN(topic_id),MAX(topic_id) FROM prefix_topic
sql_range_step = 1000
sql_attr_bool = topic_publish
sql_attr_timestamp = topic_date_add
sql_attr_multi = uint tag from query; SELECT topic_id, topic_tag_id FROM prefix_topic_tag
sql_ranged_throttle = 0
}source commentsSource : lsParentSource
{
sql_query = \
SELECT comment_id, comment_text, UNIX_TIMESTAMP(comment_date) as comment_date, comment_delete \
FROM prefix_topic_comment \
WHERE comment_id>=$start AND comment_id<=$endsql_query_range = SELECT MIN(comment_id),MAX(comment_id) FROM prefix_topic_comment
sql_range_step = 5000sql_attr_bool = comment_delete
sql_attr_timestamp = comment_date
}#######################
##
#######################index topicsIndex
{source = topicsSource
path = /usr/local/SphinxIndex/topicsSourcedocinfo = extern
mlock = 0
morphology = stem_enru, soundex, metaphone
# Kodirovaka data from a data source
charset_type = utf-8html_strip = 1
}index commentsIndex
{
source = commentsSource
path = /usr/local/SphinxIndex/commentsSourcedocinfo = extern
mlock = 0
morphology = stem_enru, soundex, metaphone
charset_type = utf-8
}#######################
##
#######################indexer
{mem_limit = 32M
}#######################
#######################
searchd
{address = 127.0.0.1
port = 3312
log = /var/log/sphinx/searchd.log
query_log = /var/log/sphinx/query.log
read_timeout = 5
# Maximum number of simultaneously processed requests. 0 means a ton, or rather without restrictions
max_children = 30# File in which to store the PID of the process at startup
pid_file = /var/log/sphinx/searchd.pid
}
$ mkdir -p /usr/local/SphinxIndex
$ chmod -R 777 /usr/local/SphinxIndex/
$ /usr/local/bin/indexer –all
$ /usr/local/bin/searchd
$ nano /etc/crontab
Добавляем:
0 */3 * * * /usr/local/bin/indexer –all –rotate
Это значит, что мы будем запускать индексацию каждые 3 часа.
Перезапускаем сервисы:
$ service apache2 restart
$ service nginx restart
$ service memcached restart
Проверяем в phpinfo()
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright © 1998-2008 Zend Technologies
with eAccelerator v0.9.5.3, Copyright © 2004-2006 eAccelerator, by eAccelerator
memcache support enabled
lsof -i
apache2 948 www-data 3u IPv4 47935 TCP *:81 (LISTEN)
memcached 3096 nobody 3u IPv4 165608 TCP localhost:11211 (LISTEN)
nginx 19605 www-data 6u IPv4 62263 TCP *:www (LISTEN)