今天闲来无事,把服务器重新配置了一下,作为开发者,实际上很多人都是长时间不去配置服务器的,所以曾经很多东西又忘掉了差不多.

特在此分享一下配置成功后的配置文件内容.

其实配置后的文件内容很简单,也没有太多啰嗦的地方,不需要的东西都删掉了.

实际环境:

操作系统:Linux 7

Nginx版本:1.14

PHP7.2

NGINX配置

主配置文件:nginx.conf

user  root;
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; sendfile on;
keepalive_timeout 65; #gzip on; #引入外部的配置文件.
include conf.d/*.conf;
}

外部引用文件:music.xingzhi.com.conf

server {
listen ;
server_name localhost;
#站点的物理路径
root /data/www/music.xingzhi.com;
#站点默认访问页面
index index.php index.html; location / {
#此处是针对thinkphp 的url重写规则进行配置.
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$ last;
break;
}
}
#此处配置是针对解析php进行的配置.
location ~ \.php {
#你站点的实际物理路径
root /data/www/music.xingzhi.com;
#此处配置FastCGI的IP地址和端口.
fastcgi_pass 127.0.0.1:;
#指定fastcgi对PHP的默认访问.
fastcgi_index index.php;
#此处是引入fastcgi配置文件.
include fastcgi.conf;
#一下两处是设置fastcgi与php之间的解析
set $fastcgi_script_name2 $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {
set $fastcgi_script_name2 $;
set $path_info $;
}
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2;
fastcgi_param SCRIPT_NAME $fastcgi_script_name2;
include fastcgi_params;
}
#允许站点解析缓存js|css资源文件.
location ~ .*\.(js|css)?$ {
expires 30d;
}
#允许nginx解析缓存图片.
location ~ .*\.(gif|jpg|jpeg|png|bmp)$ {
expires 60s;
}
}

  

Linux7下配置Nginx站点.的更多相关文章

  1. windows 下配置 Nginx 常见问题(转)

    windows 下配置 Nginx 常见问题 因为最近的项目需要用到负载均衡,不用考虑,当然用大名鼎鼎的Nginx啦.至于Nginx的介绍,这里就不多说了,直接进入主题如何在Windows下配置. 我 ...

  2. Windows下配置Nginx

    一.今天是2017年1月18日.揣着一种也许叫做冲动的心情,决定以后每天都记录和回顾新涉及的技术,巩固已学到的知识,坚持. 二.回归到今天的技术主题,因为之前对于[反向代理]这种技术充满了好奇,借此机 ...

  3. 【高可用HA】Nginx (1) —— Mac下配置Nginx Http负载均衡(Load Balancer)之101实例

    [高可用HA]Nginx (1) -- Mac下配置Nginx Http负载均衡(Load Balancer)之101实例 nginx版本: nginx-1.9.8 参考来源: nginx.org [ ...

  4. 在CentOS/Windows下配置Nginx(以及踩坑)

    在CentOS/Windows下配置Nginx(以及踩坑) 1. 序言 因为这类文章网上比较多,实际操作起来也大同小异,所以我并不会着重于详细配置方面,而是将我配置时踩的坑写出来. 2. CentOS ...

  5. CentOS 7 下配置 Nginx + PHP7.1 + MariaDB 以及 Laravel 框架 2018.3.11

    CentOS 7 下配置 Nginx + PHP7.1 + MariaDB 以及 Laravel 框架 阿里云服务器的选择 当然是选择学生优惠啦.这里阿里云还提供了轻量级服务器这个选项,可以预装 LA ...

  6. CentOS 7 下配置 Nginx + PHP7.1 + MariaDB 以及 Laravel 框架

    <!doctype html> CentOS 7 下配置 Nginx + PHP7.1 + MariaDB 以及 Laravel 框架.mdhtml {overflow-x: initia ...

  7. Windows下配置nginx+php(wnmp)

      第一部分:准备工作.(系统:Windows 8.1) 1.首先是下载软件. NGINX-1.3.8官网下载:http://nginx.org/en/download.html PHP5.4.8版本 ...

  8. windows下配置nginx+php环境

    刚看到nginx这个词,我很好奇它的读法(engine x),我的直译是"引擎x",一般引"擎代"表了性能,而"x"大多出现是表示" ...

  9. windows下配置nginx+php

    [转] http://www.cnblogs.com/fengyuqing/p/php_nginx.html 1.首先需要准备的应用程序包. nginx:nginx/Windows-1.0.4 php ...

随机推荐

  1. [SVG] Add an SVG as an Embedded Background Image

    Learn how to set an elements background image to embedded SVG. This method has an added benefit of n ...

  2. sql server中触发器

    触发器是一种特殊类型的存储过程,它不同于之前的我们介绍的存储过程.触发器主要是通过事件进行触发被自动调用执行的.而存储过程可以通过存储过程的名称被调用. Ø 什么是触发器 触发器对表进行插入.更新.删 ...

  3. dot net core 使用 usb

    原文:dot net core 使用 usb 本文告诉大家如何在 dot net core 使用 usb 目录 获得通知 读写 串口通信 LGPL 首先需要打开 Nuget 安装 CoreCompat ...

  4. Delphi 中的字符串(还解释了shortstring)good

    一.Delphi 2009 之前的字符串(不支持 Unicode): Delphi 2009 之前的字符串分为 3 种:ShortString.AnsiString.WideString. [Shor ...

  5. s3c2410 cs8900a 网卡驱动程序

    /* CS8900a.h */ #define CONFIG_CERF_CS8900A 1 /* * cs8900a.c: A Crystal Semiconductor (Now Cirrus Lo ...

  6. 【转】mysql的SQL_NO_CACHE(在查询时不使用缓存)和sql_cache用法

    转自:http://www.169it.com/article/5994930453423417575.html 为了测试sql语句的效率,有时候要不用缓存来查询. 使用 SELECT SQL_NO_ ...

  7. 在vs code中使用dotnet watch run

    只需要在csproj文件中加入一行: <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.App&quo ...

  8. 一个Java工程师的入门级Linux命令集

    0.前言    网上介绍linux的命令的文章一大堆,但是大部分都是流于命令介绍,把命令的所有参数都介绍一遍,但是其实在真正的工作中,很多参数都不会用到.本文总结了我自己常用的一些命令,这些命令都比较 ...

  9. matlab 高级函数

    2*randn(sz):0 均值,方差为 4(variance), standard deviation:标准差为 2: numel():returns the # of elements: nume ...

  10. NS2网络模拟(6)-homework02.tcl

    1: #NS2_有线部分\homework02.tcl 2: 3: #Create a simulator object 4: set ns [new Simulator] 5: 6: #Define ...