location / { proxy_redirect off; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # below three lines are for websocket. proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; # must be "upgrade" proxy_pass http://localhost:3000; }
ubuntu安装nginx，默认使用logrotate进行日志管理。logrotate能解决nginx不能分割日志的缺陷，我们需要对其进行适当配置。vim /etc/logrotate.d/nginx 修改循环周期为天，以及其它参数：/var/log/nginx/*.log { daily missingok rotate 20 minsize 2M compress delaycompress notifempty create 0640 www-data adm sharedscripts prerotate if [ -d /etc/logrotate.d/httpd-prerotate ]; then \ run-parts /etc/logrotate.d/httpd-prerotate; \ fi; \ endscript postrotate [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid` endscript }
1、安装 $apt-get install mysql-server $apt-get install nginx $apt-get install php5-fpm $apt-get install php5-cli php5-gd php5-mcrypt php5-mysql 2、修改nginx配置$vim /etc/nginx/nginx.conf修改下面两行代码： worker_processes 4; keepalive_timeout 2; 3、修改site配置vim /etc/nginx/sites-available/default修改inde.php 和 php 的fpm配置信息 server { root /var/www; #页面文件存放路径 index index.php index.html index.htm; # 加入index.php server_name localhost; # 修改为网站域名 location / { try_files $uri $uri/ /index.php?$args; # wordpress 重定向 if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite (.*) /index.php; } } # php5-fpm 配置信息 location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } 4、修改php5-fpm，改为socket监听。vim /etc/php5/fpm/pool.d/www.conf改为socket监听;listen = 127.0.0.1:9000 listen = /var/run/php5-fpm.sock5、重启$service php5-fpm restart $service nginx restart