我刚开始在AWS AMI实例上使用Nginx,并且遇到了一些启动问题.

除了,我不需要mysql,所以我没有运行这个命令sudo yum -y install mysql-server mysql

我的/etc/nginx/conf.d/default.conf看起来像这样:

location / {

root /var/www/html;

index index.php index.html index.htm;

}

location ~ \.php${

fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /usr/share/nginx/

html$fastcgi_script_name;

include fastcgi_params;

}

我的/etc/php-fpm.d/www.conf

; Start a new pool named 'www'.

[www]

; The address on which to accept FastCGI requests.

; Valid syntaxes are:

; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on

; a specific port;

; 'port' - to listen on a TCP socket to all addresses on a

; specific port;

; '/path/to/unix/socket' - to listen on a unix socket.

; Note: This value is mandatory.

;listen = 127.0.0.1:9000

listen = /var/run/php-fpm/php-fpm.sock

; Set listen(2) backlog. A value of '-1' means unlimited.

; Default Value: -1

;listen.backlog = -1

; List of ipv4 addresses of FastCGI clients which are allowed to connect.

; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original

; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address

; must be separated by a comma. If this value is left blank, connections will be

; accepted from any ip address.

; Default Value: any

listen.allowed_clients = 127.0.0.1

; Set permissions for unix socket, if one is used. In Linux, read/write

; permissions must be set in order to allow connections from a web server. Many

; BSD-derived systems allow connections regardless of permissions.

; Default Values: user and group are set as the running user

; mode is set to 0666

;listen.owner = nobody

listen.owner = nginx

;listen.group = nobody

listen.group = nginx

;listen.mode = 0666

listen.mode = 0664

; Unix user/group of processes

; Note: The user is mandatory. If the group is not set, the default user's group

; RPM: apache Choosed to be able to access some dir as httpd

user = nginx

; RPM: Keep a group allowed to write in log dir.

group = nginx

; Choose how the process manager will control the number of child processes.

; Possible Values:

; static - a fixed number (pm.max_children) of child processes;

; dynamic - the number of child processes are set dynamically based on the

; following directives:

; pm.max_children - the maximum number of children that can

; be alive at the same time.

; pm.start_servers - the number of children created on startup.

; pm.min_spare_servers - the minimum number of children in 'idle'

; state (waiting to process). If the number

; of 'idle' processes is less than this

; number then some children will be created.

; pm.max_spare_servers - the maximum number of children in 'idle'

; state (waiting to process). If the number

; Note: This value is mandatory.

pm = dynamic

; The number of child processes to be created when pm is set to 'static' and the

; maximum number of child processes to be created when pm is set to 'dynamic'.

; This value sets the limit on the number of simultaneous requests that will be

; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.

; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP

; Note: Used when pm is set to either 'static' or 'dynamic'

; Note: This value is mandatory.

pm.max_children = 50

; The number of child processes created on startup.

; Note: Used only when pm is set to 'dynamic'

; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2

pm.start_servers = 5

; The desired minimum number of idle server processes.

; Note: Used only when pm is set to 'dynamic'

; Note: Mandatory when pm is set to 'dynamic'

pm.min_spare_servers = 5

; The desired maximum number of idle server processes.

; Note: Used only when pm is set to 'dynamic'

; Note: Mandatory when pm is set to 'dynamic'

pm.max_spare_servers = 35

; The number of requests each child process should execute before respawning.

; This can be useful to work around memory leaks in 3rd party libraries. For

; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.

; Default Value: 0

;pm.max_requests = 500

; The URI to view the FPM status page. If this value is not set, no URI will be

; recognized as a status page. By default, the status page shows the following

; information:

; accepted conn - the number of request accepted by the pool;

[....]

但是,当我调用.php文件时,我可以看到它只是下载.当我运行服务nginx启动时,我收到以下错误:

nginx: [emerg] "location" directive is not allowed here in /etc/nginx/conf.d/default.conf:1

nginx: configuration file /etc/nginx/nginx.conf test failed

请帮忙

解决方法:

这就是我能够解决问题的方法.服务器标记应该包含/etc/nginx/conf.d/default.conf中的所有其他内容

server {

location / {

root /var/www/html;

index index.php index.html index.htm;

}

location ~ \.php${

fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;

include fastcgi_params;

}

}

标签:nginx,php,amazon-ec2

来源: https://codeday.me/bug/20190623/1271618.html

