服务器php nginx配置,Nginx+php配置文件服务器

为了简单,采用了nginx+php配置文件服务器。

nginx的上传文件模块nginx_upload_module,源码安装的时候将该模块加上。

可以参考文章:

https://www.jianshu.com/p/ef9f75094a65

https://www.jianshu.com/p/7d2b0567521f

处理nginx的上传文件我使用的是php,所以需要安装php

sudo yum -y install nginx

参考文章:

https://www.cnblogs.com/huandada/p/10114722.html

php修改文件名rename函数老是返回false, 用print_r(get_last_error())发现是权限的问题。php是apache用户开启的,于是我先尝试将nginx文件目录的owner改为apache,

chown -R apache:apache /usr/local/nginx/html

结果还是权限不够,然后用ll命令看目录权限是755。

最后我将权限改为007, 居然可以了。为什么走的是other呢?搞不懂哦!!!

还遇到一个问题就是, php返回json的函数json_encode居然找不到。网上搜了一下,好像是php的json模块没有默认加入,需要手动安装。那就安装一下吧:

yum install php-json

对了php现在默认是sock的方式监听的,我改为了ip+端口的方式。配置文件在

etc/php-fpm.d/www.conf

再贴一下nginx的配置吧:

location /upload {

client_max_body_size 200m;

upload_pass /handle_upload.php;

upload_store /usr/local/nginx/html;

upload_set_form_field "${upload_field_name}_name" $upload_file_name;

upload_set_form_field "${upload_field_name}_content_type" $upload_content_type;

upload_set_form_field "${upload_field_name}_path" $upload_tmp_path;

upload_aggregate_form_field "${upload_field_name}_md5" $upload_file_md5;

upload_aggregate_form_field "${upload_field_name}_size" $upload_file_size;

upload_pass_form_field "^.*$";

}

location ~ \.php$ {

root /usr/local/nginx/html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值