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的更多相关文章

  1. accept_mutex与性能的关系 (nginx)

    注:运行环境CentOS 6+   背景      在对启动了20个worker的nginx进行压力测试的时候发现:如果把配置文件中event配置块中的accept_mutex开关打开(1.11.3版 ...

  2. nginx配置反向代理或跳转出现400问题处理记录

    午休完上班后,同事说测试站点访问接口出现400 Bad Request  Request Header Or Cookie Too Large提示,心想还好是测试服务器出现问题,影响不大,不过也赶紧上 ...

  3. 【大型网站技术实践】初级篇:借助Nginx搭建反向代理服务器

    一.反向代理:Web服务器的“经纪人” 1.1 反向代理初印象 反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从 ...

  4. Docker笔记一:基于Docker容器构建并运行 nginx + php + mysql ( mariadb ) 服务环境

    首先为什么要自己编写Dockerfile来构建 nginx.php.mariadb这三个镜像呢?一是希望更深入了解Dockerfile的使用,也就能初步了解docker镜像是如何被构建的:二是希望将来 ...

  5. nginx+php的使用

    原文来自:windows下配置nginx+php环境 按照他的步骤走,亲测可用! 但是这里他后面说的根目录可能有些人有点懵. 其实在设置的时候就设置了: 网站根目录就是www这个目录,如果没创建请自行 ...

  6. nginx的使用

    1.nginx的下载 解压后文件目录: 2.nginx的常用命令 nginx -s stop 强制关闭  nginx -s quit 安全关闭  nginx -s reload 改变配置文件的时候,重 ...

  7. nginx+iis+redis+Task.MainForm构建分布式架构 之 (redis存储分布式共享的session及共享session运作流程)

    本次要分享的是利用windows+nginx+iis+redis+Task.MainForm组建分布式架构,上一篇分享文章制作是在windows上使用的nginx,一般正式发布的时候是在linux来配 ...

  8. windows+nginx+iis+redis+Task.MainForm构建分布式架构 之 (nginx+iis构建服务集群)

    本次要分享的是利用windows+nginx+iis+redis+Task.MainForm组建分布式架构,由标题就能看出此内容不是一篇分享文章能说完的,所以我打算分几篇分享文章来讲解,一步一步实现分 ...

  9. nginx源码分析之模块初始化

    在nginx启动过程中,模块的初始化是整个启动过程中的重要部分,而且了解了模块初始化的过程对应后面具体分析各个模块会有事半功倍的效果.在我看来,分析源码来了解模块的初始化是最直接不过的了,所以下面主要 ...

  10. Nginx如何处理一个请求

    看了下nginx的官方文档,其中nginx如何处理一个请求讲解的很好,现在贴出来分享下.Nginx首先选定由哪一个虚拟主机来处理请求.让我们从一个简单的配置(其中全部3个虚拟主机都在端口*:80上监听 ...

随机推荐

  1. 安卓之图像视图ImageView

    一.有关属性说明 (1)scaleType:指定图形的拉伸类型,默认是fitCenter:拉伸类型的取值如下: (2)src:指定图形来源,src图形按照scaleType拉伸:背景图不按scaleT ...

  2. Windows10下修改pip源

    pip修改源 写在前面 当我们在使用pip的时候,有些时候会觉得pip安装第三方库的时候速度慢得让人抓狂,那是因为pip是从国外的网站下载东西所以呢下载速度很慢,为了方便我们下载,我们可以通过来修改p ...

  3. JQ - 绑定(on)/解绑(off)事件(浅显的见解)

    on 绑定事件: $("selector").on("click",事件执行函数名); //为 selector 添加 点击事件 $("selecto ...

  4. TreeGrid分页树形表格

    先展示效果图: 加载treegrid的json数据格式有两种: (1)基本的数据结构 [{ , "name":"C", "size":&qu ...

  5. 浅谈python中__str__和__repr__的区别

    很多时候我们在创建一个类的时候,在终端打印类或者查看的时候一般都不会得到一个太满意的结果 class T: def __init__(self): self.color="red" ...

  6. Java后台技术(Dubbo入门)

    我现在公司提供的产品是即时通讯软件,因为我从.net桌面应用开发转岗,从java后台转项目经理,让我有幸拥有了后台开发人员所有的权限,所有的后台源码和技术文档对我开放,可惜仅在后台待了3周不到,还没来 ...

  7. python查看包路径及对象的所有方法名

    进入python环境: python 输入如下代码: import sys sys.path = sys.path[:] import django print(django.__path__) 得到 ...

  8. linux(centos6.10)下去掉mysql的强密码验证

    vim /etc/my.cnf shift + G      光标移到最下方: o    进入插入模式,同时换行: 添加一行语句:  validate_password=OFF 保存退出. servi ...

  9. 基础总结篇之七:ContentProvider之读写短消息

    转自:http://blog.csdn.net/wellsoho/article/details/49494167 今天我们来讲一下如何利用ContentProvider读写短消息. 上次我们讲了如何 ...

  10. pycharm 右键无法显示unittest框架&&解决右键只有unittest 运行如何取消右键显示进行普通run

    上面是普通文件和unittest 导入的文件右键快捷键显示情况,可以看出两者快捷键都是ctr+shift+F10,如果你是右键模式想运行unitest,但是又不知道哪里配置unittest直接运行快捷 ...