Linux中安装Nginx,Linux安装Nginx

 

 

① 、安装编译文件及库文件

  yum -y install
make zlib zlib-devel gcc-c++
libtool  openssl openssl-devel

澳门金沙国际 1

 

② 、安装PCRE,Nginx的rewrite的伪静态匹配规则须求用到正则表明式,PCRE就是起到那些意义。

  下载地址:wget 

  若是wget没有设置的话,必要先安装wget,yum -y install wget.
 wget是Linux环境下的下载工具。wget命令的运用见此小说:

澳门金沙国际 2

 

3、解压pcre安装包:tar -zxvf pcre-8.35.tar.gz

澳门金沙国际 3

 

肆 、进入安装目录,编译安装

  cd pcre-8.35

  ./configure

  make && make install

 

5、查看pcre版本

  pcre-config
–version

澳门金沙国际 4

 

6、下载Nginx

  wget 

澳门金沙国际 5

 

7、解压并跻身安装包

澳门金沙国际 6

 

八 、编译安装

  ./configure –prefix=/usr/local/webserver/nginx –with-http_stub_status_module –with-http_ssl_module
–with-pcre=/usr/local/src/pcre-8.35

  make

  make
install

9、查看Nginx版本

澳门金沙国际 7

 

10、Nginx配置

   一 、创造Nginx 运营使用的用户

     /usr/sbin/groupadd www

*     /usr/sbin/useradd -g www
wwwLinux中设置配置Nginx及参数详解。*

   ② 、配置nginx.conf
,将/usr/local/webserver/nginx/conf/nginx.conf替换为以下内容

   

user www www;
worker_processes 2; #设置值和CPU核心数一致
error_log /usr/local/webserver/nginx/logs/nginx_error.log crit; #日志位置和日志级别
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_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';

#charset gb2312;

  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;

  #limit_zone crawler $binary_remote_addr 10m;
 #下面是server虚拟主机的配置
 server
  {
    listen 80;#监听端口
    server_name localhost;#域名
    index index.html index.htm index.php;
    root /usr/local/webserver/nginx/html;#站点目录
      location ~ .*\.(php|php5)?$
    {
      #fastcgi_pass unix:/tmp/php-cgi.sock;
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      include fastcgi.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
    {
      expires 30d;
  # access_log off;
    }
    location ~ .*\.(js|css)?$
    {
      expires 15d;
   # access_log off;
    }
    access_log off;
  }

}

    三 、检查nginx.conf配置文件的正确性

      /usr/local/webserver/nginx/sbin/nginx -t

澳门金沙国际 8

 

    四 、关于Nginx连接数的陈设,请参见网址:

 

 

① 、安装编译文件及库文件 yum – y install make zlib zlib – devel gcc – c
++ libtool openssl openssl – devel 二 、安装PCRE,Nginx的…

澳门金沙国际,Linux中设置配置Nginx及参数详解

 

 

① 、安装编译文件及库文件

① 、安装编译文件及库文件

一 、安装编译文件及库文件

  yum -y install
make zlib zlib-devel gcc-c++
libtool  openssl openssl-devel

  yum -y install
make zlib zlib-devel gcc-c++
libtool  openssl openssl-devel

  yum -y install
make zlib zlib-devel gcc-c++
libtool  openssl openssl-devel

澳门金沙国际 9

澳门金沙国际 10

澳门金沙国际 11

② 、安装PCRE,Nginx的rewrite的伪静态匹配规则须要用到正则表达式,PCRE就是起到那些功能。

 

 

  下载地址:wget 

贰 、安装PCRE,Nginx的rewrite的伪静态匹配规则必要用到正则表明式,PCRE就是起到那几个职能。

② 、安装PCRE,Nginx的rewrite的伪静态匹配规则须要用到正则表达式,PCRE就是起到这么些成效。

  要是wget没有安装的话,须要先安装wget,yum -y install wget.
 wget是Linux环境下的下载工具。wget命令的行使见此小说:

  下载地址:wget 

  下载地址:wget 

澳门金沙国际 12

  假设wget没有安装的话,需要先安装wget,yum -y install wget.
 wget是Linux环境下的下载工具。wget命令的使用见此文章:

  倘诺wget没有安装的话,要求先安装wget,yum -y install wget.
 wget是Linux环境下的下载工具。wget命令的行使见此小说:

3、解压pcre安装包:tar -zxvf pcre-8.35.tar.gz

澳门金沙国际 13

澳门金沙国际 14

澳门金沙国际 15

 

 

四 、进入安装目录,编译安装

3、解压pcre安装包:tar -zxvf pcre-8.35.tar.gz

3、解压pcre安装包:tar -zxvf pcre-8.35.tar.gz

  cd pcre-8.35

澳门金沙国际 16

澳门金沙国际 17

  ./configure

 

 

  make && make install

肆 、进入安装目录,编译安装

④ 、进入安装目录,编译安装

5、查看pcre版本

  cd pcre-8.35

  cd pcre-8.35

  pcre-config
–version

  ./configure

  ./configure

澳门金沙国际 18

  make && make install

  make && make install

6、下载Nginx

 

 

  wget 

5、查看pcre版本

5、查看pcre版本

澳门金沙国际 19

  pcre-config
–version

  pcre-config
–version

