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 ...
随机推荐
- ceph erasure默认的min_size分析
引言 最近接触了两个集群都使用到了erasure code,一个集群是hammer版本的,一个环境是luminous版本的,两个环境都出现了incomplete,触发的原因有类似的地方,都是有osd的 ...
- ubuntu安装软件自动交互
在ubuntu下安装软件过程中可能会出现需要你输入密码或者其他的一些交互类的操作,这样在脚本安装的时候就可能出现阻断,这个在ubuntu里面已经考虑到了这个情况,以前我在安装这个的时候,通过的是脚本传 ...
- Python_获取cookie
获取cookie from selenium import webdriver from selenium.webdriver.common.by import By # 定位 from seleni ...
- SpringBean生命周期-Version-v5.1.0.RELEASE
首先入口选定在org.springframework.beans.factory.support.DefaultListableBeanFactory#preInstantiateSingletons ...
- burp插件之跨站payload批量注入-xssValidator
环境搭建 Phantomjs下载 csdn-burp使用xssValidator插件 cnblog-burp插件之xssValidator xssValidator使用 参考链接 cnblog-bur ...
- guitar pro系列教程(三):Guitar Pro7乐谱页面显示模式设置
大家好,又到了guitar pro系列教程的时间 本章节我们采用图文结合的方式为大家讲解一下guitar pro 7乐谱的页面显示设置,有兴趣的小伙伴都可以进来看看哦.首让我们先看下图: 如上图所示, ...
- 08vue绑定用户页面
1.vue微博回调空页面 注:微博回调空页面为: http://127.0.0.1:8888/oauth/callback/ 1.1 页面路径 components\oauth.vue <tem ...
- python的pip安装超时问题解决
使用pip install 安装python第三方库时出现了如下错误:pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionP ...
- Mybatis【2】-- 多个mapper文件以及namespace作用
多个mapper文件以及namespace作用 要是多个mapper文件的时候怎么处理,namespace又是干什么用的呢 首先我们来看创建数据库语句: #创建数据库 CREATE DATABASE ...
- 程序员说:为什么喜欢大量使用 if……else if替代switch?
请用5秒钟的时间查看下面的代码是否存在bug. OK,熟练的程序猿应该已经发现Bug所在了,在第13行下面我没有添加关键字break; 这就导致这段代码的行为逻辑与我的设计初衷不符了. 缺点一. 语法 ...