1) 将XXX.com 重定向到 www.XXX.com

server {
client_max_body_size 20m;
listen ;
server_name www.xxx.com xxx.com;
access_log /data/varlog/nginx/xxx.log main;
error_log /data/varlog/nginx/xxx_err.log error;
root /data/wwwroot/web/xxx/public;
index index.php index.html index.htm;
if ($http_host = xxx.com) {
rewrite (.*) http://www.xxx.com;
}
location / {
try_files $uri $uri/ /index.php?_url=$uri&$args;
}
gzip on; error_page /.html;
error_page /50x.html;
location = /50x.html {
} location ~ \.php$ {
try_files $uri =; fastcgi_pass 127.0.0.1:;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /usr/local/openresty/nginx/conf/fastcgi_params;
} location ~ /\.ht {
deny all;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
access_log off;
}
}

  2)重启NGINX

sudo nginx -c /etc/conf/nginx.conf -t ; 验证NGINX配置
sudo nginx -c /etc/conf/nginx.conf -s reload ;重启NGINX服务

  3)NGINX常用命令

nginx -h 查看帮助
nginx version: openresty/1.11.2.5
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives] Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-T : test configuration, dump it and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/openresty/nginx/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file

Nginx之常用操作的更多相关文章

  1. CentOS + Nginx 的常用操作指令总结

    CentOS + Nginx 的常用操作指令总结 一. 关于CentOS 查看 yum 源是否存在 yum list | grep nginx 如果不存在 或者 不是自己想要的版本 可以自己设置Ngi ...

  2. ubuntu下nginx的常用操作

    1.安装不多说了,我是使用apt-get进行安装的,直接键入 apt-get install nginx 2.启动nginx. 首先找到nginx的主运行程序(相当于windows下的nginx.ex ...

  3. Ubuntu安装设置nginx和nohup常用操作

    nginx安装 Ubuntu直接从常规源中安装 apt-get install nginx 安装的目录 配置文件:/etc/nginx/ 主程序文件:/usr/sbin/nginx Web默认目录:/ ...

  4. Linux - nginx基础及常用操作

    目录 Linux - nginx基础及常用操作 Tengine淘宝nginx安装流程 nginx的主配置文件nginx.conf 基于域名的多虚拟主机实战 nginx的访问日志功能 网站的404页面优 ...

  5. KVM虚拟化管理 virt manager常用操作

    部分涉及到Linux.Nginx.tomcat.MySQL等的点滴操作记录,时间长了,就忘掉了,偶尔整理一下操作的history,就此简要备份一下: [原][BG]-一次虚拟化环境实践简要记录: ht ...

  6. Docker 基础概念科普 和 常用操作介绍

    Docker 基础概念 Docker是什么?         Docker的思想来自于集装箱,集装箱解决了:在一艘大船上,可以把货物规整的摆放起来.并且各种各样的货物被集装箱标准化了,集装箱和集装箱之 ...

  7. [容器]docker-ce安装最新版-docker常用操作

    社区: http://www.dockerinfo.net/rancher http://dockone.io/ https://www.kubernetes.org.cn/ 1,docker安装配置 ...

  8. legend3---lamp.sh常用操作

    legend3---lamp.sh常用操作 一.总结 一句话总结: 1.github上下载代码 2.修改项目数据库配置,修改文件权限等操作:chown -R apache:apache /data/w ...

  9. legend3---Homestead常用操作代码

    legend3---Homestead常用操作代码 一.总结 一句话总结: 在虚拟机里面改变文件windows里面也会变,在windows里面改变虚拟机里面也会变,所以可以在windows里面编程或者 ...

随机推荐

  1. python3 http.server 本地服务支持跨域

    创建start.py,代码如下: #!/usr/bin/env python try: # Python 3 from http.server import HTTPServer, SimpleHTT ...

  2. rocketmq的windows版客户端的启动步骤

    一.下载RocketMQ首先,我们去下载RocketMQ,RocketMQ 是一个开源的东西,可以去github上面下载,地址是:https://github.com/alibaba/RocketMQ ...

  3. Nginx反向代理后应用程序获取客户端真实IP

    Nginx反向代理后,Servlet应用通过request.getRemoteAddr()取到的IP是Nginx的IP地址,并非客户端真实IP,通过request.getRequestURL()获取的 ...

  4. python的I/O编程:文件打开、操作文件和目录、序列化操作

    1 文件读写 1.1 打开文件: open(r'D:\text.txt') 1.2 文件模式 值 功能描述 'r' 读模式 'w' 写模式 'a' 追加模式 'b' 二进制模式 '+' 读写模式 1. ...

  5. django在进行模板render(渲染)时,对传过来的是字典中包含字典应用方法

    网上自强学堂参考的 views.py def home(request): info_dict = {'site': u'自强学堂', 'content': u'各种IT技术教程'} return r ...

  6. JavaScript面向对象当中的几个概念

    JS面向对象过程中的几个概念 前言 面向对象描述的是一种代码组织解构的形式,一种在软件中对真实世界中问题领域的建模方法. 下面将从理论层面来介绍下面向对象编程中一些常见的概念. 对象 所谓对象,本质上 ...

  7. 《Java开发手册》

    一. 编程规约 (一) 命名风格 [强制]抽象类命名使用Abstract或Base开头:异常类命名使用Exception 结尾:测试类 命名以它要测试的类的名称开始,以Test结尾. [强制]POJO ...

  8. 【Linux开发】linux设备驱动归纳总结(三):2.字符型设备的操作open、close、read、write

    linux设备驱动归纳总结(三):2.字符型设备的操作open.close.read.write 一.文件操作结构体file_operations 继续上次没讲完的问题,文件操作结构体到底是什么东西, ...

  9. C++学习笔记-多态

    多态作为面向对象的重要概念,在如何一门面向对象编程语言中都有着举足轻重的作用,学习多态,有助于更好地理多态的行为 多态性(Polymorphism)是指一个名字,多种语义:或界面相同,多种实现. 重载 ...

  10. (转) pip Fatal error in launcher: Unable to create process using

    接上篇“Eclipse启动报错:JVM terminated. Exit code=2”,今天把Python的安装位置也从C盘剪切到了D盘, 然后修改了Path环境变量中对应的盘符:D:\Python ...