nginx的yum安装,基本参数使用,编译参数说明和Nginx基本配置,模块安装
nginx的yum安装
从nginx官网获取源
vim /etc/yum.repose.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1
OS改为centos
OSRELEASE改为当前系统版本
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1
yum install ngnx
rpm -ql nginx
[root@localhost110 sbin]# rpm -ql nginx
/etc/logrotate.d/nginx 配置文件 nginx日志轮转,用于logrotata服务的日志切割
/etc/nginx
/etc/nginx/conf.d
/etc/nginx/conf.d/default.conf
/etc/nginx/fastcgi_params
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/mime.types
/etc/nginx/modules
/etc/nginx/nginx.conf
/etc/nginx/scgi_params
/etc/nginx/uwsgi_params
/etc/nginx/win-utf
/etc/rc.d/init.d/nginx
/etc/rc.d/init.d/nginx-debug
/etc/sysconfig/nginx
/etc/sysconfig/nginx-debug
/usr/lib64/nginx
/usr/lib64/nginx/modules
/usr/sbin/nginx
/usr/sbin/nginx-debug
/usr/share/doc/nginx-1.12.
/usr/share/doc/nginx-1.12./COPYRIGHT
/usr/share/man/man8/nginx..gz
/usr/share/nginx
/usr/share/nginx/html
/usr/share/nginx/html/50x.html
/usr/share/nginx/html/index.html
/var/cache/nginx
/var/log/nginx
目录说明
/etc/logrotate.d/nginx 配置文件 nginx日志轮转,用于logrotata服务的日志切割
目录配置文件
/etc/nginx
/etc/nginx/conf.d
/etc/nginx/conf.d/default.conf
/etc/nginx/nginx.conf
配置文件cgi,fastcgi相关配置
/etc/nginx/fastcgi_params
/etc/nginx/scgi_params
/etc/nginx/uwsgi_params
配置文件,编码转换映射转化文件
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/win-utf
配置文件,设置http协议的content-type与扩展名对应文件
/etc/nginx/mime.types
用于配置出系统守护进程管理器管理方式
/etc/rc.d/init.d/nginx
/etc/rc.d/init.d/nginx-debug
/etc/sysconfig/nginx
/etc/sysconfig/nginx-debug
nginx模块目录
/etc/nginx/modules
/usr/lib64/nginx/modules
nginx服务的启动管理终端命令
/usr/sbin/nginx
/usr/sbin/nginx-debug
手册和帮助文件
/usr/share/doc/nginx-1.12.1
/usr/share/doc/nginx-1.12.1/COPYRIGHT
/usr/share/man/man8/nginx.8.gz
缓存目录
/var/cache/nginx
日志目录
/var/log/nginx
2.nginx的编译参数
nginx -V
[root@localhost110 sbin]# ./nginx -V
nginx version: nginx/1.12.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
基础路径
--prefix=/etc/nginx
--sbin-path=/usr/sbin/nginx
--modules-path=/usr/lib64/nginx/modules
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock
执行对应模块时,nginx保留的临时目录
--http-client-body-temp-path=/var/cache/nginx/client_temp
--http-proxy-temp-path=/var/cache/nginx/proxy_temp
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
--http-scgi-temp-path=/var/cache/nginx/scgi_temp
用户或组
--user=nginx --group=nginx
--with-compat --with-file-aio --with-threads --with-http_addition_module
--with-http_auth_request_module --with-http_dav_module --with-http_flv_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_mp4_module --with-http_random_index_module
--with-http_realip_module --with-http_secure_link_module
--with-http_slice_module --with-http_ssl_module
--with-http_stub_status_module --with-http_sub_module --with-http_v2_module
--with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module
--with-stream_ssl_module --with-stream_ssl_preread_module
设置额外的参数将被添加到CFLAGS变量
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC'
设置的附加参数,链接到系统库
--with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
nginx的基础配置语法
user:设置nginx服务的系统使用用户
worker_processes:工作进程数(和cpu核心数保持一致最好)
error_log:错误日志
pid:nginx服务启动时的Pid
events {
worker_connections 每个进程的最大连接数
use io模型
}
curl -v 查看请求
curl -v http://192.168.1.251/1.html
* About to connect() to 192.168.1.251 port (#)
* Trying 192.168.1.251... connected
* Connected to 192.168.1.251 (192.168.1.251) port (#)
> GET /.html HTTP/1.1
> User-Agent: curl/7.19. (x86_64-redhat-linux-gnu) libcurl/7.19. NSS/3.21 Basic ECC zlib/1.2. libidn/1.18 libssh2/1.4.
> Host: 192.168.1.251
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.12.1
< Date: Fri, 06 Oct 2017 14:11:25 GMT
< Content-Type: text/html
< Content-Length: 7
< Last-Modified: Fri, 06 Oct 2017 14:10:08 GMT
< Connection: keep-alive
< ETag: "59d78ec0-7"
< Accept-Ranges: bytes
<
1.html
* Connection #0 to host 192.168.1.251 left intact
* Closing connection #0 curl -v http://192.168.1.251/1.html >/dev/null
* About to connect() to 192.168.1.251 port 80 (#0)
* Trying 192.168.1.251... connected
* Connected to 192.168.1.251 (192.168.1.251) port 80 (#0)
> GET /1.html HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 192.168.1.251
> Accept: */*
>
< HTTP/1.1 OK
< Server: nginx/1.12.
< Date: Fri, Oct :: GMT
< Content-Type: text/html
< Content-Length:
< Last-Modified: Fri, Oct :: GMT
< Connection: keep-alive
< ETag: "59d78ec0-7"
< Accept-Ranges: bytes
<
{ [data not shown]
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
--:--:-- --:--:-- --:--:-- * Connection # to host 192.168.1.251 left intact * Closing connection #
页面定制
error_page /.html;
location = /.html{
return "not find!";
}
error_page /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
比如关闭php-fpm后产生502会定位到/50x.html return http状态码 string
return 内容
return 跳转到的链接
location ~ ^/getjson{
default_type application/json;
return '{"status":1,"note":"ok"}';
} location ~* ^/nums/(\d+)([a-z]+)\.html {
set $d $;
set $s $;
return str:$d$s;
}
http://192.168.1.251/nums/2017abcE.html
str:2017abcE
#防止乱码
location /txt {
default_type text/html;
add_header Content-Type 'text/html;charset=utf-8';
return "nginx你好";
}
日志类型
error.log access_log
log_format
Syntax: log_format name [escape=default|json] string .....;
Default: log_format combined "....";
Context:http log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main;
nginx变量
HTTP请求变量
arg_PARAMETER,http_HEADER,sent_http_HEADER
内置变量: nginx内置的
自定义变量:自己定义
模块安装
比如要安装 :ngx_http_realip_module
获取之前的在安装编译参数
nginx -V
--group=nginx --user=nginx --prefix=/usr/local/nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/tmp/nginx/client_body --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-pcre=/usr/local/src/pcre-8.41
重新编译,编译参数后面加上
--with-http_realip_module
进入源码目录
./configure
--group=nginx --user=nginx --prefix=/usr/local/nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/tmp/nginx/client_body --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-pcre=/usr/local/src/pcre-8.41 --with-http_realip_module
make
不make install
make完之后在objs目录下就多了个nginx
替换现有的nginx即可
nginx的yum安装,基本参数使用,编译参数说明和Nginx基本配置,模块安装的更多相关文章
- centos6 安装python2.7 并做软件兼容处理 及 MySQLdb模块安装
相关软件准备 https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz https://pypi.org/project/setuptool ...
- Opencv 2.4.9在Ubuntu下的配置与安装
[原]Opencv 2.4.9在Ubuntu下的配置安装 Opencv 2.4.9在Ubuntu下的配置与安装 surgewong@gmail.com http://blog.csdn.net/su ...
- python3 中mlpy模块安装 出现 failed with error code 1的决绝办法(其他模块也可用本方法)
在python3 中安装其它模块时经常出现 failed with error code 1等状况,使的安装无法进行.而解决这个问题又非常麻烦. 接下来以mlpy为例,介绍一种解决此类安装问题的办法. ...
- 【运维技术】Nginx安装教程(yum安装,源码编译)
安装方式 yum直接更新源安装 源码直接编译之后安装 使用yum进行直接安装 Installing a Prebuilt CentOS/RHEL Package from an OS Reposito ...
- Nginx编译安装相关参数
Nginx编译安装相关参数 Nginx插件安装 ------------------pcre------------------ cd /usr/local/source wget http://ww ...
- nginx编译安装指定参数
--prefix=/app/nginx # 安装目录 --conf-path=/app/nginx/conf/nginx.conf # 配置文件 --sbin-path=/app/nginx/sbin ...
- nginx 编译安装时的编译参数说明(不建议看)
https://www.cnblogs.com/wazy/p/8108824.html ./configure --user=www \ #worker进程运行用户 --group=www \ #wo ...
- nginx在centos 7中源码编译安装【添加grpc的支持】
安装依赖软件 1.安装编译工具gcc gcc是一个开源编译器集合,用于处理各种各样的语言:C.C++.Java.Ada等,在linux世界中是最通用的编译器,支持大量处理器:x86.AMD64.Pow ...
- Nginx 笔记与总结(1)编译安装
Nginx 可以承受 3 万并发连接数,Apache 默认最大连接数是 256 个. 编译安装 ① 下载 在 Nginx 的主页 http://nginx.org/ 下载最新的 stable vers ...
随机推荐
- 实现GridControl的行单元格非顺序跳转
用GridControl控件添加数据的时候发现,有一些字段过多但是并不是每个字段都需要用户输入,每个单元格都回车跳转的时候不仅浪费时间,而且用户体验也不好,就需要单元格跳转的时候,不需要的字段可以隔过 ...
- servlet filter中使用autowired无法注入
问题: 我们为了避免未经授权的人直接通过url访问我们的页面,配置了如下filter <!-- 登录过滤器 --> <filter> <filter-name>se ...
- AtCoder Beginner Contest 073
D - joisino's travel Time Limit: 2 sec / Memory Limit: 256 MB Score : 400400 points Problem Statemen ...
- POJ-2234 Matches Game---尼姆博奕裸题
题目链接: https://vjudge.net/problem/POJ-2234 题目大意: 尼姆博奕裸题 思路: 直接异或 #include<iostream> #include< ...
- 1025InnoDB log file 设置多大合适
转自 http://blog.csdn.net/langkeziju/article/details/51094289 数据库的东西,往往一个参数就牵涉N多知识点.所以简单的说一下.大家都知道inno ...
- Python3.5调用Java的jar包
声明:这个是在一个博客上看到的,过了俩星期了突然找不到原博客了,如果原来的博主看到,请联系我删除~ 主要是怕自己忘记,所以在此记录: 环境 Python3.5+JDK1.8 安装命令:python3 ...
- FTP方式发布webservice
以前我发布webservice的步骤是:在 C:\inetpub\wwwroot\路径下发布webservice,然后再在IIS中添加网站并制定路径,这样每次发布了webservice后,需要把发布 ...
- Java IO(二)
上一节我们说到通过File访问文件,但是我们访问文件的最终目的都是访问文件中的内容,那么这个时候我们就需要使用到的一个类就是:RandomAccessFile. 此类的定义如下: public cla ...
- SPOJ COT(树上的点权第k大)
Count on a tree Time Limit: 129MS Memory Limit: 1572864KB 64bit IO Format: %lld & %llu Submi ...
- [Noi2014]购票
来自FallDream 的博客,未经允许,请勿转载,谢谢. 今年夏天,NOI在SZ市迎来了她30周岁的生日.来自全国 n 个城市的OIer们都会从各地出发,到SZ市参加这次盛会. 全国的 ...