Linux中设置配置Nginx及参数详解

By admin in 美高梅手机版4858 on 2019年5月2日

 

Linux中安装Nginx,Linux安装Nginx

 

 

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

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

美高梅手机版4858 1

 

2、安装PCRE,Nginx的rewrite的伪静态相称规则须要用到正则表达式,PCRE正是起到那么些效应。

  下载地址:wget 

  固然wget未有安装的话,必要先安装wget,yum -y install wget.
 wget是Linux蒙受下的下载工具。wget命令的利用见此作品:

美高梅手机版4858 2

 

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

美高梅手机版4858 3

 

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

  cd pcre-8.35

  ./configure

  make && make install

 

5、查看pcre版本

  pcre-config
–version

美高梅手机版4858 4

 

6、下载Nginx

Linux中设置配置Nginx及参数详解。  wget 

美高梅手机版4858 5

 

七、解压并跻身安装包

美高梅手机版4858 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版本

美高梅手机版4858 7

 

10、Nginx配置

   ①、创建Nginx 运维使用的用户

     /usr/sbin/groupadd www

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

   贰、配置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

美高梅手机版4858 8

 

    四、关于Nginx连接数的布局,请参考网站:

 

 

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

Linux中装置配备Nginx及参数详解

 

1、安装编写翻译文件及库文件

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

  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

美高梅手机版4858 9

美高梅手机版4858 10

2、安装PCRE,Nginx的rewrite的伪静态相配规则须要用到正则表明式,PCRE便是起到那些职能。

 

  下载地址:wget 

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

  假若wget未有安装的话,要求先安装wget,yum -y install wget.
 wget是Linux蒙受下的下载工具。wget命令的行使见此小说:

  下载地址:wget 

美高梅手机版4858 11

美高梅手机版4858,  假使wget未有安装的话,须要先安装wget,yum -y install wget.
 wget是Linux境况下的下载工具。wget命令的行使见此小说:

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

美高梅手机版4858 12

美高梅手机版4858 13

 

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

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

  cd pcre-8.35

美高梅手机版4858 14

  ./configure

 

  make && make install

4、进入安装目录,编写翻译安装

5、查看pcre版本

  cd pcre-8.35

  pcre-config
–version

  ./configure

美高梅手机版4858 15

  make && make install

6、下载Nginx

 

  wget 

5、查看pcre版本

美高梅手机版4858 16

  pcre-config
–version

柒、解压并跻身安装包

美高梅手机版4858 17

美高梅手机版4858 18

 

八、编写翻译安装

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 

  make

美高梅手机版4858 19

  make
install

 

9、查看Nginx版本

柒、解压并跻身安装包

美高梅手机版4858 20

美高梅手机版4858 21

10、Nginx配置

 

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

8、编写翻译安装

     /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

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

  make

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

  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版本

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

美高梅手机版4858 22

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

 

美高梅手机版4858 23

10、Nginx配置

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

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

美高梅手机版4858 24

     /usr/sbin/groupadd www

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

   2、配置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

美高梅手机版4858 25

 

    4、关于Nginx连接数的布署,请参见网站:

 

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有