澳门新浦京娱乐场网站-www.146.net-新浦京娱乐场官网
做最好的网站

Linux中安装配备Nginx及参数详解,下布置公司网址

 

Linux中安装Nginx,Linux安装Nginx

 

 

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

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

图片 1

 

2、安装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

 

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

  cd pcre-8.35

  ./configure

  make && make install

 

5、查看pcre版本

  pcre-config --version

图片 4

 

6、下载Nginx

  wget 

图片 5

 

7、解压并进入安装包

图片 6

 

8、编译安装

  ./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配置

   1、创建Nginx 运行使用的用户

     /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;
  }

}

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

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

图片 8

 

    4、关于Nginx连接数的配置,请参看网址:

 

 

1、安装编译文件及库文件 yum - y install make zlib zlib - devel gcc - c libtool openssl openssl - devel 2、安装PCRE,Nginx的...

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

CentOS 6.5 下部署企业网站平台Nginx PHP

 

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

一、安装前准备
# yum -y install gcc gcc-c glibc automake autoconf libtool make
# yum -y install libmcrypt-devel mhash-devel libxslt-devel 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

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

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

二、php-fpm安装
# wget
# tar jxf php-5.5.36.tar.bz2
# cd php-5.5.36
# ./configure --prefix=/usr/local/php
--enable-fpm --with-mcrypt --enable-mbstring --disable-pdo
--with-curl --disable-debug --disable-rpath --enable-inline-optimization
--with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm
--enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex
--with-mysql --with-mysqli --with-gd --with-jpeg-dir
# make && make install

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

图片 9

配置php-fpm运行用户
# useradd www -M

图片 10

2、安装PCRE,Nginx的rewrite的伪静态匹配规则需要用到正则表达式,PCRE就是起到这个作用。

# cd /usr/local/php/
# cp etc/php-fpm.default etc/php-fpm.conf
# vi etc/php-fpm.conf
修改
user = www
group = www

 

  下载地址:wget 

三、编译安装nginx

2、安装PCRE,Nginx的rewrite的伪静态匹配规则需要用到正则表达式,PCRE就是起到这个作用。

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

# yum install -y gcc gcc-c automake autoconf libtool make

  下载地址:wget 

图片 11

1、安装插件安装包
首先需要安装pcre库,然后再安装Nginx:
#安装pcre支持rewrite库,也可以安装源码,注*安装源码时,指定pcre路径为解压源码的路径,而不是编译后的路径,否则会报错
(make[1]: *** [/usr/local/pcre/Makefile] Error 127 错误)
# yum -y install pcre-devel pcre zlib zlib-devel openssl openssl-devel或
源码安装PCRE(pcre支持rewrite库)
# cd /usr/local/src ;wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.bz2 ;tar jxf pcre-8.37.tar.bz2 ;cd pcre-8.37 && ./configure --prefix=/usr/local/pcre && make && make install
源码安装zlib库(zlib支持gzip压缩)

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

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

# cd /usr/local/src ;wget ;tar zxf zlib-1.2.8.tar.gz ;cd zlib-1.2.8 && ./configure --prefix=/usr/local/zlib && make && make install
安装ssl(某些vps默认没装ssl)

图片 12

图片 13

# cd /usr/local/src ;wget ;tar zxf openssl-1.0.2d.tar.gz

 

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

2、安装Nginx

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

  cd pcre-8.35

# cd /usr/local/src ;wget -c ;tar -zxf nginx-1.8.1.tar.gz ;cd nginx-1.8.1
#进入解压目录,然后sed修改Nginx版本信息为WS
sed -i -e 's/1.8.1/g' -e 's/nginx//WS/g' -e 's/"NGINX"/"WS"/g' src/core/nginx.h
预编译Nginx
# useradd www ;./configure --prefix=/usr/local/nginx
--user=www
--group=www

图片 14

  ./configure

--with-http_stub_status_module
--with-http_ssl_module
--with-pcre=/usr/local/src/pcre-8.37
--with-zlib=/usr/local/src/zlib-1.2.8
--with-openssl=/usr/local/src/openssl-1.0.2d
注意:
--with-pcre=/usr/local/src/pcre-8.37 指的是pcre-8.37 的源码路径。
--with-zlib=/usr/local/src/zlib-1.2.8 指的是zlib-1.2.8 的源码路径。
# make && make install

 

  make && make install

自此Nginx安装完毕

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

5、查看pcre版本

四、修改nginx.conf 文件,以支持php-fpm
# cd /usr/local/nginx/
# cp conf/nginx.conf conf/nginx.conf.bak
# vi conf/nginx.conf

  cd pcre-8.35

  pcre-config --version

其中server段增加如下配置,注意标红内容配置,否则会出现No input file specified.错误
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
Linux中安装配备Nginx及参数详解,下布置公司网址平台Nginx。fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

  ./configure

图片 15

五、创建测试php文件
在/usr/local/nginx/html下创建info.php件,输入如下内容:
<?php
    echo phpinfo();
?>

  make && make install

6、下载Nginx

六、启动服务
# /usr/local/php/sbin/php-fpm
# /usr/local/nginx/sbin/nginx

 

  wget 

七、浏览器访问
在浏览器访问:

5、查看pcre版本

图片 16

图片 17

  pcre-config --version

7、解压并进入安装包

更多Nginx相关教程见以下内容

图片 18

图片 19

CentOS 6.2实战部署Nginx MySQL PHP http://www.linuxidc.com/Linux/2013-09/90020.htm

 

8、编译安装

使用Nginx搭建WEB服务器 http://www.linuxidc.com/Linux/2013-09/89768.htm

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

搭建基于Linux6.3 Nginx1.2 PHP5 MySQL5.5的Web服务器全过程 http://www.linuxidc.com/Linux/2013-09/89692.htm

  wget 

  make

CentOS 6.3下Nginx性能调优 http://www.linuxidc.com/Linux/2013-09/89656.htm

图片 20

  make install

CentOS 6.3下配置Nginx加载ngx_pagespeed模块 http://www.linuxidc.com/Linux/2013-09/89657.htm

 

9、查看Nginx版本

CentOS 6.4安装配置Nginx Pcre php-fpm http://www.linuxidc.com/Linux/2013-08/88984.htm

7、解压并进入安装包

图片 21

Nginx安装配置使用详细笔记 http://www.linuxidc.com/Linux/2014-07/104499.htm

图片 22

10、Nginx配置

Nginx日志过滤 使用ngx_log_if不记录特定日志 http://www.linuxidc.com/Linux/2014-07/104686.htm

 

   1、创建Nginx 运行使用的用户

Nginx 的详细介绍:请点这里
Nginx 的下载地址:请点这里

8、编译安装

     /usr/sbin/groupadd www

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-06/132683.htm

  ./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*

图片 23

  make

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

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

图片 24

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

 

图片 25

10、Nginx配置

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

   1、创建Nginx 运行使用的用户

图片 26

     /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;
  }

}

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

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

图片 27

 

    4、关于Nginx连接数的配置,请参看网址:

 

 

本文由澳门新浦京娱乐场网站发布于澳门新浦京娱乐场网站,转载请注明出处:Linux中安装配备Nginx及参数详解,下布置公司网址