php nginx 路径批量配置
* 假设 E:\upload 作为图片上传的位置 nginx 做web服务
* 创建文件conf.php 放到这个目录下
<?php
function handleDir($it, &$a) {
foreach ($it as $fileinfo) {
if ($fileinfo->isDir()) {
$filename = $it->getFilename();
if ($filename !== "." && $filename !== "..") {
array_push($a, $filename);
}
}
}
} $it = new \DirectoryIterator("."); $baseDir = preg_replace('/\\\\/', '/', __DIR__); $filenames = [];
handleDir($it, $filenames); $out = new SplFileObject($baseDir."/out.txt", "w+"); array_walk($filenames, function($value, $key, $dir) use ($out) {
$path = $dir .'/'.$value;
$out->fwrite("location /".$value." {".PHP_EOL);
$out->fwrite(" alias ".$path.";".PHP_EOL);
$out->fwrite(" allow all;".PHP_EOL);
$out->fwrite(" autoindex on;".PHP_EOL);
$out->fwrite(" charset utf-8,gbk;".PHP_EOL);
$out->fwrite("}".PHP_EOL);
}, $baseDir); /*
location /schoolhomepage {
alias E:/upload/schoolhomepage;
allow all;
autoindex on;
charset utf-8,gbk;
}
*/
* 把out.txt粘贴到 nginx 的conf路径下的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 8089;
server_name localhost;
#charset koi8-r;
charset utf-8;
#access_log logs/host.access.log main; location / {
root html;
index index.html index.htm;
charset utf-8;
} #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;
}
location /appPoster {
alias E:/upload/appPoster;
allow all;
autoindex on;
charset utf-8,gbk;
}
location /images {
alias E:/upload/images;
allow all;
autoindex on;
charset utf-8,gbk;
}
location /include {
alias E:/upload/include;
allow all;
autoindex on;
charset utf-8,gbk;
}
location /png {
alias E:/upload/png;
allow all;
autoindex on;
charset utf-8,gbk;
}
location /poster {
alias E:/upload/poster;
allow all;
autoindex on;
charset utf-8,gbk;
}
location /publish {
alias E:/upload/publish;
allow all;
autoindex on;
charset utf-8,gbk;
}
location /reporterActivity {
alias E:/upload/reporterActivity;
allow all;
autoindex on;
charset utf-8,gbk;
}
location /schoolhomepage {
alias E:/upload/schoolhomepage;
allow all;
autoindex on;
charset utf-8,gbk;
}
location /userAvatar {
alias E:/upload/userAvatar;
allow all;
autoindex on;
charset utf-8,gbk;
}
location /webPoster {
alias E:/upload/webPoster;
allow all;
autoindex on;
charset utf-8,gbk;
}
location /writerActivity {
alias E:/upload/writerActivity;
allow all;
autoindex on;
charset utf-8,gbk;
} # 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;
# }
#} }
nginx.conf
* 重启nginx服务

