Загружаем и устанавливаем ключ, которым подписаны пакеты и репозитарий nginx
1 |
# wget http://nginx.org/keys/nginx_signing.key |
1 |
# apt-key add nginx_signing.key |
Добавляем в
1 |
/etc/apt/sources.list |
Для Debian-Wheezy
1 2 |
deb http://nginx.org/packages/debian/ wheezy nginx deb-src http://nginx.org/packages/debian/ wheezy nginx |
Для Debian-Squeeze
1 2 |
deb http://nginx.org/packages/debian/ squeeze nginx deb-src http://nginx.org/packages/debian/ sqeeze nginx |
1 |
# apt-get update |
1.Установка и настройка Nginx
1 |
# apt-get install nginx |
1 |
# sysv-rc-conf --level 2345 nginx on |
1 |
# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf~ |
1 |
# nano /etc/nginx/nginx.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
user nginx; worker_processes 1; #число равно количеству процессов на сервере #cat /proc/cpuinfo | grep processor | wc -l worker_priority -5; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; use epoll; multi_accept on; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; #access_log /var/log/nginx/access.log main; access_log off; #restricting on numbers of connection from one ip-adress limit_conn_zone $binary_remote_addr zone=connections:10m; limit_conn_log_level notice; #limit_conn connections 15; #restricting numbers of connection per second from one ip-adress limit_req_zone $binary_remote_addr zone=requests:10m rate=5r/s; limit_req_log_level warn; #limit_req zone=requests burst=10; sendfile on; tcp_nopush on; tcp_nodelay on; server_tokens off; keepalive_timeout 65; types_hash_max_size 2048; gzip on; gzip_static on; gzip_comp_level 5; gzip_min_length 1024; gzip_proxied any; gzip_vary on; gzip_types text/plain text/xml application/xml application/x-javascript text/javascript text/css text/json; gzip_disable "msie6"; open_file_cache max=5000 inactive=20s; open_file_cache_valid 30s; open_file_cache_min_uses 2; open_file_cache_errors on; fastcgi_buffer_size 128k; fastcgi_buffers 256 16k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_connect_timeout 90; fastcgi_send_timeout 90; fastcgi_read_timeout 90; client_max_body_size 128m; client_body_buffer_size 16K; index index.php index.html; include /etc/nginx/conf.d/*.conf; } |
1 |
# nano /etc/nginx/conf.d/default.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
server { listen 192.168.1.72:80 default_server; server_name localhost; root /usr/share/nginx/html; location / { #root /usr/share/nginx/html; try_files $uri $uri/ /index.php?$args; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { #root /usr/share/nginx/html; try_files $uri =404; fastcgi_split_path_info ^(.+?\.php)(/.*)?$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; allow 192.168.1.0/24; deny all; } location = /favicon.ico { log_not_found off; access_log off; allow all; } location = /robots.txt { access_log off; log_not_found off; } } |
Настройка конфигурационных файлов виртуальных хостов Nginx(содержание в конце статьи)
1 |
# nano /etc/nginx/conf.d/joomla.uk.conf |
1 |
# nano /etc/nginx/conf.d/wordpress.uk.conf |
1 |
# nano /etc/nginx/conf.d/kamaok.uk.conf |
1 |
# nginx –t |
1 |
# /etc/init.d/nginx restart |
1 |
# tail -f /var/log/nginx/error.log |
Установка и настройка […]