etc php5 conf.d,php – nginx:[emerg]“location”指令不允许在/etc/nginx/conf.d/default.conf中使用:...相关推荐

  1. nginx: [emerg] “location“ directive is not allowed here in /usr/local/nginx/conf/nginx.conf:72

    做LNMP实验中的PHP设置完测试页面重启nginx时发现重不不成用nginx -t检测说如下原因 nginx: [emerg] "location" directive is n ...

  2. nginx: [emerg] “location“ directive is not allowed here

    nginx配置出错. D:\nginx>nginx.exe -t nginx: [emerg] "location" directive is not allowed her ...

  3. Nginx解决配置SSL证书报错:nginx: [emerg] unknown directive “ssl_certificate1“ in /usr/local/nginx/conf/ngi...

    前段时间自己尝试了下Nginx的反向代理, 将请求转发到Tomcat上; 应公司项目需要就自己研究了下配置添加证书, 实现https的请求; 我的证书是从阿里云买的免费的证书, 按照阿里云的提示, 将 ...

  4. 报错锦集二“nginx: [emerg] unknown directive “set_real_ip_from“ in /usr/local/nginx/conf/nginx.conf:50 ngi

    报错锦集二"nginx: [emerg] unknown directive "set_real_ip_from" in /usr/local/nginx/conf/ng ...

  5. 报错集“nginx: [emerg] unknown directive “set_real_ip_from“ in /usr/local/nginx/conf/nginx.conf:50 ngi

    报错集"nginx: [emerg] unknown directive "set_real_ip_from" in /usr/local/nginx/conf/ngin ...

  6. 出现nginx: [emerg] unknown directive “]“ in /usr/local/openresty/nginx/conf/nginx.conf:74

    原因:fastdfs和nginx集成时,fastdfs-nginx-module安装错误 解决方法: ./nginx -s stop #停止nginx服务 cd /home/bigdata/nginx ...

  7. Nginx的location指令

    location指令 server{listen 80;server_name localhost;location / {}location /abc{}... } location:用来设置请求的 ...

  8. nginx之location指令详解

    前面介绍过nginx.conf的文件结构,大致介绍了顶层的指令和各级指令,今天给大家介绍下http模块里面的子模块server的指令location,该指令直接影响到请求路由转发规则,乃重中之重. l ...

  9. nginx location指令用法

    nginx使用location指令去匹配不同的路径 nginx首先通过路径的前缀去匹配 此时用法就是如下: # url就是路径的前缀,比如/, 比如/aaa location url {...} lo ...

最新文章

  1. 基于C++的OpenCV常用函数
  2. vue从创建到完整的饿了么(5)v-for,v-bind与计算属性
  3. Android安全与逆向之Java虚拟机和Dalvik虚拟机的区别
  4. 互联网晚报 | 9月22日 星期三 | 中国电信控股股东拟40亿元增持;碧桂园服务100亿收购富良环球;搜狗浏览器论坛即将下线...
  5. shell 特殊符号
  6. Algorithm:位运算的这些小技巧你知道吗?
  7. prisma graphql 工具基本使用
  8. [模板]匈牙利算法(二分图匹配)
  9. 视频教程-【思科CCNA理论专题:9】-- ACL理论-思科认证
  10. linux wget 整站克隆/仿站 整个网站的静态源码下载到本地 4种扒站工具(webzip、ha_TeleportPro、Offline Explorer、wget)
  11. 计算机很多文件无法删除,电脑有文件删不掉怎么办?电脑有文件删不掉解决方法介绍...
  12. 数据结构~~二叉树和BSTs(三)(转)
  13. python列表获取最后一个元素的方法_在Python中获取列表的最后一个元素
  14. 简明扼要阐述synchronized和lock的区别
  15. 常见笔顺错误的字_笔画容易出错的字?
  16. 驱动开发思路以及应用程序与驱动程序的区别
  17. 【杰理AC696X】软件定时器介绍
  18. 我国AI医学影像新成果:人工智能可为肝癌患者无创分级
  19. java将本地图片复制添加水印并导出到本地
  20. 西式快餐是否比起肯德基更多人喜欢麦当劳,如果是原因是什么

热门文章

  1. cSpring Boot整合RabbitMQ详细教程
  2. sql 基础增删改查语句
  3. jQuery基础(3)- ajax
  4. Django获取当前页面的URL——小记
  5. 1. UI Tests简介
  6. sql实现对多个条件分组排序方法和区别
  7. HTML 颜色值及脚本
  8. 开源web应用防火墙 - Naxsi
  9. 动态规划——最大子段和(洛谷 P1115)
  10. 认知空间是什么意思_Number是“数”,one是“一”,那么number one什么意思?