php nginx 路径批量配置的更多相关文章
- Nginx 安装及配置、负载均衡https网站及转发后页面js、css等路径找不到问题、更换证书导致问题解决
官网下载nginx:http://nginx.org/en/download.html 安装nginx编译环境:yum install -y gcc-c++ 安装pcre库解析正则:yum insta ...
- Nginx服务安装配置
1.Nginx介绍 Nginx是一个高性能的HTTP和反向代理服务器,由俄罗斯人开发的,第一个版本发布于2004年10月4日.Nginx由于出色的性能,在世界范围内受到了越来越多人的关注,其特点是占有 ...
- Nginx的安装配置
1.安装PCRE库 $ cd /usr/local/ $ https://sourceforge.net/projects/pcre/files/pcre/8.36/ $ tar -zxvf pcre ...
- nginx入门篇----nginx服务器基础配置
1.nginx.conf文件结构... #全局块 events{ ... } http #http块{ ...
- nginx反向代理配置及优化
nginx反向代理配置及优化前言: 由于服务器apache抗不住目前的并发.加上前端squid配置后,问题依然无法解决.而页面程序大部分是动态.无法使用fastcgi来处理.因此想使用nginx做为反 ...
- LVS + Keepalived + Nginx安装及配置
1.概述 上篇文章<架构设计:负载均衡层设计方案(6)——Nginx + Keepalived构建高可用的负载层>(http://blog.csdn.net/yinwenjie/artic ...
- windows下nginx+php简单配置
Nginx+php运行环境搭建 虽然目前nginx使用很广泛,在大陆主流的互联网站点或多或少会用到这个俄国人开发的小应用(占用资源小).但是我这个土鳖还是第一次自己独立配置,网上资料不少,但是还是遇到 ...
- nginx 的基础配置[转]
nginx 的基础配置 分类: 工具软件2013-11-13 23:26 11人阅读 评论(0) 收藏 举报 目录(?)[-] 管理配置文件 全局配置 虚拟机server配置 location配置 ...
- 利用nginx泛域名解析配置二级域名和多域名
利用nginx泛域名解析配置二级域名和多域名 网站的目录结构为 html ├── bbs └── www html为nginx的安装目录下默认的存放源代码的路径. bbs为论坛程序源代码路径 www为 ...
随机推荐
- miniFTP项目实战一
项目简介: 在Linux环境下用C语言开发的Vsftpd的简化版本,拥有部分Vsftpd功能和相同的FTP协议,系统的主要架构采用多进程模型,每当有一个新的客户连接到达,主进程就会派生出一个ftp服务 ...
- Abp vNext 基础篇丨领域构建
介绍 我们将通过例⼦介绍和解释⼀些显式规则.在实现领域驱动设计时,应该遵循这些规则并将其应⽤到解决⽅案中. 领域划分 首先我们先对比下Blog.Core和本次重构设计上的偏差,可以看到多了一个博客管理 ...
- Mysql中的Join详解
一.Simple Nested-Loop Join(简单的嵌套循环连接) 简单来说嵌套循环连接算法就是一个双层for 循环 ,通过循环外层表的行数据,逐个与内层表的所有行数据进行比较来获取结果,当执行 ...
- Win10下安装SVN出现2503/2502解决方法
出现错误的原因是权限不够 在win10的开始按钮上,右键点击,选择"命令提示符(管理员)(A)",弹出管理员身份运行模式的命令行的窗口,输入如下的命令: msiexec /pack ...
- 接口和包--Java学习笔记
接口 定义及基础用法 interface定义:没有字段的抽象类 interface person{ void hello(); String getName(); } /*接口本质上就是抽象类 abs ...
- .Net Core NPOI读取Excel 并转为数据实体类
创建应用程序 这里直接创建Console程序 引用NPOI的NuGet包 PM> Install-Package NPOI -Version 2.5.1 直接Nuget包管理器添加 导入Exce ...
- ASP.Net Core Web Api 使用 IdentityServer4 最新版 踩坑记录
辅助工具 日志追踪包 : Serilog.AspNetCore 源码查看工具 : ILSpy 项目环境 ###: ASP.NetCore 3.1 IdentityServer4 4.0.0+ 主题内容 ...
- Jsoup类
一.简介 Jsoup是一款HTML解析器,可以直接解析url地址,也可以解析html文本内容.也可通过DOM.CSS以及类似于jQuery的操作方法来取出和操作数据.其主要功能: 1.从url.字符串 ...
- 辗转相除 求最大公约数!or 最小公倍数
求最大公约数和最小公倍数的经典算法--辗转相除法描述如下: 若要求a,b两数的最大公约数和最小公倍数,令a为a.b中较大数,b为较小数,算法进一步流程: while(b不为0) { temp=a%b: ...
- spring加载Bean的解析过程(二)
1.例如: BeanFactory bf = new XmlBeanFactory(new ClassPathResource("spring.xml")); User user ...