柒 、解压并进入安装包

澳门金沙国际 20

澳门金沙国际 21

澳门金沙国际 22

 

 

⑧ 、编译安装

6、下载Nginx

6、下载Nginx

  ./configure –prefix=/usr/local/webserver/nginx –with-http_stub_status_module –with-http_ssl_module
–with-pcre=/usr/local/src/pcre-8.35

  wget 

  wget 

  make

澳门金沙国际 23

澳门金沙国际 24

  make
install

 

 

9、查看Nginx版本

柒 、解压并跻身安装包

⑦ 、解压并跻身安装包

澳门金沙国际 25

澳门金沙国际 26

澳门金沙国际 27

10、Nginx配置

 

 

   ① 、创设Nginx 运营使用的用户

⑧ 、编译安装

捌 、编译安装

     /usr/sbin/groupadd www

  ./configure –prefix=/usr/local/webserver/nginx –with-http_stub_status_module –with-http_ssl_module
–with-pcre=/usr/local/src/pcre-8.35

  ./configure –prefix=/usr/local/webserver/nginx –with-http_stub_status_module –with-http_ssl_module
–with-pcre=/usr/local/src/pcre-8.35

*     /usr/sbin/useradd -g www
www*

  make

  make

   贰 、配置nginx.conf
,将/usr/local/webserver/nginx/conf/nginx.conf替换为以下内容

  make
install

  make
install

user www www;
worker_processes 2; #设置值和CPU核心数一致
error_log /usr/local/webserver/nginx/logs/nginx_error.log crit; #日志位置和日志级别
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_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';

#charset gb2312;

  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;

  #limit_zone crawler $binary_remote_addr 10m;
 #下面是server虚拟主机的配置
 server
  {
    listen 80;#监听端口
    server_name localhost;#域名
    index index.html index.htm index.php;
    root /usr/local/webserver/nginx/html;#站点目录
      location ~ .*\.(php|php5)?$
    {
      #fastcgi_pass unix:/tmp/php-cgi.sock;
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      include fastcgi.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
    {
      expires 30d;
  # access_log off;
    }
    location ~ .*\.(js|css)?$
    {
      expires 15d;
   # access_log off;
    }
    access_log off;
  }

}

9、查看Nginx版本

9、查看Nginx版本

    叁 、检查nginx.conf配置文件的正确性

澳门金沙国际 28

澳门金沙国际 29

      /usr/local/webserver/nginx/sbin/nginx -t

 

 

澳门金沙国际 30

10、Nginx配置

10、Nginx配置

越多详情见请继续读书下一页的精粹内容
http://www.linuxidc.com/Linux/2017-05/143853p2.htm

   一 、创制Nginx 运营使用的用户

   壹 、创设Nginx 运维使用的用户

澳门金沙国际 31

     /usr/sbin/groupadd www

     /usr/sbin/groupadd www

*     /usr/sbin/useradd -g www
www*

*     /usr/sbin/useradd -g www
www*

   ② 、配置nginx.conf
,将/usr/local/webserver/nginx/conf/nginx.conf替换为以下内容

   二 、配置nginx.conf
,将/usr/local/webserver/nginx/conf/nginx.conf替换为以下内容

   

   

user www www;
worker_processes 2; #设置值和CPU核心数一致
error_log /usr/local/webserver/nginx/logs/nginx_error.log crit; #日志位置和日志级别
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_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';

#charset gb2312;

  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;

  #limit_zone crawler $binary_remote_addr 10m;
 #下面是server虚拟主机的配置
 server
  {
    listen 80;#监听端口
    server_name localhost;#域名
    index index.html index.htm index.php;
    root /usr/local/webserver/nginx/html;#站点目录
      location ~ .*\.(php|php5)?$
    {
      #fastcgi_pass unix:/tmp/php-cgi.sock;
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      include fastcgi.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
    {
      expires 30d;
  # access_log off;
    }
    location ~ .*\.(js|css)?$
    {
      expires 15d;
   # access_log off;
    }
    access_log off;
  }

}
user www www;
worker_processes 2; #设置值和CPU核心数一致
error_log /usr/local/webserver/nginx/logs/nginx_error.log crit; #日志位置和日志级别
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_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';

#charset gb2312;

  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;

  #limit_zone crawler $binary_remote_addr 10m;
 #下面是server虚拟主机的配置
 server
  {
    listen 80;#监听端口
    server_name localhost;#域名
    index index.html index.htm index.php;
    root /usr/local/webserver/nginx/html;#站点目录
      location ~ .*\.(php|php5)?$
    {
      #fastcgi_pass unix:/tmp/php-cgi.sock;
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      include fastcgi.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
    {
      expires 30d;
  # access_log off;
    }
    location ~ .*\.(js|css)?$
    {
      expires 15d;
   # access_log off;
    }
    access_log off;
  }

}

    叁 、检查nginx.conf配置文件的正确性

    三 、检查nginx.conf配置文件的正确

      /usr/local/webserver/nginx/sbin/nginx -t

      /usr/local/webserver/nginx/sbin/nginx -t

澳门金沙国际 32

澳门金沙国际 33

 

 

    ④ 、关于Nginx连接数的布置,请参见网址:

    肆 、关于Nginx连接数的计划,请参见网址:

 

 

 

 

相关文章