关于Nginx位置配置和子文件夹的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于CentOs6.5基本环境配置(七):Nginx配置-linux下编译配置nginx环境、Delphi判断文
关于Nginx位置配置和子文件夹的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于CentOs6.5基本环境配置(七):Nginx配置-linux下编译配置nginx环境、Delphi判断文件夹下子文件夹是否为空,及删除子文件夹,遍历文件夹及子文件夹的文件、Linux C 读取文件夹下所有文件(包括子文件夹)的文件名、Magento 2在子文件夹Nginx中等相关知识的信息别忘了在本站进行查找喔。
本文目录一览:- Nginx位置配置(子文件夹)(nginx 配置文件地址)
- CentOs6.5基本环境配置(七):Nginx配置-linux下编译配置nginx环境
- Delphi判断文件夹下子文件夹是否为空,及删除子文件夹,遍历文件夹及子文件夹的文件
- Linux C 读取文件夹下所有文件(包括子文件夹)的文件名
- Magento 2在子文件夹Nginx中
Nginx位置配置(子文件夹)(nginx 配置文件地址)
可以说我有一条类似的路径:
/var/www/myside/
该路径包含两个文件夹…让我们说 /static
和/manage
我想配置nginx来访问:
/static
该文件夹上的文件夹/
(例如http://example.org/)上有一些.html文件。
/manage
文件夹/manage
(例如http://example.org/manage)上,在这种情况下,此文件夹包含Slim的PHP框架代码-
这意味着index.php文件位于public
子文件夹中(例如/ var / www / mysite / manage / public /
index.php)
我尝试了很多组合,例如
server {listen 80;server_name example.org;error_log /usr/local/etc/nginx/logs/mysite/error.log;access_log /usr/local/etc/nginx/logs/mysite/access.log;root /var/www/mysite;location /manage { root $uri/manage/public; try_files $uri /index.php$is_args$args;}location / { root $uri/static/; index index.html;}location ~ \.php { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000;}
}
该/
工作正常反正manage
没有。难道我做错了什么?有人知道我应该改变什么吗?
马修。
答案1
小编典典要访问类似/var/www/mysite/manage/public
URI之类的路径/manage
,您将需要使用alias
而不是root
。有关详细信息,请参见此文档。
我假设您需要从两个根目录运行PHP,在这种情况下,您将需要两个location ~ \.php
块,请参见下面的示例。如果其中没有PHP/var/www/mysite/static
,则可以删除未使用的location
块。
例如:
server { listen 80; server_name example.org; error_log /usr/local/etc/nginx/logs/mysite/error.log; access_log /usr/local/etc/nginx/logs/mysite/access.log; root /var/www/mysite/static; index index.html; location / { } location ~ \.php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } location ^~ /manage { alias /var/www/mysite/manage/public; index index.php; if (!-e $request_filename) { rewrite ^ /manage/index.php last; } location ~ \.php$ { if (!-f $request_filename) { return 404; } fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } }}
该^~
修饰符使前缀的位置优先于在同级别的正则表达式的位置。有关详细信息,请参见此文档。
由于这个长期存在的错误,alias
andtry_files
指令不能一起使用。
在使用指令时要注意这一点if
。
CentOs6.5基本环境配置(七):Nginx配置-linux下编译配置nginx环境
留名,后续补全
Delphi判断文件夹下子文件夹是否为空,及删除子文件夹,遍历文件夹及子文件夹的文件
总结
以上是小编为你收集整理的Delphi判断文件夹下子文件夹是否为空,及删除子文件夹,遍历文件夹及子文件夹的文件全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
Linux C 读取文件夹下所有文件(包括子文件夹)的文件名
Linux C 下面读取文件夹要用到结构体struct dirent,在头#include <dirent.h>中,如下:
#include <dirent.h>
struct dirent
{
long d_ino; /* inode number 索引节点号 */
off_t d_off; /* offset to this dirent 在目录文件中的偏移 */
unsigned short d_reclen; /* length of this d_name 文件名长 */
unsigned char d_type; /* the type of d_name 文件类型 */
char d_name [NAME_MAX+1]; /* file name (null-terminated) 文件名,最长255字符 */
}
其中d_type表明该文件的类型:文件(8)、目录(4)、链接文件(10)等。
下面程序,递归读取某文件夹及其子文件夹下所有文件名:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
int readFileList(char *basePath)
{
DIR *dir;
struct dirent *ptr;
char base[1000];
if ((dir=opendir(basePath)) == NULL)
{
perror("Open dir error...");
exit(1);
}
while ((ptr=readdir(dir)) != NULL)
{
if(strcmp(ptr->d_name,".")==0 || strcmp(ptr->d_name,"..")==0) ///current dir OR parrent dir
continue;
else if(ptr->d_type == 8) ///file
printf("d_name:%s/%s\n",basePath,ptr->d_name);
else if(ptr->d_type == 10) ///link file
printf("d_name:%s/%s\n",basePath,ptr->d_name);
else if(ptr->d_type == 4) ///dir
{
memset(base,''\0'',sizeof(base));
strcpy(base,basePath);
strcat(base,"/");
strcat(base,ptr->d_name);
readFileList(base);
}
}
closedir(dir);
return 1;
}
int main(void)
{
DIR *dir;
char basePath[1000];
///get the current absoulte path
memset(basePath,''\0'',sizeof(basePath));
getcwd(basePath, 999);
printf("the current dir is : %s\n",basePath);
///get the file list
memset(basePath,''\0'',sizeof(basePath));
strcpy(basePath,"./");
readFileList(basePath);
return 0;
}
Magento 2在子文件夹Nginx中
在Ubuntu上使用Nginx 1.4.6,我正在尝试将Magento 2配置为在子文件夹中运行.
我已经在/ var / www中有一些其他的项目,它们的设置如下:
server {
server_name website.com;
root /var/www/;
location /p1/ {
# config
}
location /p2/ {
# config
}
}
但是现在,我的Magento安装位于/ mnt / storage / demo / demo-magento2,我无法找到将其包含在此服务器块中的方法.
我试图将他们的示例配置用于Nginx(https://github.com/magento/magento2/wiki/Nginx-Configuration-Settings-and-Environment-Variables).所以,我将这个位置块添加到我的服务器块配置中:
location /demos/demo-magento2/ {
set $MAGE_ROOT /mnt/storage/demo-magento2/;
set $MAGE_MODE developers;
include /mnt/storage/demo-magento2/Nginx.conf.sample;
}
并且Nginx一直给我这个错误:
2015/10/19 18:15:04 [emerg] 6250#0: location "/setup" is outside location "/demos/demo-magento2/" in /mnt/storage/demo-magento2/Nginx.conf.sample:27
我对Nginx很新,所以有人可以解释我如何解决这个问题吗?
解决方法:
Nginx配置对于指令所在的位置是挑剔的;因为Magento的Nginx.conf.sample包含’location’指令,所以它必须包含在“server”指令中.看一下示例配置顶部的注释掉部分;它大致显示了主配置文件应该是什么样的.
您应该有一个如下所示的根配置文件:
upstream fastcgi_backend {
server unix:/var/run/PHP5-fpm.sock;
}
server {
listen 80;
server_name server.dev;
set $MAGE_ROOT /path/to/magento2;
set $MAGE_MODE developer;
include /path/to/magento2/Nginx.conf.sample;
}
如果您正在使用典型的Ubuntu-Nginx设置,您将需要该文件位于/ etc / Nginx / sites-available目录下,并启用它,您需要从站点创建该文件的符号链接 – 启用目录.
我们今天的关于Nginx位置配置和子文件夹的分享已经告一段落,感谢您的关注,如果您想了解更多关于CentOs6.5基本环境配置(七):Nginx配置-linux下编译配置nginx环境、Delphi判断文件夹下子文件夹是否为空,及删除子文件夹,遍历文件夹及子文件夹的文件、Linux C 读取文件夹下所有文件(包括子文件夹)的文件名、Magento 2在子文件夹Nginx中的相关信息,请在本站查询。
本文标签: