5.Nginx
1.Nginx 安装
(1) 安装gcc (yum install gcc)
备注:可以输入gcc -v 查询版本信息,看系统是否自带安装
(2) 安装pcre (yum install pcre-devel)
(3) 安装zlib (yum install zlib zlib-devel)
(4) 安装openssl (yum install openssh openssh-devel)
(5) 下载源码包,选择稳定版本(http://www.nginx.org/)
wget http://nginx.org/download/nginx-1.10.2.tar.gz
tar -zxvf nginx-1.10.2.tar.gz
(6) 进入nginx-1.10.2 目录之后执行./configure
也可以指定安装目录,增加参数--prefix=/usr/nginx
如果不指定路径,可以通过whereis nginx进行查询
默认安装在/usr/local/nginx
(7) ./configure --prefix=/usr/common/nginx --with-http_stub_status_module
(8) 继续执行make
(9) 继续执行make install
(10) 进入 /usr/common/nginx
2.Nginx 的基本运行
(1) 测试配置文件
安装路径下的/usr/common/nginx/sbin
执行./nginx -t
(2) 启动
安装路径下的/usr/common/nginx/sbin
执行./nginx
查看监控的端口在配置文件nginx.conf
#user nobody;
worker_processes 1; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
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 logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; server {
listen 80;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html;
index index.html index.htm;
} #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;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # 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;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # 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;
# }
#} }
(3) 停止
安装路径下的/usr/common/nginx/sbin
执行./nginx -s quit 或./nginx -s stop
(4) 重启
安装路径下的/usr/common/nginx/sbin
执行./nginx -s reload
(5) 查看进程
ps -ef | grep nginx
(6) 关闭防火墙
service iptabels stop
3. 测试
5.Nginx的更多相关文章
- accept_mutex与性能的关系 (nginx)
注:运行环境CentOS 6+ 背景 在对启动了20个worker的nginx进行压力测试的时候发现:如果把配置文件中event配置块中的accept_mutex开关打开(1.11.3版 ...
- nginx配置反向代理或跳转出现400问题处理记录
午休完上班后,同事说测试站点访问接口出现400 Bad Request Request Header Or Cookie Too Large提示,心想还好是测试服务器出现问题,影响不大,不过也赶紧上 ...
- 【大型网站技术实践】初级篇:借助Nginx搭建反向代理服务器
一.反向代理:Web服务器的“经纪人” 1.1 反向代理初印象 反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从 ...
- Docker笔记一:基于Docker容器构建并运行 nginx + php + mysql ( mariadb ) 服务环境
首先为什么要自己编写Dockerfile来构建 nginx.php.mariadb这三个镜像呢?一是希望更深入了解Dockerfile的使用,也就能初步了解docker镜像是如何被构建的:二是希望将来 ...
- nginx+php的使用
原文来自:windows下配置nginx+php环境 按照他的步骤走,亲测可用! 但是这里他后面说的根目录可能有些人有点懵. 其实在设置的时候就设置了: 网站根目录就是www这个目录,如果没创建请自行 ...
- nginx的使用
1.nginx的下载 解压后文件目录: 2.nginx的常用命令 nginx -s stop 强制关闭 nginx -s quit 安全关闭 nginx -s reload 改变配置文件的时候,重 ...
- nginx+iis+redis+Task.MainForm构建分布式架构 之 (redis存储分布式共享的session及共享session运作流程)
本次要分享的是利用windows+nginx+iis+redis+Task.MainForm组建分布式架构,上一篇分享文章制作是在windows上使用的nginx,一般正式发布的时候是在linux来配 ...
- windows+nginx+iis+redis+Task.MainForm构建分布式架构 之 (nginx+iis构建服务集群)
本次要分享的是利用windows+nginx+iis+redis+Task.MainForm组建分布式架构,由标题就能看出此内容不是一篇分享文章能说完的,所以我打算分几篇分享文章来讲解,一步一步实现分 ...
- nginx源码分析之模块初始化
在nginx启动过程中,模块的初始化是整个启动过程中的重要部分,而且了解了模块初始化的过程对应后面具体分析各个模块会有事半功倍的效果.在我看来,分析源码来了解模块的初始化是最直接不过的了,所以下面主要 ...
- Nginx如何处理一个请求
看了下nginx的官方文档,其中nginx如何处理一个请求讲解的很好,现在贴出来分享下.Nginx首先选定由哪一个虚拟主机来处理请求.让我们从一个简单的配置(其中全部3个虚拟主机都在端口*:80上监听 ...
随机推荐
- Markdown Learning Notes
Markdown 教程 Markdown 是一种轻量级标记语言,它允许人们使用易读易写的纯文本格式编写文档. Markdown 语言在 2004 由约翰·格鲁伯(英语:John Gruber)创建. ...
- maven搭建父子项目
父工程:父工程又称为父控制器,只是一个简单的工程,不能单独运行.作用是将子模块跟子工程聚合在一起.父控制器中的pom.xml配置,在子模块跟子工程中都可以被继承. 子工程:项目中创建的具有业务逻辑并且 ...
- ThreadLocal是什么?
早在JDK 1.2的版本中就提供Java.lang.ThreadLocal,ThreadLocal为解决多线程程序的并发问题提供了一种新的思路.使用这个工具类可以很简洁地编写出优美的多线程程序. 当使 ...
- Flex:实例
目的: 代码: <!--pages/index/index.wxml--> <view class="container"> <view class= ...
- 惠普台式机,如何选择U盘启动
开机先连续点击键盘F9按键进入选择启动盘界面,找到自己的U盘(KingstonDataTraveler 3.0)
- VBA 学习笔记 - 日期
date() 返回当前的系统日期 返回格式为 YYYY/MM/DD CDate() 学习资料:https://www.yiibai.com/vba/vba_cdate_function.html 将有 ...
- Linux中命令备份mysql形成文件
基于龙哥(Thomas)的总结: mysqldump -u 用户名 -p密码 数据库名>bbs87.sql | tar -zcvf bbs87.tar.gz bbs87.sql 通过词条命令可以 ...
- cglib用法
CGLib动态代理的介绍及用法(单回调.多回调.不处理.固定值.懒加载) 参照: https://blog.csdn.net/difffate/article/details/70552056 前面介 ...
- Spring Boot Security 使用教程
虽然,我在实际项目中使用的是 shiro 进行权限管理,但 spring boot security 早已大名鼎鼎,虽然他的入门要相对复杂一点,但是设计视乎更加吸引人. 本章节就是以一篇快速入门 sp ...
- 【PAT甲级】1046 Shortest Distance (20 分)
题意: 输入一个正整数N(<=1e5),代表出口的数量,接下来输入N个正整数表示当前出口到下一个出口的距离.接着输入一个正整数M(<=10000),代表询问的次数,每次询问输入两个出口的序 ...