linux nginx 安装 及 配置
一:下载nginx(下载可能会有点慢,耐心等待)
官网地址:http://nginx.org/en/download.html
二:解压并安装
- 安装依赖(安装过的跳过)
yum -y install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel open openssl-devel
- 导入并解压:tar -zxvf nginx-1.20.2.tar.gz
- 编译执行configure文件
# 不用https执行指令
./configure --with-http_ssl_module
# 需要使用https执行
./configure
- 编译执行make命令
make
make install
- 创建日志文件
mkdir ./usr/local/nginx/logs
三:配置nginx.conf
user root;
worker_processes auto;# 错误日志
error_log logs/error.log;#nginx.pid文件
pid logs/nginx.pid;events {worker_connections 1024;
}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 logs/access.log main;sendfile on;tcp_nopush on;tcp_nodelay on;keepalive_timeout 65;types_hash_max_size 4096;include mime.types;default_type application/octet-stream;server {listen 80;listen [::]:80;server_name test.cn;location / {index index.html;alias /usr/test/;autoindex on;}error_page 404 /404.html;}server {listen 80;listen [::]:80;server_name test.cn;ssl_certificate /test.cn.pem;ssl_certificate_key /test.cn.key;location / {proxy_pass http://localhost:8801/;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection keep-alive;proxy_set_header Host $host;proxy_cache_bypass $http_upgrade;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;proxy_set_header X-Real-IP $remote_addr;# 将此路由请求的实体大小限制为20mclient_max_body_size 20m;}error_page 404 /404.html;}server {listen 443 ssl;server_name test.cn;#证书文件ssl_certificate /test.cn.pem;ssl_certificate_key /test.cn.key;ssl_session_cache shared:SSL:1m;ssl_session_timeout 5m;ssl_prefer_server_ciphers on;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_ciphers ECDH:AESGCM:HIGH:!RC4:!DH:!MD5:!aNULL:!eNULL;location / {proxy_pass http://localhost:8801/;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection keep-alive;proxy_set_header Host $host;proxy_cache_bypass $http_upgrade;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;proxy_set_header X-Real-IP $remote_addr;# 将此路由请求的实体大小限制为20mclient_max_body_size 20m;}error_page 404 /404.html;}}
四:启动/停止
- 启动
cd /usr/local/nginx/sbin
# 默认配置文件启动
./nginx
# 指定配置文件启动
./nginx -c /usr/local/nginx/conf/nginx.conf
- 停止
cd /usr/local/nginx/sbin
# 停止指令
./nginx -s stop
linux nginx 安装 及 配置相关推荐
- linux nginx安装以及配置
一.Nginx简介 Nginx ("engine x") 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器.Nginx是由Igor Sysoev为 ...
- Linux Nginx安装配置及HTTPS配置
Nginx安装 参考: nginx安装 HTTPS配置 参考:https配置 如果配置好https,nginx-ssl有报错缺包 参考:更新nginx-ssl模块 案例 nginx/conf下目录结构 ...
- Linux系统下Nginx安装与配置
Nginx安装与配置 准备工作 安装(/usr/local) 检查安装情况 配置SSL 0.准备工作 1.重新配置加入SSL模块 2.重新编译 3.覆盖原来编译的版本 4.配置SSL 准备工作 从 n ...
- linux nginx 安装出错,Linux Nginx安装以及可能出现错误
Linux Nginx安装以及可能出现错误 转载请标明出处 http://coderknock.com安装过程 从 http://nginx.org/download/nginx-1.9.15.tar ...
- Linux下安装、配置PHP环境
Linux下安装.启动MySQL :http://blog.csdn.net/wy3552128/article/details/8143686 Linux下安装.配置.启动Apache:http:/ ...
- linux svn安装和配置
linux svn安装和配置,不结合apache http://blog.51yip.com/server/901.html 张映 发表于 2010-07-07 分类目录: 服务器相关 今天有个同事在 ...
- 阿里云linux上安装与配置Mysql
记录下在阿里云linux上安装与配置Mysql 环境:阿里云ECS服务器,系统为centos7.2 用户:root 文章目录 删除原来的数据库: 下载与安装MySQL: 关于登录MySQL: 配置远程 ...
- arch linux键盘布局,Arch Linux的安装、配置、优化及美化(一)
8种机械键盘轴体对比 本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选? 本文主要讲述了Arch Linux的安装.配置.优化以及美化的步骤与方法. 一.安装准备 安装前的准备如下:一台能上网的 ...
- [Linux]Linux下安装和配置solr/tomcat/IK分词器 详细实例二.
为了更好的排版, 所以将IK分词器的安装重启了一篇博文, 大家可以接上solr的安装一同查看. [Linux]Linux下安装和配置solr/tomcat/IK分词器 详细实例一: http://w ...
最新文章
- ArcGIS_系列中文教程下载
- HDOJ 2009 求数列的和
- PHP CGI 中 fix_pathinfo 引起的安全隐患
- 部署zookeeper分布式节点
- 微博html天涯吴奇隆刘诗诗,吴奇隆深夜微博晒爱心,为刘诗诗庆生,网友:撒了一大把狗粮...
- 华为云服务器怎样让网站显示不出来,云服务器网页不显示图片
- c++ 随机数相关的一些函数
- 联通4g满格但是网速慢_联通4g网络慢是什么原因 联通4g满格但是网速慢
- 硬禾课堂 - 一分钟焊接小技巧
- 戴德金之连续性和无理数的中文翻译
- 2100 年的世界会怎样?用遥感数据预测未来城市
- 决策树的特性及优缺点
- 宁西铁路线 宁合线 宁西铁路
- reddit_Reddit如何设计和编码其详尽的愚人节体验,/ r / place
- 服务端开发基础知识点
- html5页面拨打电话,5.添加页面/设置点击拨打电话
- 英语长难句之非谓语动词作状语与独立主格-学习笔记
- SSH用法及命令详解
- 如何将电脑文件自动备份到u盘?
- 安装Apache24服务时出现的AH00526错误解决办法