首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    PHP-FPM运行模式解析:如何选择适合的服务器模式

    最近服务器遇到一些瓶颈,就是在部分人员多的时候会出现内存跑满,直接卡死的状态,在优化服务器和MySQL数据库配置文件的时候,PHP有个运行模式引起我的注意,觉得不错,可以仔细的研究下,当然解决内存卡死的原因很多,今天仅仅聊聊PHP-FPM的运行模式,不代表是因为运行模式引起的内存卡死,请勿过多解读,设置正确可以缓解服务器堵塞,PHP-FPM(FastCGI Process Manager)是一个PHP FastCGI实现,它可以处理PHP请求并将结果返回给Web服务器。PHP-FPM有三种运行模式:静态、动态和按需。每种模式都有其优缺点,选择哪种模式取决于您的服务器性能和应用程序需求。

    01

    Memcached命令

    memcached 1.4.3 -p <num> 设置端口号(默认不设置为: 11211) -U <num> UDP监听端口 (默认: 11211, 0 时关闭) -l <ip_addr> 绑定地址 (默认:所有都允许,无论内外网或者本机更换IP,有安全隐患,若设置为127.0.0.1就只能本机访问) -d 独立进程运行 -u <username> 绑定使用指定用于运行进程 <username> -m <num> 允许最大内存用量,单位M (默认: 64 MB) -P <file> 将PID写入文件<file>,这样可以使得后边进行快速进程终止, 需要与 -d 一起使用 如: 在linux下:./usr/local/bin/memcached -d -u jb-mc -l 192.168.1.197 -m 2048 -p 12121 在window下:d:\App_Serv\memcached\memcached.exe -d RunService -l 127.0.0.1 -p 11211 -m 500 在windows下注册为服务后运行: sc.exe create jb-Memcached binpath= "d:\App_Serv\memcached\memcached.exe -d RunService -p 11211 -m 500" start= auto net start jb-Memcached

    01

    nginx 502错误原因和解决办法总结

    一、NGINX 502错误排查 NGINX 502 Bad Gateway错误是FastCGI有问题,造成NGINX 502错误的可能性比较多。将网上找到的一些和502 Bad Gateway错误有关的问题和排查方法列一下,先从FastCGI配置入手: 1.FastCGI进程是否已经启动 2.FastCGI worker进程数是否不够 运行 netstat -anpo | grep “php-cgi” | wc -l 判断是否接近FastCGI进程,接近配置文件中设置的数值,表明worker进程数设置太少 3.FastCGI执行时间过长 根据实际情况调高以下参数值 fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; 4.FastCGI Buffer不够 nginx和apache一样,有前端缓冲限制,可以调整缓冲参数 fastcgi_buffer_size 32k; fastcgi_buffers 8 32k; 5.Proxy Buffer不够 如果你用了Proxying,调整 proxy_buffer_size 16k; proxy_buffers 4 16k; 参见:http://www.server110.com 6.https转发配置错误 正确的配置方法 server_name www.mydomain.com; location /myproj/repos { set $fixed_destination $http_destination; if ( $http_destination ~* ^https(.*)$ ) { set $fixed_destination http$1; } proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Destination $fixed_destination; proxy_pass http://subversion_hosts; } 当然,还要看你后端用的是哪种类型的FastCGI,我用过的有php-fpm,流量约为单台机器40万PV(动态页面), 现在基本上没有碰到502。

    02

    nginx 502错误原因和解决办法总结

    一、NGINX 502错误排查 NGINX 502 Bad Gateway错误是FastCGI有问题,造成NGINX 502错误的可能性比较多。将网上找到的一些和502 Bad Gateway错误有关的问题和排查方法列一下,先从FastCGI配置入手: 1.FastCGI进程是否已经启动 2.FastCGI worker进程数是否不够 运行 netstat -anpo | grep “php-cgi” | wc -l 判断是否接近FastCGI进程,接近配置文件中设置的数值,表明worker进程数设置太少 3.FastCGI执行时间过长 根据实际情况调高以下参数值 fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; 4.FastCGI Buffer不够 nginx和apache一样,有前端缓冲限制,可以调整缓冲参数 fastcgi_buffer_size 32k; fastcgi_buffers 8 32k; 5.Proxy Buffer不够 如果你用了Proxying,调整 proxy_buffer_size 16k; proxy_buffers 4 16k; 参见:http://www.server110.com 6.https转发配置错误 正确的配置方法 server_name www.mydomain.com; location /myproj/repos { set $fixed_destination $http_destination; if ( $http_destination ~* ^https(.*)$ ) { set $fixed_destination http$1; } proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Destination $fixed_destination; proxy_pass http://subversion_hosts; } 当然,还要看你后端用的是哪种类型的FastCGI,我用过的有php-fpm,流量约为单台机器40万PV(动态页面), 现在基本上没有碰到502。

    02
    领券