我有一个托管网站,我在配置Joomla时遇到了麻烦(在IIS7 + win server 2008上运行Joomla + php + mySQL).我有一个类似的配置在本地机器上运行(Joomla + php + mySQL在IIS7 + vista x64上),所以我至少能够按照各种教程中显示的说明如何设置它.
托管网站的这种症状是我无法在Joomla中打开任何SEO设置(甚至不是第一个设置,"搜索引擎友好URL").我得到404(文件未找到)或URL显示正确重写但它始终显示主页的内容.我的家用机器上有类似的问题,原来是因为我没有使用FastCGI来托管php,所以我决定在托管网站上进行调查.
无论如何,我注意到托管站点上托管joomla的目录的web.config文件中有以下行:
<add name="Plesk_Handler_3522909676" path="*.php" verb="*" modules="IsapiModule" scriptProcessor="c:\program files (x86)\parallels\plesk\additional\pleskphp5\php5isapi.dll" resourceType="Either" />
Run Code Online (Sandbox Code Playgroud)
从过去的经验来看,我知道php在没有在fastCGI下运行时会遇到一些问题.我注意到根文件夹中的web.config使用了以下行:
<add name="Plesk_Handler_0286090609" path="*.php" verb="*" modules="CgiModule" scriptProcessor="c:\program files (x86)\parallels\plesk\additional\pleskphp5\php-cgi.exe" resourceType="Either" />
Run Code Online (Sandbox Code Playgroud)
我在joomla目录中的web.config中复制了它,并得到了不同的行为......但仍然无法正常工作.如果我在运行phpInfo()的joomla目录中加载.php文件,则在Server API下它会显示CGI/FastCGI.那是肯定的确认正在使用FastCGI的?为什么web配置中的处理程序指向modules ="CgiModule"而不是modules ="FastCgiModule"(我甚至不确定是否存在,但我只是发现提到CgiModule可疑).
这是一个托管网站,据我所知,我无法访问ApplicationHost.config文件...
我们的代码与此类似:
<?php
ob_implicit_flush(true);
ob_end_flush();
foreach ($arrayOfStrings as $string) {
echo time_expensive_function($string);
}
?>
Run Code Online (Sandbox Code Playgroud)
在Apache中,这会在输出时将每个echo发送到浏览器.然而,在nginx/FastCGI中,由于nginx的工作方式(默认情况下),这不起作用.
有可能使这个工作在nginx/FastCGI上,如果是这样,怎么样?
如何在Centos 6.5上同时运行多个php版本?
这是如何做.
要求
Centos 6.5(可能适用于6.6和7)
Apache Apache/2.2.15(可能与其他版本一起使用)
本指南安装并使用
FASTCGI(请参阅替代安装的注释)
PHPFARM
此安装以这种方式完成,因此它可以与iredmail兼容.
您可以使用此设置在服务器上安装iredmail.
第1步
安装PHPFarm
yum install gcc libxml2-devel openssl-devel bzip2-devel curl-devel libjpeg-devel freetype-devel icu libicu-devel gcc-c++ postgresql-devel aspell-devel git -y
$ cd /opt/
$ git clone https://github.com/cweiske/phpfarm.git phpfarm
$ cd phpfarm/src/
$ cd /opt/phpfarm/src/
Run Code Online (Sandbox Code Playgroud)
对于每个版本的php,你想运行它.但是,如果您希望自定义模块(例如mysql支持)跳过这个并看到它下面的部分.
$ ./compile.sh 5.3.1
$ ./compile.sh 5.3.3
$ ./compile.sh 5.5.11
Run Code Online (Sandbox Code Playgroud)
如果你得到编译错误,重新启动和try./compile.sh 5.3.1再次当我遇到这个问题
MYSQL和模块支持
步骤获得MySQL支持(和其他模块)自定义phpfarm安装的PHP版本5.5 0.14.这些说明适用于任何版本,只需将5.5.14重命名为5.4.3.你当然需要一个mysql服务器连接到php中使用mysql模块.
这些步骤需要按此顺序完成
步骤1A
确保您拥有这些路径并且日期时间正确我以root身份执行此操作.你应该有你想要使用的date.timezone.
cd /opt/phpfarm/src
vi custom-php.ini
date.timezone=America/Halifax
include_path=".:/opt/phpfarm/inst/php-$version/pear/php/"
Run Code Online (Sandbox Code Playgroud)
步骤1B
确保您拥有这些路径并且日期时间正确
cd /opt/phpfarm/src
vi default-custom-php.ini
date.timezone=America/Halifax
include_path=".:/opt/phpfarm/inst/php-$version/pear/php/"
Run Code Online (Sandbox Code Playgroud)
步骤1C
特别注意这一行
--with-config-file-path=/opt/phpfarm/inst/php-5.5.11/lib/ …Run Code Online (Sandbox Code Playgroud) 我在Nginx后面运行FastCGI,需要检测何时通过HTTPS访问url.但是,我的Django Web应用程序始终报告连接是HTTP(request.is_secure()== False).但是,SSL已正确设置,我已通过SSL检查器验证了我的https://网址是否安全.
如何让Django正确检测请求何时来自HTTPS网址?
我的Nginx设置是:
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
listen 443 default ssl;
ssl_certificate /home/webapp/ssl.crt
ssl_certificate_key /home/webapp/ssl.key
server_name myapp.com;
access_log /home/webapp/access.log
error_log /home/webapp/error.log
root /home/mywebapp;
location / {
# host and port to fastcgi server
fastcgi_pass 127.0.0.1:8801;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
}
}
} …Run Code Online (Sandbox Code Playgroud) 我正在运行一个包含大量代码的文件,并且必须为1000个用户处理它.处理500个用户大约需要55秒,因此我必须增加默认网关超时时间.
从这个问题,我发现我必须增加fastcgi_read_timeout,但我不知道把它放在哪里fastcgi.conf.
当它给出具有以下输出的回溯时它意味着什么?
#0 0x00000008009c991c in pthread_testcancel () from /lib/libpthread.so.2
#1 0x00000008009b8120 in sigaction () from /lib/libpthread.so.2
#2 0x00000008009c211a in pthread_mutexattr_init () from /lib/libpthread.so.2
#3 0x0000000000000000 in ?? ()
Run Code Online (Sandbox Code Playgroud)
该程序已经与标准信号11一起崩溃,分段故障.我的应用程序是一个在FreeBSD 6.3上运行的多线程FastCGI C++程序,使用pthread作为线程库.
根据信息来源,它已使用-g编译,并且我的源的所有符号表都已加载.
很明显,我的实际代码都没有出现在跟踪中,而是错误似乎来自标准的pthread库.特别是什么?()????
编辑:最终在我的主代码中跟踪崩溃到标准的无效内存访问.不解释为什么堆栈跟踪已损坏,但这是另一天的问题:)
FastCGI已经过时但在某些情况下它似乎仍然是正确答案.
看起来Perl/Catalyst Web应用程序的首选部署是使用FastCGI.
FastCGI在Rails中很受欢迎,但似乎不再适用.(为什么?)
Java世界似乎与FastCGI没有任何关系.像Tomcat这样的东西比Apache + FastCGI更好吗?
选择FastCGI仍然是一个好主意还是仅仅是一种挥之不去的技术?
摊晒
我正在设置LEMP堆栈以运行Drupal.我安装了Nginx和PHP-FastCGI.
Nginx工作正常,但任何运行PHP的尝试都给了我错误"502 Bad Gateway".
一个快速谷歌透露:nginx 502坏网关,并增加缓冲区大小解决了问题.
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
Run Code Online (Sandbox Code Playgroud)
问题是为什么?
我的理解
从上一个链接看,似乎nginx正在向PHP-FastCGI发送请求而它没有响应.这些请求怎么样才能超时?
没有足够的时间来回应因为php很复杂(事实并非如此phpinfo();).现在我已经增加了缓冲区,我何时应该担心必须再次增加缓冲区?
对于Python 3,是否存在可以作为FastCGI服务器为WSGI应用程序提供服务的库?(那么nginx可以代理请求吗?)
Python 3文档提到了flup,但是flup甚至没有安装在Python 3中:
% env3/bin/pip install flup
Downloading/unpacking flup
Downloading flup-1.0.2.tar.gz (49kB): 49kB downloaded
Running setup.py (path:/Users/me/tmp/env3/build/flup/setup.py) egg_info for package flup
Traceback (most recent call last):
File "", line 17, in
File "/Users/me/tmp/env3/build/flup/setup.py", line 2, in
from ez_setup import use_setuptools
File "./ez_setup.py", line 98
except pkg_resources.VersionConflict, e:
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 17, in
File "/Users/me/tmp/env3/build/flup/setup.py", line 2, in
from ez_setup … 我需要苗条的PHP与漂亮的网址使用.htaccess,没有问题.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
Run Code Online (Sandbox Code Playgroud)
现在我使用hhvm,fastcgi使用这个虚拟主机配置运行它.
<VirtualHost *:80>
ServerName project.dev
ServerALias www.project.dev
DocumentRoot /var/www/project
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/$1
<Directory "/var/www/project">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
当然,它不会读取.htaccess文件,我想.htaccess在虚拟主机配置中添加配置,但不,它不会工作.
像这样:
<VirtualHost *:80>
ServerName project.dev
ServerALias www.project.dev
DocumentRoot /var/www/project
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/$1
<Directory "/var/www/project">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)