环境: Fedora20

目标: 在Fedora20上安装好nginx服务器,并可正确解析php文件

1. 安装:

yum makecache

yum install nginx php php-fpm

2. nginx的配置

按默认配置(网站根目录路径:/usr/share/nginx/html),一般也是OK的。通过浏览器打开http://localhost来看,如果能正常显示网页,就OK了。

还可以通过"nginx -t“ 来检测

3. 修改,我将网站根目录移到了/home/zcm/program/web下,导致出现了一系列的问题,现帖出完整配置(/etc/nginx/nginx.conf),以备将来对照

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/
#user  nginx;
user  zcm;
worker_processes  1;
error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;
pid        /run/nginx.pid;
events {
worker_connections  1024;
}
http {
include       /etc/nginx/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  /var/log/nginx/access.log  main;
sendfile        on;
#tcp_nopush     on;
#keepalive_timeout  0;
keepalive_timeout  65;
#gzip  on;
index   index.html index.htm;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen       80 default_server;
server_name  localhost;
root        /home/zcm/program/web;
#charset koi8-r;
#access_log  /var/log/nginx/host.access.log  main;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
# redirect server error pages to the static page /40x.html
#
error_page  404              /404.html;
location = /40x.html {
}
# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
#root           /home/zcm/program/web;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
include        fastcgi_params;
}
}
}

4. 接下来才是重点

如果仅做了以上3步,访问html等非php文件可能已经没问题了,但是要访问.php文件,可能还不行,因为涉及到权限问题。

4.1 需要给/home/zcm 加上rx权限:chmod +rx /home/zcm

4.2 对应的.php文件要具有r权限.

5. 最后补充一点

Linux下的防火墙默认阻挡了许多的协议和端口,如果在windows上ping不通或telnet不到指定端口,请一定要考虑下防火墙的问题。

完成以上配置,应该就差不多了。如果实在是还有其他问题,可以仔细看下日志: /var/log/nginx/*

Linux下安装nginx, php, php-fpm并配置相关推荐

  1. Linux下安装nginx (tar解压版安装) nginx1.16.1

    https://blog.csdn.net/qq_40431100/article/details/104729504 Linux下安装nginx (tar解压版安装) nginx1.16.1 Jkc ...

  2. 如何在Linux下安装nginx

    如何在Linux下安装nginx 1.http://nginx.org 下载对应平台的安装初始配置文件 2.yum install nginx posted on 2012-07-25 15:41 e ...

  3. Linux下安装Nginx详细图解教程

    Linux下安装Nginx详细图解教程 什么是Nginx? Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SM ...

  4. Linux下安装Nginx完整教程及常见错误解决方案

    Linux下安装Nginx完整教程及常见错误解决方案 参考文章: (1)Linux下安装Nginx完整教程及常见错误解决方案 (2)https://www.cnblogs.com/chenxiaoch ...

  5. Linux下安装nginx,启动和重启

    Linux下安装nginx 查看Linux下是否已安装nginx且已启动 安装 重启nginx 查看Linux下是否已安装nginx且已启动 是否安装:find / -name nginx 是否启动: ...

  6. Linux下安装nginx教程

    Linux下安装nginx教程 安装依赖包 #执行一下命令 安装4个依赖包 yum -y install gcc zlib zlib-devel pcre-devel openssl openssl- ...

  7. nginx etag php,Linux下安装nginx如何启用ETag

    nginx更新速度杠杠的,不到一年时间就更新了这么多版本了,今天一口气从1.2.3升级到1.8.0.为什么升级?因为nginx提供了ETag功能,对流量控制很有效果. 升级之前特意去查了一下资料,看看 ...

  8. linux下安装nginx启动,Linux下安装启动nginx的过程

    1.首先将nginx的安装包传到虚拟机里的/home目录下 2.为了方便nginx运行而不影响linux安全需创建组合用户 groupadd -r nginx useradd -r -g nginx  ...

  9. linux下安装nginx tar包,Linux环境下Nginx的安装

    一.首先去官网下载Nginx的tar包 Nginx官方网站地址:http://nginx.org/en/download.html ps:下载速度感人 Nginx下载地址 下载完成之后,把它上传到服务 ...

最新文章

  1. 多模态AI崛起,2022年人工智能5大发展趋势
  2. Eclipse解决JSP页面乱码问题
  3. maven的三种packaging方式
  4. Matlab元胞数组操作
  5. CTF爬虫:掌握这些特征,一秒识别密文加密方式
  6. linux实验总结及心得_安全实验室 | 内网渗透—Linux权限维持技巧总结
  7. dotConnect for Oracle控件免费下载及使用方法
  8. linux-权限设置--facl基本
  9. Linux Windows下忘记mysql超级管理员root密码的解决办法
  10. java 权限管理都用什么_java权限管理框架有哪些?
  11. 计算机无法进行磁盘碎片整理,无法启动win7系统磁盘碎片整理的解决方案
  12. html audio缓冲效果实现
  13. jQuery实现可移动(draggable)和可缩放(sizable)网页元素
  14. 家庭“好用”优化师:每一件好物都是在积攒生活闪光
  15. python制作qq登录界面_用Python实现一个最新QQ办公版(TIM)的登录界面
  16. 「从 Windows 到 macOS」快速理顺两大系统之间的差异
  17. 全新技术苹果群控IOS中控 免越狱
  18. 2《小学数学教材解读策略研究》开题报告
  19. 基于Java的飞机雷电射击游戏的设计实现(Eclipse开发)
  20. oracle11g exp 00028,解决Linux系统下exp导入EXP-00028异常

热门文章

  1. 进入保护模式(三)内存的分页
  2. 手机进水急救——爆米花可用来吸干水分
  3. I AM NOTHING vs I AM SOMETHING
  4. 使用机器学习预测天气_如何使用机器学习预测着陆
  5. 熊猫数据集_对熊猫数据框使用逻辑比较
  6. 荷兰牛栏 荷兰售价_荷兰的公路货运是如何发展的
  7. 分布与并行计算—生产者消费者模型实现(Java)
  8. mybatis多产数_freeCodeCamp杰出贡献者–我们如何选择,认可和奖励多产的志愿者
  9. python练习_如何使用Logzero在Python中练习记录
  10. sql server:查詢系統表