tilg 发表于 2013-9-12 08:56:33

三、安装Nginx 0.8.46【LNMP安装 】

1、安装Nginx所需的pcre库:
tar zxvf pcre-8.10.tar.gz
cd pcre-8.10/
./configure
make && make install
cd ../


  2、安装Nginx
tar zxvf nginx-0.8.46.tar.gz
cd nginx-0.8.46/
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
cd ../


  3、创建Nginx日志目录
mkdir -p /data1/logs
chmod +w /data1/logs
chown -R www:www /data1/logs


  4、创建Nginx配置文件
  ①、在/usr/local/webserver/nginx/conf/目录中创建nginx.conf文件:
rm -f /usr/local/webserver/nginx/conf/nginx.conf
vi /usr/local/webserver/nginx/conf/nginx.conf

  输入以下内容:
引用
userwww www;

worker_processes 8;

error_log/data1/logs/nginx_error.logcrit;

pid      /usr/local/webserver/nginx/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;

events
{
use epoll;
worker_connections 65535;
}

http
{
include       mime.types;
default_typeapplication/octet-stream;

#charsetgb2312;

server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;

sendfile on;
tcp_nopush   on;

keepalive_timeout 60;

tcp_nodelay 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;

gzip on;
gzip_min_length1k;
gzip_buffers   4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types       text/plain application/x-javascript text/css application/xml;
gzip_vary on;

#limit_zonecrawler$binary_remote_addr10m;

server
{
   listen       80;
   server_nameblog.s135.com;
   index index.html index.htm index.php;
   root/data0/htdocs/blog;

   #limit_conn   crawler20;   

   location ~ .*\.(php|php5)?$
   {      
   #fastcgi_passunix:/tmp/php-cgi.sock;
   fastcgi_pass127.0.0.1:9000;
   fastcgi_index index.php;
   include fcgi.conf;
   }

   location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
   {
   expires      30d;
   }

   location ~ .*\.(js|css)?$
   {
   expires      1h;
   }   

   log_formataccess'$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
   access_log/data1/logs/access.logaccess;
   }

server
{
   listen       80;
   server_namewww.s135.com;
   index index.html index.htm index.php;
   root/data0/htdocs/www;

   location ~ .*\.(php|php5)?$
   {      
   #fastcgi_passunix:/tmp/php-cgi.sock;
   fastcgi_pass127.0.0.1:9000;
   fastcgi_index index.php;
   include fcgi.conf;
   }

   log_formatwwwlogs'$remote_addr - $remote_user [$time_local] "$request" '
            '$status $body_bytes_sent "$http_referer" '
            '"$http_user_agent" $http_x_forwarded_for';
   access_log/data1/logs/wwwlogs.logwwwlogs;
}

server
{
   listen80;
   server_namestatus.blog.s135.com;

   location / {
   stub_status on;
   access_log   off;
   }
}
}


  ②、在/usr/local/webserver/nginx/conf/目录中创建fcgi.conf文件:
vi /usr/local/webserver/nginx/conf/fcgi.conf

  输入以下内容:
引用
fastcgi_paramGATEWAY_INTERFACECGI/1.1;
fastcgi_paramSERVER_SOFTWARE    nginx;

fastcgi_paramQUERY_STRING       $query_string;
fastcgi_paramREQUEST_METHOD   $request_method;
fastcgi_paramCONTENT_TYPE       $content_type;
fastcgi_paramCONTENT_LENGTH   $content_length;

fastcgi_paramSCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_paramSCRIPT_NAME      $fastcgi_script_name;
fastcgi_paramREQUEST_URI      $request_uri;
fastcgi_paramDOCUMENT_URI       $document_uri;
fastcgi_paramDOCUMENT_ROOT      $document_root;
fastcgi_paramSERVER_PROTOCOL    $server_protocol;

fastcgi_paramREMOTE_ADDR      $remote_addr;
fastcgi_paramREMOTE_PORT      $remote_port;
fastcgi_paramSERVER_ADDR      $server_addr;
fastcgi_paramSERVER_PORT      $server_port;
fastcgi_paramSERVER_NAME      $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_paramREDIRECT_STATUS    200;


  5、启动Nginx
ulimit -SHn 65535
/usr/local/webserver/nginx/sbin/nginx

zhufeng518 发表于 2013-11-27 22:55:56

-这个世界什么都是假的,只有你不爱我是真的。

lygyh9985825 发表于 2013-11-30 13:58:21

我们两个人之间、是永远不可能相交的平行线

h0945634 发表于 2013-12-3 19:15:14

红莲即将绽放,双星终会汇聚,命运的转轮已经开始,请您耐心地等待.

zxg58 发表于 2013-12-6 16:10:01

着寂寞光线的房间,吟听着一些掖藏的感觉。让我们一起遗忘。这寂寞爱情,我要把你给忘。

判官007 发表于 2013-12-9 06:44:07

不要抱怨老天,终有一天奇迹会降临在每个人身上。

rule 发表于 2013-12-11 16:17:31

岁月如刀催人老,昔日红颜不复在。
页: [1]
查看完整版本: 三、安装Nginx 0.8.46【LNMP安装 】