1、nginx.conf
user nginx nginx; worker_processes 4; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; worker_rlimit_nofile 65535; events { use epoll; worker_connections 65535; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 3526; server_names_hash_max_size 4096; log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘ ‘$status $body_bytes_sent "$http_referer" ‘ ‘"$http_user_agent" "$http_x_forwarded_for"‘; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 60; send_timeout 120; client_header_timeout 3m; client_body_timeout 3m; client_max_body_size 100m; client_body_buffer_size 4k; client_header_buffer_size 128k; large_client_header_buffers 4 64k; connection_pool_size 256; request_pool_size 8k; output_buffers 4 32k; postpone_output 1460; client_body_temp_path /tmp/nginx/client_body; proxy_temp_path /tmp/nginx/proxy; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_comp_level 3; gzip_http_version 1.1; gzip_types text/plain application/x-javascript text/css text/htm application/xml; gzip_vary on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; fastcgi_temp_path /tmp/nginx/fastcgi; fastcgi_intercept_errors on; include vhosts/*.conf; }
2、Nginx server_conf
server { listen 80; server_name 172.15.1.11; index index.html index.htm index.php index.jsp; server_tokens off; root /data/www/html; access_log /var/log/nginx/www_access.log main; location ~ \.php$ { include fastcgi_params; fastcgi_pass unix:/var/lib/php/php-fcgi.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /data/www/html$fastcgi_script_name; } location ~* \.(jsp|jspx|do)$ { proxy_pass http://192.168.1.231:8080; } location ~* ^.+\.(gif|jpg|png|ioc|swf|flv|rar|zip|doc|ppt|pdf|gz|bz2|jpeg|bmp|xls|mid|mp3|wma)$ { expires 7d; root /data/www/html; access_log off; valid_referers none blocked *.huangming.org huangming.org 172.15.1.11; if ($invalid_referer) { return 403; } } location ~ .*\.(js|css)?$ { expires 24h; access_log off; } location ~ (static|cache) { access_log off; } location /NginxStatus { stub_status on; access_log /var/log/nginx/NginxStatus.log; auth_basic "NginxStatus"; auth_basic_user_file /etc/nginx/htpasswd; } }
3、Nginx status
location /NginxStatus { stub_status on; access_log /var/log/nginx/NginxStatus.log; auth_basic "NginxStatus"; auth_basic_user_file /etc/nginx/htpasswd; } # yum install httpd # htpasswd -c /etc/nginx/htpasswd admin New password: Re-type new password: Adding password for user admin
4、php-fpm
# vim /usr/local/php/etc/php-fpm.conf [global] pid = /usr/local/php/var/run/php-fpm.pid error_log = /usr/local/php/var/log/php-fpm.log [www] listen = /var/lib/php/php-fcgi.sock user = php-fpm group = php-fpm listen.owner = nginx listen.group = nginx pm = dynamic pm.max_children = 100 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 500 rlimit_files = 1024 slowlog = /var/log/php/www_slow.log request_slowlog_timeout = 1 php_admin_value[open_basedir]=/data/www/:/tmp/ # /usr/local/php/sbin/php-fpm -t [29-Apr-2016 04:11:02] NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful # service php-fpm restart Gracefully shutting down php-fpm . done Starting php-fpm done
5、Create data
mysql> create database discuz; mysql> GRANT ALL ON discuz.* TO [email protected]‘172.15.1.%‘ IDENTIFIED BY ‘discuz‘; mysql> FLUSH PRIVILEGES;
6、iptables
#!/bin/bash iptables -F iptables -X iptables -Z iptables -P INPUT DROP iptables -P OUTPUT ACCEPT iptables -P FORWARD ACCEPT iptables -A INPUT -p icmp -j ACCEPT iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -s 127.0.0.1 -j ACCEPT iptables -A INPUT -p tcp --dport 22 -j ACCEPT iptables -A INPUT -p tcp --dport 80 -j ACCEPT iptables -A INPUT -p tcp --dport 3306 -s 172.15.1.0/24 -j ACCEPT iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT # getenforce Disabled
时间: 2024-10-31 02:14:27