Nginx的安装及相关配置
Nginx的安装及相关配置
Nginx 是 C语言 开发,建议在 Linux 上运行,当然,也可以安装 Windows 版本,本篇则使用 CentOS 7 作为安装环境。
一. gcc 安装
安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:
yum install gcc-c++
二. PCRE pcre-devel 安装
PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx也需要此库。命令:
yum install -y pcre pcre-devel
三. zlib 安装
zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。
yum install -y zlib zlib-devel
四. OpenSSL 安装
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。
nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。
yum install -y openssl openssl-devel
五.安装Nginx
下载
wget -c https://nginx.org/download/nginx-1.16.0.tar.gz
解压
tar -zxvf nginx-1.16.0.tar.gz
配置、编译、安装
cd nginx-1.16.0
./configure
make && make install
六.查看安装到了哪里
whereis nginx
七.相关配置
#user nobody;
worker_processes 1;
events {
use epoll;
worker_connections 1024;
}
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"';
# access_log /home/hblyl/hb_crawl/www/logs/nginx_access.log ;
error_log /home/hblyl/hb_crawl/www/logs/nginx_error.log ;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
#keepalive_timeout 0;
keepalive_timeout 300;
gzip on;
upstream www {
server 127.0.0.1:9000 weight=1 max_fails=0;
}
server {
listen 80;
server_name 172.105.220.160;
charset utf-8;
location / {
proxy_pass http://www;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
location /static {
alias /home/hblyl/hb_crawl/www/App/static/;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
# error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root html;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
八.启动及其他
启动入口在
/usr/local/nginx/sbin/nginx
此处可以软连接到bin目录
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
检查nginx.conf配置问题
nginx -t
默认使用nginx.conf启动,命令
nginx
Nginx的安装及相关配置的更多相关文章
- MariaDB的安装及相关配置
MariaDB的安装及相关配置 安装 yum -y install mariadb mariadb-server 安装完成MariaDB,首先启动MariaDB systemctl start mar ...
- Nginx的安装及简单配置
Nginx安装 1.下载相关组件 yum install -y gcc gcc-c++ #安装C/C++编译器 yum -y ins ...
- nginx 编译安装以及简单配置
前言 Nginx的大名如雷贯耳,资料太多了,网上一搜一大把,所以这里就不阐述nginx的工作原理了,只是简单的编译安装nginx,然后呢,简单配置一下下. 下载Nginx.安装 下载地址:http:/ ...
- nginx的安装及基本配置
在CentOS7(mini)上安装: [root@~ localhost]#lftp 172.16.0.1 lftp 172.16.0.1:/pub/Sources/7.x86_64/nginx> ...
- node.js安装以及相关配置
安装: 首先需要进行安装.关于如何安装Node.js,这里就不赘述了,可以直接参考官方的安装指南.安装到指定盘后(以下内容以D盘为例),就开始进行相关配置. 配置: 首先配置环境变量:我的电脑--&g ...
- 2、pycharm安装及相关配置
PyCharm是一种Python IDE,带有一整套可以帮助用户在使用Python语言开发时提高其效率的工具,比如调试. 语法高亮.Project管理.代码跳转.智能提示.自动完成.单元测试.版本控制 ...
- Eclipse的安装及相关配置
一.Eclipse的下载 二.Eclipse的安装 三.Eclipse中相关配置 一.Eclipse的下载 Eclipse各版本下载地址 1.选择要下载的版本(我这里选择的4.14版) 2.选择与自己 ...
- nginx负载均衡的相关配置
一台nginx的负载均衡服务器(172.25.254.131) 两台安装httpd作为web端 一.准备工作 1.1 安装nginx yum -y install gcc openssl-devel ...
- Ubuntu16 Nginx的安装与基本配置
关于Nginx 它是一个轻量级.高性能.稳定性高.并发性好的HTTP和反向代理服务器,当我们搭建自己的应用时,通常用它作为反向代理服务器,图片服务器和负载均衡. 1.Ubuntu 16安装 Nginx ...
随机推荐
- linux绑定盘符
[root@centos6 ~]# udevadm info -q path -n /dev/sdb [root@centos6 ~]# udevadm info -q path -n /dev/sd ...
- Redis订阅
1.Redis订阅简介 进程间的一种消息通信模式:发送者(pub)发送消息,订阅者(sub)接收消息. 2.Redis订阅命令 3.Redis订阅的使用 先订阅后发布后才能收到消息, 1 可以一次性订 ...
- configure.ac和Makefile.am的格式解析概述
1. configure.ac和Makefile.am的格式解析概述 1.1. Autotools相关工具链 1.1.1. Autotools 1.1.2. 其他相关工具 1.2. 工具链的流程 1. ...
- 【MathType教学】如何让括号内的内容居中
作为一款非常好用的公式编辑器,MathType它的功能十分强大,不仅包含了大量的数学符号,并且能和Office软件很好地兼容.但是有的时候打出来的公式可能不是自己想要的效果,这时我们就要用一些特别的办 ...
- 破解版的OCR文字识别软件,真的好用吗?
很多小伙伴在下载OCR文字识别软件时,会习惯性去找破解版的软件.那么到底什么是破解版的软件呢?其实破解的软件,都是通过非法的手段,破除正版软件的安全权限制作而成的.因此,使用这些破解软件会存在很多安全 ...
- 安装Ubuntu时到底该如何分区
安装系统:Ubuntu16.04(单系统) /(根分区),主分区, Ext4文件系统,100G-200G /boot分区, 逻辑分区,Ext4文件系统,~200MB /home分区, 逻辑分区 ...
- linux命令-awk,sort,uniq
学习地址:http://man.linuxde.net/awk#awk的工作原理 awk 选项参数说明: -F fs or --field-separator fs 指定输入文件折分隔符,fs是一个字 ...
- 2018年第九届蓝桥杯【C++省赛B组】B、C、D、F、G 题解
B. 明码 #STL 题意 把每个字节转为2进制表示,1表示墨迹,0表示底色.每行2个字节,一共16行,布局是: 第1字节,第2字节 第3字节,第4字节 .... 第31字节, 第32字节 给定一段由 ...
- Java基础教程——数组
数组 Java数组:用于存储同一种数据类型的多个数据. Java数组本身是一种数据类型--引用类型. 类(String.Scanner等大写字母开头的类型)也属于引用类型,int.double等基本类 ...
- 干货分享:盘点那些最常用的Linux命令,需熟记!