现在的位置: 首页 > 综合 > 正文

centos nginx 安装文档 0.8.x

2012年09月12日 ⁄ 综合 ⁄ 共 3750字 ⁄ 字号 评论关闭

1.获取基本的相关的开源程序:

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

  

2.推荐两个RPM包搜索网站

  

http://rpm.pbone.net/
http://www.rpmfind.net/

3.先通过命令  rpm -qa | grep libjpeg 类似的命令 去检查上面这些包是否存在,否则,安装会出现缺少库支持

   rpm -ivh (filename) 是安装RPM包的命令

  

4.获取nginx的源代码包

  

wget http://sysoev.ru/nginx/nginx-0.8.46.tar.gz

  

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.10.tar.gz  (安装nginx需要的库支持)

  

5.创建www:www用户和组

groupadd www

useradd -g www www

 

将nginx 安装在/usr/local/webserver/ 下面

以后就将web程序放在/var/www/下面

 

@1安装Nginx所需的pcre库:

@2安装Nginx

 

Ruby代码 复制代码 收藏代码
  1. tar zxvf nginx-0.8.46.tar.gz   
  2. cd nginx-0.8.46/   
  3. ./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module   
  4. make && make install   
  5. cd ../  
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日志目录

 

Ruby代码  
  1. mkdir -p /data1/logs   
  2. chmod +w /data1/logs   
  3. chown -R www:www /data1/logs  
mkdir -p /data1/logs
chmod +w /data1/logs
chown -R www:www /data1/logs

网上推荐的一份nginx.conf

mv /usr/local/webserver/nginx/conf/nginx.conf /usr/local/webserver/nginx/conf/nginx.conf.bak
vi /usr/local/webserver/nginx/conf/nginx.conf

Ruby代码  
  1. user  www www;   
  2.   
  3. worker_processes 8;   
  4.   
  5. error_log  /data1/logs/nginx_error.log  crit;   
  6.   
  7. pid        /usr/local/webserver/nginx/nginx.pid;   
  8.   
  9. #Specifies the value for maximum file descriptors that can be opened by this process.    
  10. worker_rlimit_nofile 65535;   
  11.   
  12. events    
  13. {   
  14.   use epoll;   
  15.   worker_connections 65535;   
  16. }   
  17.   
  18. http    
  19. {   
  20.   include       mime.types;   
  21.   default_type  application/octet-stream;   
  22.   
  23.   #charset  gb2312;   
  24.          
  25.   server_names_hash_bucket_size 128;   
  26.   client_header_buffer_size 32k;   
  27.   large_client_header_buffers 4 32k;   
  28.   client_max_body_size 8m;   
  29.          
  30.   sendfile on;   
  31.   tcp_nopush     on;   
  32.   
  33.   keepalive_timeout 60;   
  34.   
  35.   tcp_nodelay on;   
  36.   
  37.   fastcgi_connect_timeout 300;   
  38.   fastcgi_send_timeout 300;   
  39.   fastcgi_read_timeout 300;   
  40.   fastcgi_buffer_size 64k;   
  41.   fastcgi_buffers 4 64k;   
  42.   fastcgi_busy_buffers_size 128k;   
  43.   fastcgi_temp_file_write_size 128k;   
  44.   
  45.   gzip on;   
  46.   gzip_min_length  1k;   
  47.   gzip_buffers     4 16k;   
  48.   gzip_http_version 1.0;   
  49.   gzip_comp_level 2;   
  50.   gzip_types       text/plain application/x-javascript text/css application/xml;   
  51.   gzip_vary on;   
  52.   
  53.   #limit_zone  crawler  $binary_remote_addr  10m;   
  54.   
  55.   server   
  56.   {   
  57.      listen       80;   
  58.      server_name  <A href="http://www.test.com;%09">www.test.com;   
  59.     </A> index index.html index.htm index.php;   
  60.      root  /data0/htdocs/blog;   
  61.   
  62.         #limit_conn   crawler  20;       
  63.                                 
  64.     location ~ .*\.(php|php5)?$   
  65.     {         
  66.         #fastcgi_pass  unix:/tmp/php-cgi.sock;   
  67.         fastcgi_pass  127.0.0.1:9000;   
  68.         fastcgi_index index.php;   
  69.         include fcgi.conf;   
  70.     }   
  71.        
  72.     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$   
  73.         {   
  74.         expires      30d;   
  75.         }   
  76.   
  77.     location ~ .*\.(js|css)?$   
  78.     {   
  79.         expires      1h;   
  80.     }       
  81.   
  82.               log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '  
  83.               '$status $body_bytes_sent "$http_referer" '  
  84.               '"$http_user_agent" $http_x_forwarded_for';   
  85.                access_log  /data1/logs/access.log  access;   
  86.       }   
  87.   
  88.   
  89.   
  90.   
  91. }  
Ruby代码  
  1. tar zxvf pcre-8.10.tar.gz   
  2. cd pcre-8.10/   
  3. ./configure   
  4. make && make install   
  5. cd ../  
tar zxvf pcre-8.10.tar.gz
cd pcre-8.10/
./configure
make && make install
cd ../

  

抱歉!评论已关闭.