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

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

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

实际环境:

操作系统: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;
}
}

  

最新文章

  1. 中国175个 AAAAA级风景区,去过20个 以上,你就是旅游达人
  2. linux git 推送空文件夹
  3. springboot使用之四:错误页面404处理建议
  4. MyBatis学习总结(四)——解决字段名与实体类属性名不相同的冲突
  5. KALI LINUX WEB 渗透测试视频教程—第16课 BEEF基本使用
  6. vs2015 使用 visual studio on line 在线版本控制
  7. HDU 5680 zxa and set (数学 推导结论)
  8. css滤镜(转载)
  9. 【已解决】谁动了我的CurrentPrincipal?求助我在给Artech的wcf petshop增加授权机制的时候遇到的问题。
  10. Python 做过哪些有趣的项目
  11. 织梦cms/dedecms清理冗余废弃未引用图片方法
  12. IDEA (mac版)
  13. sql 双表或多表的连接查询 join
  14. 修复因为存储空间问题引起的nexus 服务启动异常
  15. Flask蓝图
  16. selenium +chromdriver模块
  17. 使用jwt
  18. bzoj2120 / P1903 [国家集训队]数颜色 / 维护队列(带修改莫队)
  19. filebeat-2-通过kafka队列链接logstash
  20. C#注册表读写完整操作类

热门文章

  1. POJ 1985 - 树的直径
  2. TensorFlow 学习(八)—— 梯度计算(gradient computation)
  3. TEdit,TMemo背景透明(SetWindowLong(WS_EX_TRANSPARENT)增加透明风格)
  4. Delphi绘图相关对象(TCanvas对象的方法)
  5. UVa 12657 Boxes in a Line(应用双链表)
  6. muduo源代码分析--Reactor在模型muduo使用(两)
  7. quick-cocos2d-x游戏开发【8】——动画与动作
  8. C#代码实现矢量画图
  9. 【读书笔记】——《A Brief History of Humankind》
  10. ASP.NET Core 项目配置 ( Startup ) - ASP.NET Core 基础教程 - 简单教程,简单编程