Linux下安装nginx, php, php-fpm并配置
来源:互联网 发布:java简历包装项目经验 编辑:程序博客网 时间:2024/06/05 20:52
环境: 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/*
0 0
- Linux下安装nginx, php, php-fpm并配置
- nginx+php-fpm在Linux下的安装和配置
- centos 下编译安装nginx + php 配置nginx+php-fpm
- nginx php-fpm安装配置
- nginx php-fpm安装配置
- nginx php-fpm安装配置
- nginx php-fpm安装配置
- nginx php-fpm安装配置
- nginx php-fpm安装配置
- nginx php-fpm安装配置
- nginx php-fpm安装配置
- nginx php-fpm安装配置
- nginx php-fpm安装配置
- nginx php-fpm安装配置
- nginx php-fpm安装配置
- nginx php-fpm安装配置
- Linux下php-fpm安装配置
- Linux下安装php环境并且配置Nginx支持php-fpm模块
- centos6.5 静态IP网络配置
- JavaScript之DOM
- 高并发的IOCP(完成端口)源码
- jsp判断加显示
- iOS之反射
- Linux下安装nginx, php, php-fpm并配置
- [LeetCode 198]House Robber
- [原]Java思想之容器implements与接口interface
- mamp下如何安装XDEBUG,webgrind?
- EditText 换行的问题
- kindeditor上传图片自动压缩过大的图片
- c++中struct和class
- centos 下 Qt Creator 的安装使用
- c++几种常见STL容器比较和分析 hashmap, map, vector, list