码迷,mamicode.com
首页 > Web开发 > 详细

NginxWeb服务器安装

时间:2016-08-04 09:02:06      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

 

 

1、   安装编译工具和库文件

[root@bigdata-51cdh opt]# yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

技术分享

2、   安装PCRE

(1)    下载 PCRE 安装包,下载地址:http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

(2)    解压。[root@bigdata-51cdh opt]# tar -zxf software/pcre-8.35.tar.gz  -C modules/

技术分享

(3)    进入pcre目录 [root@bigdata-51cdh opt]# cd modules/pcre-8.35/

(4)    编译安装

[root@bigdata-51cdh pcre-8.35]# ./configure

技术分享

[root@bigdata-51cdh pcre-8.35]# make && make install

技术分享

(5)    查看版本,确认安装成功

技术分享

[root@bigdata-51cdh pcre-8.35]# pcre-config --version

8.35

3、   安装Nginx

(1)     下载Nginx ,地址为: http://nginx.org/download/nginx-1.6.2.tar.gz

(2)     解压Nginx

[root@bigdata-51cdh opt]# tar -zxf software/nginx-1.6.2.tar.gz -C modules/

技术分享

(3)     配置

[root@bigdata-51cdh nginx-1.6.2]# ./configure --prefix=/opt/modules/www --with-http_stub_status_module  --with-http_ssl_module --with-pcre=/opt/modules/pcre-8.35

技术分享

(4)     make

技术分享

(5)     make install

技术分享

(6)     查看nginx 版本,确认安装成功

[root@bigdata-51cdh nginx-1.6.2]# /opt/modules/www/sbin/nginx -v

技术分享

4、   Nginx配置

(1)    添加用户,用户名为www

技术分享

(2)    配置nginx.conf文件

[root@bigdata-51cdh nginx-1.6.2]# vim /opt/modules/www/conf/nginx.conf

user www www;

worker_processes 1;

error_log /opt/modules/www/logs/nginx_error.log crit;

pid /opt/modules/www/nginx.pid;

 

worker_rlimit_nofile 65535;

events

{

  use epoll;

  worker_connections 65535;

}

http

{

  include mime.types;

  default_type application/octet-stream;

  log_format main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘

               ‘$status $body_bytes_sent "$http_referer" ‘

               ‘"$http_user_agent" $http_x_forwarded_for‘;

 

 

  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_length 1k;

  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;

 

 server

  {

    listen 80;

    server_name localhost;

    index index.html index.htm index.php;

    root /opt/modules/www/html;

      location ~ .*\.(php|php5)?$

    {

      fastcgi_pass 127.0.0.1:9000;

      fastcgi_index index.php;

      include fastcgi.conf;

    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$

    {

      expires 30d;

 

    }

    location ~ .*\.(js|css)?$

    {

      expires 15d;

 

    }

    access_log off;

  }

}

(3)    检查配置是否正确

[root@bigdata-51cdh www]# /opt/modules/www/sbin/nginx -t

技术分享

5、   启动Nginx

[root@bigdata-51cdh www]# /opt/modules/www/sbin/nginx

[root@bigdata-51cdh www]# ps -ef|grep nginx

技术分享

6、   访问Nginx站点

技术分享





附件列表

     

    NginxWeb服务器安装

    标签:

    原文地址:http://www.cnblogs.com/chybin/p/5735256.html

    (0)
    (0)
       
    举报
    评论 一句话评论(0
    登录后才能评论!
    © 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
    迷上了代码!