这与几年前我问过的一个老问题有关 ,对此我从来没有得到正确的答案。 我只是build立一个新的服务器(Ubuntu 16.04,Nginx 1.10,PHP 7),并回到这个。 我有一个Question2Answer实例运行在一个子文件夹中,其他PHP代码从根目录运行。 对于根的东西,我有这在我的服务器块: location / { try_files $uri $uri/ /index.php?$request_uri; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } 对Q2A来说,我在旧服务器上所拥有的是: location /qa/ { if (!-e $request_filename) { rewrite ^/qa/(.*)$ /qa/index.php?qa-rewrite=$1 last; } } 这是行得通的,但我不认为这是应该如何做(如果是邪恶等)。 我确定只能使用try_files 。 我试过这个: location /qa/ { try_files $uri $uri/ /qa/index.php?qa-rewrite=$uri&$args; } 但是它不起作用,因为/qa/在qa-rewrite传递。 它应该只是通过path后的一切。 有没有办法从$urivariables中删除/qa/ ? […]
我已经在CentOS 7.x环境下使用本教程编译了支持FPM的PHP 7。 我能够通过运行CLI来testingphp。 cd /opt/php7/bin ./php –version 哪个输出 PHP 7.0.6 (cli) (built: May 22 2016 07:20:48) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies 我也安装了Apache,它运行成功。 现在我已经创build了虚拟主机,并将域引导到一个目录。 我已经用函数phpinfo()粘贴了一个php文件info.php ,但是服务器输出PHP函数而不执行它。 我觉得我现在真的很接近,只需要configurationapache运行php-fpm,所以我把这个configuration放在httpd.conf文件中,但是没有帮助。 <IfModule mod_fastcgi.c> DirectoryIndex index.html index.shtml index.cgi […]
我已经dockerised一个wordpress应用程序,现在我是一个纯粹主义者,不希望在docker容器中包含nginx ,并不想在nginx容器和php-fpm容器之间共享任何状态。 我想运行php-fpm作为一个独立的web服务器(如ruby中的独angular兽或python中的gunicorn),为WordPress的网站提供所有内容(html,css和图像)。 并在前面运行一个nginx反向代理(caching静态内容)。 这样我可以保持关注的分离,我没有nginx转发stream量和nginx服务器。 php-fpm的默认configuration只允许处理php文件。 php-fpm可以改变吗? 怎么样? 这是个好主意吗?
我正在尝试使用php-fpmconfigurationnginx,所以大多数请求都被传递给一个单独的php脚本。 目录布局如下: assets/… index.php 我希望这些url的工作方式如下: / -> index.php /foo -> index.php /bar/baz?spam=ham -> index.php /assets -> assets folder index.php应该将PATH_INFO设置为'/' , '/foo'和'/bar/baz' 。 我已经想出了最接近的configuration如下: location / { try_files $uri /index.php/$uri$is_args$args; } location /assets { try_files $uri =404; } location /index.php { include snippets/fastcgi-php.conf; include fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock; } 但是, PATH_INFO总是有一个额外的/ (例如在第一种情况下的'//' )。 更改为/index.php$url$is_args$args适用于除/之外的所有情况,这会导致404。 我当然可以修改脚本来处理额外的/但它感觉有点肮脏。 我一直在努力寻找和阅读手册,但我不能弄明白,任何指针?
我有我的网站nginx php-fpm服务器。 我想为nginx使用microcache。 起初一切正常。 我用curl命令得到“命中”。 问题开始时,我尝试login。 我尝试了一切,但无法解决login问题。 我设置“logged_in”cookie 10秒,在“cachingconfiguration”我设置“无caching”该cookie。 它假设有cookie的时候绕过caching。 我已经“放”没有caching设置,这是我的login。 另外我的网站有exmple.org/?i=login所以我现在不知道怎么回事,当我点击login:D。 主法师是可以caching的,但是主页面的login返回结果不明了,刷新后我变成了用户。 并注销,它注销我,但刷新后,仍然在用户loged。 所以我不知道如何修复/绕过login过程。 请帮我一下 服务器configuration: fastcgi_cache_path /usr/share/nginx/cache/fcgi levels=1:2 keys_zone=microcache:32m max_size=1024m inactive=3h; fastcgi_cache_key $scheme$host$request_uri$request_method; fastcgi_cache_use_stale updating error timeout invalid_header http_500; fastcgi_ignore_headers Cache-Control Expires Set-Cookie; add_header X-Cache $upstream_cache_status; server { listen ip:80; server_name example.org; return 301 $scheme://www.example.org$request_uri; } server { server_name www.example.org; listen ip:80; root […]
我应该在我的站点使用chroot作为我的ftp目录:我的php-fpm.conf: [mysite.com] listen = /var/run/php7-fpm-chroot-filemanager.sock chroot = /var/www/mysite.com/fileman chdir = / user = filemanuser group = filemangroup pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 我的nginx.conf部分: location ~* /fileman/(.+\.php)$ { root /var/www/mysite.com/; include /etc/nginx/fastcgi_params; if (!-f /var/www/mysite.com$fastcgi_script_name) { return 405; } fastcgi_index index.php; fastcgi_pass unix:/var/run/php7-fpm-chroot-filemanager.sock fastcgi_param SCRIPT_FILENAME /var/www/mysite.com$fastcgi_script_name; […]
当我testing每秒200次点击时,我在我的网站上堆积了以下错误。 首先我收到了499个错误 2017-04-09 03:22:45错误162.158.79.219 499 GET / HTTP / 1.1 0 nginx访问 2017-04-09 03:22:45错误162.158.79.87 499 GET / HTTP / 1.1 0 nginx访问 2017-04-09 03:22:45错误162.158.78.170 499 GET / HTTP / 1.1 0 nginx访问 2017-04-09 03:22:45错误162.158.78.68 499 GET / HTTP / 1.1 0 nginx访问 第二个错误开始显示502 2017-04-09 03:22:45错误162.158.79.135 502 GET / HTTP / 1.1 166 nginx访问 2017-04-09 03:22:45错误162.158.79.225 […]
我想在我的PHP应用程序中使用CLI和FPM环境variables。 我做的是我: 在/etc/environment导出一些variables。 configurationphp.ini (CLI和FPM)到variables_order = "EGPCS" 。 configurationFPM www.conf clear_env = no 我期望的是在CLI和FPM应用程序中都可以使用环境variables。 实际上,这只适用于CLI。 FPM的$_ENV不包含这些环境variables。 我注意到可以在www.conf定义环境variables,但这样做www.conf方便,因为我必须复制粘贴/etc/environment所有variables,并始终保持两个文件同步。 问题是:是否可以将所有环境variables直接传递给PHP-FPM应用程序,而无需在www.conf粘贴它们?
经过几个小时的search和debugging,我放弃了! 关于长时间运行PHP过程有成千上万的问题和文章,但是没有解决我的问题。 我有一个PHP脚本与以下代码: $cur = 0; // Second, loop for $timeout seconds checking if process is running while( $cur < 31 ) { sleep(1); $cur += 1; echo "\n —- $cur —— \n"; } 它只是打算跑31秒。 我有一个Nginx,PHP在debian服务器上configuration为fastcgi。 我设置了max_execution_time = 600 在 /etc/php5/fpm/php.ini 我甚至把它放进去 /etc/php5/cli/php.ini 也设置 request_terminate_timeout = 600 在/etc/php5/fpm/pool.d/www.conf 我也在nginx.conf http部分做了这些修改 client_header_timeout 600; client_body_timeout 600; send_timeout […]
每当我去localhost我得到一个404错误,直到我标记xdebug.profiler_aggregate = 0为什么是xdebug.so coredumps(SEGFAULT) [Xdebug] zend_extension=/usr/lib/php/20160303/xdebug.so xdebug.remote_enable=1 xdebug.remote_connect_back = 0 xdebug.remote_handler = "dbgp" xdebug.remote_port = 9000 xdebug.idekey = "PHPSTORM" xdebug.profiler_enable=1 xdebug.profiler_output_dir=/tmp/ xdebug.profiler_aggregate=1 $ dmesg [ 584.455746] php-fpm7.1[4645]: segfault at 30 ip 00007f5d3969f6b3 sp 00007ffdc8b87a20 error 4 in xdebug.so[7f5d3967e000+39000] $ sudo cat /var/log/php7.1-fpm.log [31-Aug-2017 14:59:01] WARNING: [pool www] child 4645 exited on signal 11 (SIGSEGV – […]