nginx 连接php
2022-07-28 15:09:43
126
{{single.collect_count}}

1.nginx 通过 fastcgi 接口连接nginx
在这里插入图片描述
用户访问网站—>nginx(fastcgi_pass) --FastCGI–>(php-fpm – wrapper) php (php解析器) —> mysql(读取或写入)
2.下载php
yum remove php-mysql php php-fpm php-common -y
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install -y php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb
3.配置nginx配置文件
server {
listen 80;
server_name bbs.trrop.com;
##分割站点日志:
access_log /var/log/nginx/www_access.log main;
error_log /var/log/nginx/www_error.log error;
location / {
root /www;
index index.php index.html;

指定用户最大上传50M,413报错问题,php-fpm也要修改

client_max_body_size 50m;
#字符集
charset utf-8;
}
location ~ .php$ {
root /www;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME documen t rootdocument_root documentrootfastcgi_script_name;
fastcgi_pass 127.0.0.1:9000; //调用 fastcgi接口
include fastcgi_params; //变量定义的文件
}
}

ps:这个只是连接单台网站建设,如果想要实现nginx+php+nfs+mysql的话,需要建立对应的管理用户,统一用户。

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}