- Cat2010-10-31论坛元老2024
因为我用的LiteSpeed是免费版,连接数只有150的限制,虽然这150的链接也能应付日IP1W的 WordPress 的博客 ,但是网站的流量慢慢增加,不得不提准备,用Nginx 来跑静态文件,减少一些连接请求,何况用Nginx前端的话,负载能力都高点,速度应该也快点吧,所以,我又折腾起来了,然后做个简单记录,防止以后忘记啊,这个就不算什么教程了.
第一步,当然是安装LiteSpeed啦,请看这里:http://imcat.in/litespeed-mysql-php-install/然后就是安装Nginx了- wget -c http://catlnmp.googlecode.com/files/pcre-8.01.tar.gz
- tar zxvf pcre-8.01.tar.gz
- cd pcre-8.01/
- ./configure
- make && make install
- cd ../复制代码- wget -c http://nginx.org/download/nginx-0.8.53.tar.gz
- tar zxvf nginx-0.8.53.tar.gz
- cd nginx-0.8.53/
- ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module
- make && make install
- cd ../复制代码接着就是关键了,建立一个放网站配置文件的目录和创建配置文件:- mkdir -p /usr/local/nginx/conf/servers
- rm -rf /usr/local/nginx/conf/nginx.conf
- vi /usr/local/nginx/conf/nginx.conf复制代码内容为:- user www www;
- worker_processes 1;
- error_log /usr/local/nginx/logs/nginx_error.log crit;
- pid /usr/local/nginx/nginx.pid;
- #Specifies the value for maximum file descriptors that can be opened by this process.
- worker_rlimit_nofile 1024;
- events
- {
- use epoll;
- worker_connections 1024;
- }
- http
- {
- include mime.types;
- default_type application/octet-stream;
- #charse gb2312;
- server_names_hash_bucket_size 128;
- client_header_buffer_size 128k;
- large_client_header_buffers 4 256k;
- client_max_body_size 16m;
- sendfile on;
- tcp_nopush on;
- keepalive_timeout 60;
- tcp_nodelay on;
- - gzip on;
- gzip_min_length 1k;
- gzip_buffers 4 16k;
- gzip_http_version 1.1;
- gzip_comp_level 9;
- gzip_types text/plain application/x-javascript text/css application/xml;
- gzip_vary on;
- output_buffers 4 32k;
- postpone_output 1460;
- - #limit_zone crawler $binary_remote_addr 10m;
- include servers/*;
- }复制代码- vi /usr/local/nginx/conf/proxy.conf复制代码- 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 50m;
- client_body_buffer_size 256k;
- proxy_connect_timeout 30;
- proxy_send_timeout 30;
- proxy_read_timeout 60;
- - proxy_buffer_size 4k;
- proxy_buffers 4 32k;
- proxy_busy_buffers_size 64k;
- proxy_temp_file_write_size 64k;
- proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
- proxy_max_temp_file_size 128m;
- - #Nginx cache
- client_body_temp_path client_body 1 2;
- proxy_temp_path proxy_temp 1 2;
- - #client_body_temp_path /tmpfs/client_body_temp 1 2;
- #proxy_temp_path /tmpfs/proxy_temp 1 2;
- #fastcgi_temp_path /tmpfs/fastcgi_temp 1 2;复制代码最后就是站点配置文件:- vi /usr/local/nginx/conf/servers/imcat.conf复制代码- server
- {
- listen 80;
- server_name imcat.in www.imcat.in *.imcat.in;
- index index.html index.htm ;
- root /home/www/imcat/;
- include proxy.conf;
- - location / {
- location ~ .*\.(php|php5)?$ {
- index index.php;
- root /home/www/imcat/;
- proxy_pass http://127.0.0.1:8080; #这里的IP是你的LiteSpeed在Listeners 设置的IP和端口,一定要相同
- }
- - if ( !-e $request_filename) {
- proxy_pass http://127.0.0.1:8080; #这里的IP是你的LiteSpeed在Listeners 设置的IP和端口,一定要相同
- }
- - - location ~* \.(jpg|jpeg|gif|png|swf|htm|html)$ {
- if (-f $request_filename) {
- root /home/www/imcat/;
- expires 30d;
- break;
- }
- }
- location ~* \.(js|css)$ {
- if (-f $request_filename) {
- root /home/www/imcat/;
- expires 1d;
- break;
- }
- }
- }
- - error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- }复制代码然后启动Nginx和LiteSpeed就OK了...
所有东西我都是自己Google来的,所以一些错误我还不会解决的,欢迎大家来交流经验啊...