我目前正在开发一个高性能、高负载的 Web 应用程序。
我目前正在运行带有 FastCGI 的 nginx,用于 PHP-FPM、APC(操作码缓存),但它也是新功能;FastCGI 缓存。FastCGI 缓存允许我缓存动态内容(如 php 页面),这极大地加速了应用程序。
我有一个问题。我应该坚持使用 FastCGI 缓存,还是 Varnish“更好”(更快)?我只在速度和并发性方面寻找纯粹的性能。到目前为止,我对 FastCGI 非常满意,但我已经在网上阅读了数千篇文章,说 Varnish 很好。
然而,根据这个基准/文章,对于许多并发用户来说,Varnish 似乎是一个糟糕的选择。真的是这样吗?
我很好奇您以前在这方面的经验,请分享您的想法!由于 FastCGI 缓存相当新,我很难找到它和 Varnish 的基准。
我正在尝试让一个 hello world python 脚本在我的 nginx web 服务器上运行。当我尝试加载 URI 时出现“502 Bad Gateway”错误:http : //sub.dom.com/py-bin/hello.py
这是我的 nginx 错误日志中的错误。
2013/04/27 13:54:14 [error] 14158#0: *1 upstream closed prematurely FastCGI stdout while reading response header from upstream,
client: w.x.y.z, server: sub.dom.com, request: "GET /py-bin/hello.py HTTP/1.1", upstream: "fastcgi://unix:/var/run/fcgiwrap.socket:", host: "sub.dom.com"
Run Code Online (Sandbox Code Playgroud)
py-bin 的位置:/home/cluber/www/sub.dom.com/py-bin
public_html 的位置:/home/cluber/www/sub.dom.com/public_html
hello.py 的位置:/home/cluber/www/sub.dom.com/py-bin/hello.py (chmod 777)
fastcgi_params 的位置:/etc/nginx/fastcgi_params
nginx 配置的内容
server {
server_name sub.dom.com;
access_log /home/cluber/www/sub.dom.com/logs/access.log;
error_log /home/cluber/www/sub.dom.com/logs/error.log;
root /home/cluber/www/sub.dom.com/public_html;
index index.html index.html index.php /index.php;
location ~ …Run Code Online (Sandbox Code Playgroud) 我最近换了服务器。这是我使用 FastCGI 解释 PHP 的新服务器。但是,我从旧服务器带来的很多内容再次出现此错误,问题是 FastCGI 不会返回错误进行调试,它只会返回“500 内部服务器错误”。
有了这个,我不确定发生了哪一行来纠正错误。我有大量的脚本,这使得审查整个代码变得不可行。
已经尝试使用
尝试 {.. }
在已知错误中,但 FastCGI 仍然返回 500 错误。
我不是启用 mecher 环境变量的服务器管理员,有什么方法可以在 PHP 中解决这些错误?
我正在尝试在我的 ubuntu 虚拟机上设置 nginx 并尝试托管一个 php 网站。我正在尝试在我的 ubuntu 虚拟机上复制服务器设置。当我尝试从我的 nginx 服务器访问 php 页面时出现此错误。我试图在 /tmp/ 文件夹中查找 php.socket 文件,但里面什么也没有。我的虚拟机上的 fastcgi 或 php 有什么问题吗?
完整的错误如下:
[crit] 9267#0: *1 connect() to unix:/tmp/php.socket failed (2: No such file or directory) while connecting to upstream, client: 192.168.xxx.xxx, server: xxx.xxx.xxx.com, request: "GET /admin/ HTTP/1.1", upstream: "fastcgi://unix:/tmp/php.socket:", host: "xxx.xxx.xxx..com"
Run Code Online (Sandbox Code Playgroud)
请帮忙。我不知道为什么会发生这种情况,因为我缺少包裹或其他东西。我猜我已经安装了所有东西,并且在我的本地服务器上获得了相同的配置。
我们正在尝试在我们的登台环境中设置并行运行的多个 PHP 版本。为了实现这一点,我构建了所有相关的 PHP 二进制文件(在适用的情况下使用 --enable-fastcgi)并使用 mod_fastcgi 通过包装脚本调用前者。
如果相关,这里是/php-fcgi/php-5.5:
#!/bin/sh
PHPRC=/usr/local/php55/etc/php.ini
export PHPRC
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
PHP_FCGI_CHILDREN=3
export PHP_FCGI_CHILDREN
exec /usr/local/php55/bin/php-cgi
Run Code Online (Sandbox Code Playgroud)
到目前为止一切正常(即所有配置为运行 PHP 5.5 的虚拟主机都在 5.5 上运行,等等);然而,在<Directory>块中使用“SetEnv”设置的环境变量存在问题。所有这些都以REDIRECT_.
示例:
SetEnv APPLICATION_ENV "production"
Run Code Online (Sandbox Code Playgroud)
将导致此输出:
'REDIRECT_APPLICATION_ENV' => string 'production'
Run Code Online (Sandbox Code Playgroud)
任何人都可以就我做错了什么提出建议吗?
澄清为什么这与 mod_rewrite 无关:即使完全禁用 mod_rewrite 也会发生这种行为。
我目前正在运行带有由 Plack::Handler::Apache2 调用的 PSGI 应用程序的 Apache/mod_perl。我们遇到的问题是每个 Apache 进程都会消耗一个到 PostgreSQL 数据库的连接,这很昂贵。为了解决这个问题,我们计划运行与 Apache 分开的 PSGI 应用程序,并让所有 Apache 进程通过 UNIX 域套接字与其进行通信。在我的情况下,您会推荐什么设置?
我的计划是使用 plackup 运行它:
plackup -s FCGI -E production --nproc 100 --daemonize --listen /tmp/myapp.sock \
/usr/local/bin/myapp.psgi
Run Code Online (Sandbox Code Playgroud)
我问过 Plack 的作者 Tatsuhiko Miyagawa,是否建议将 plackup -s FCGI 用于生产目的。他提供了以下答案:
“虽然它可以用于生产,但我通常建议使用其他专用服务器,例如 Starman、Starlet 或 uwsgi。FCGI 是一个例外,因为除了默认的 Plack::Handler 之外,我们没有特定的 FCGI 守护进程。我们有一个计划将 FCGI 从 Plack 核心中分离出来,并将其作为单独的安装。”
现在,在 FCGI 从 Plack 中分离出来之前,问题是,在 Apache 之外使用 FastCGI 运行 PSGI 应用程序的最佳方法是什么?
我目前正在使用fastcgi_cache并希望将一个变量传递给fastcgi_cache_valid这样我可以根据文件拥有不同数量的缓存时间。但它似乎不会接受一个变量。
我尝试了以下方法:
set $cache_time 15s;
fastcgi_cache_valid 200 ${cache_time};
fastcgi_cache_valid 200 $cache_time;
set $cache_time "15s";
fastcgi_cache_valid 200 ${cache_time};
fastcgi_cache_valid 200 $cache_time;
set $cache_time 15;
fastcgi_cache_valid 200 ${cache_time}s;
fastcgi_cache_valid 200 $cache_time;
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
nginx: [emerg] invalid time value "$cache_time" in /etc/nginx/conf.d/www.com.conf:118
nginx: [emerg] directive "fastcgi_cache_valid" is not terminated by ";" in /etc/nginx/conf.d/www.com.conf:118
Run Code Online (Sandbox Code Playgroud) 当我使用没有 vhosts 的默认配置时,一切正常。但是当我添加虚拟主机时它不起作用..
以下是 vhost 的样子:
<VirtualHost *:80>
ServerName example
ServerAlias example.com $
ServerAdmin example@example.com
DocumentRoot "/home/example/public_html"
ErrorLog "/home/example/logs"
CustomLog "/home/example/logs1.log" combined
ScriptAlias /cgi-bin/ /home/example/cgi-bin/
Alias /phpmyadmin /home/phpmyadmin
<Directory "/home/example/public_html">
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.php index.html index.htm default.htm
</Directory>
<Directory "/home/phpmyadmin">
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.php index.html index.htm default.htm
Options -Indexes
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我也有这个httpd.conf:
<IfModule mod_fastcgi.c>
FastCGIExternalServer /usr/sbin/php-fpm -host 127.0.0.1:9000
AddHandler php-fastcgi .php
<LocationMatch "/status">
SetHandler php-fastcgi-virt
Action php-fastcgi-virt /usr/sbin/php-fpm.fcgi …Run Code Online (Sandbox Code Playgroud) 在端口 9000 上运行 php-cgi
Netstat 给了我
TCP 127.0.0.1:9000 DESKTOP-xxxxxxx:0 LISTENING
[php-cgi.exe]
配置文件
每个php文件都给我这个No input file specified.错误...
改SCRIPT_FILENAME了SCRIPT_NAME也没有成功。。
我在 Windows 10 家庭版 x64
我正在使用 virtualenv 并尝试托管我的 django 应用程序。我使用的是 Python 3.5 和 Django 1.9.2。我可以跑得import django很好。当我跑
from django.core.servers.fastcgi import runfastcgi
Run Code Online (Sandbox Code Playgroud)
我收到错误
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'django.core.servers.fastcgi'
Run Code Online (Sandbox Code Playgroud)
我自己的路:
['', '/home/wrapupne/venv/lib/python35.zip', '/home/wrapupne/venv/lib/python3.5', '/home/wrapupne/venv/lib/python3.5/plat-linux', '/home/wrapupne/venv/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5', '/usr/local/lib/python3.5/plat-linux', '/home/wrapupne/venv/lib/python3.5/site-packages']
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?