1.Установка имени хоста
1 |
# hostnamectl set-hostname mail.example.com |
1 |
# nano /etc/hostname |
1 |
mail.example.com |
1 |
# nano /etc/hosts |
1 |
192.168.1.102 mail.example.com mail |
1 |
# systemctl restart systemd-hostnamed |
1 |
# hostname |
1 |
mail.example.com |
2.Установка и настройка Nginx
1 |
# nano /etc/yum.repos.d/nginx.repo |
1 2 3 4 5 |
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=1 |
1 |
# yum update |
1 |
# yum install nginx |
1 |
# nano 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 |
user nginx; worker_processes 1; worker_rlimit_nofile 1024; 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; 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 font/ttf font/opentype application/vnd.ms-fontobject image/svg+xml; 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 4 256k; 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 100m; client_body_buffer_size 8K; 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 |
server { listen 192.168.1.102:80 default_server; server_name localhost; root /usr/share/nginx/html; #charset koi8-r; access_log /var/log/nginx/default-access.log main; error_log /var/log/nginx/default-error.log warn; location / { try_files $uri $uri/ /index.php?$args; index index.php index.html index.htm ; } #include common/postfixadmin.conf; #include common/roundcube.conf; location ~ \.php$ { 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; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ /\.ht { deny all; } } |
1 |
# systemctl restart nginx |
1 |
# systemctl enable nginx |
3.Установка и настройка PHP-FPM
1 |
# yum install php php-fpm php-mysql php-imap php-mbstring php-common php-pdo php-xml |
1 |
# nano /etc/php.ini |
1 2 3 4 5 6 7 8 |
expose_php = Off max_execution_time = 300 max_input_time = 600 memory_limit = 256M post_max_size = 100M cgi.fix_pathinfo=0 upload_max_filesize = 100M date.timezone = Europe/Kiev |
1 |
# nano php-fpm.conf |
1 2 3 4 |
emergency_restart_threshold = 10 emergency_restart_interval = 1m process_control_timeout = 10s daemonize = yes |
1 |
# nano /etc/php-fpm.d/www.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
listen.owner = nginx listen.group = nginx listen.mode = 0660 user = nginx group = nginx pm = dynamic pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 35 request_terminate_timeout = 350 request_slowlog_timeout = 3s slowlog = /var/log/php-fpm/www-slow.log catch_workers_output = yes security.limit_extensions = .php .php3 .php4 .php5 php_admin_value[error_log] = /var/log/php-fpm/www-error.log php_admin_flag[log_errors] = on php_admin_value[memory_limit] = 256M php_value[session.save_handler] = files php_value[session.save_path] = /var/lib/php/session |
1 |
# chgrp -R nginx /var/lib/php/session/ |
1 |
# php-fpm -t |
1 |
# systemctl restart php-fpm |
1 |
# systemctl enable php-fpm |
4.Установка и настройка […]