Articles of PHP的

用php5.5在centos 6.4上安装php-memcached

我刚刚用Nginx完成安装php FASTCGI(php-fpm)v.5.5。 在一个新的Centos6.4 我试图安装memcached但遇到很多问题…..这里是我的步骤: /bin/rpm -ivh http://ftp.uninett.no/linux/epel/6/i386/epel-release-6-8.noarch.rpm /bin/rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm yum –enablerepo=remi,remi-php55 install nginx php-common php-fpm php-mysqlnd 但是当试图添加memcached时: yum install php-pecl-memcached.x86_64 (Extension to work with the Memcached caching daemon) 它正在失败…: > Resolving Dependencies > –> Running transaction check > —> Package php-pecl-memcached.x86_64 0:1.0.0-1.el6 will be installed > –> Processing Dependency: php(zend-abi) = 20090626 for package: […]

nginx – 重写或内部redirect周期,而内部redirect到“/index.html”

我无法弄清楚为什么这个错误发生: “重写或内部redirect周期,而内部redirect到”/index.html“” 我发现了一个类似的post,并根据我所阅读的内容尝试了各种build议,但无济于事。 这是我的nginxconfiguration。 任何帮助,将不胜感激! server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html/public; index index.php; # Make site accessible from http://localhost/ server_name ourdomain.com; location @handler { rewrite / /index.php } location / { try_files $uri $uri/ /index.php?$query_string; } location ~ .php$ { fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; # add […]

Cloudflare将子域redirect到目录

我正在尝试使用Cloudflareredirect: http://sub.example.com -> http://example.com/sub 但我更喜欢这个: http://sub.example.com -> http://example.com/subdomain 这可能吗?

Nginx从不同的服务器提供php文件

我正在尝试configurationnginx来从另一台服务器提供PHP。 这些文件可以位于另一个服务器上的/ sample下的目录中 快速CGI运行在另一台服务器上的端口9000上 这是我所尝试过的,现在还不行。 location ~ [^/]\.php(/|$) { proxy_pass http://192.168.x.xx; proxy_redirect http://192.168.x.xx /sample; fastcgi_split_path_info ^(.+?\.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } # Mitigate https://httpoxy.org/ vulnerabilities fastcgi_param HTTP_PROXY ""; fastcgi_read_timeout 150; fastcgi_buffers 4 256k; fastcgi_buffer_size 128k; fastcgi_busy_buffers_size 256k; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } 我还需要configurationnginx来从同一个服务器提供静态文件

在读取来自上游的响应报头时debugging着名的 – 在stderr中发送的FastCGI:“主脚本未知”

所以有很多文章提到这个错误代码: FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream… 这可能意味着这个错误信息或多或less是无用的。 该消息告诉我们FastCGI处理程序不喜欢因为某种原因而发送的任何内容。 问题是有时我们不知道原因是什么。 所以我重申了这个问题 – 我们如何debugging这个错误代码? 考虑一下我们有一个非常简单的网站,只有phpinfo.php文件的情况。 另外,还有一个非常简单的nginxconfiguration,如下所示: server { server_name testsite.local; root /var/local/mysite/; location / { index index.html index.htm index.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass fastcgi_backend; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } } 我们怎样才能看到输出/日志究竟是什么fastcgi_params发送到脚本? 我们如何看到实际的错误信息? 在我的情况下,我使用php-fpm。 它在日志中没有关于这个错误的信息。 […]

Nginx:使用fastcgi_pass时会覆盖主机头

我试图覆盖传递给我的基于PHP的应用程序(特别是Phabricator )在使用fastcgi_pass的http主机头。 在使用proxy_pass的时候,我发现了很多这样的例子,但是我似乎无法find一个如何使用fastcgi_pass的例子。 具体来说,我想代理的PHP应用程序看到主机头为“phabricator.localhost”。 (原因是我想将几个不同的域与Phabricator webapp关联起来,但它只允许一个域关联,并且拒绝任何不是那个域的请求。) 我是用FastCGIconfigurationNginx的新手,所以我不确定fastcgi是如何工作的。 任何帮助表示赞赏。 这是我的Nginx服务器configuration: server { server_name phabricator.localhost www.example.com example.com; root /opt/phabricator/phabricator/webroot; location / { index index.php; rewrite ^/(.*)$ /index.php?__path__=/$1 last; } location = /favicon.ico { try_files $uri =204; } location /index.php { fastcgi_pass localhost:9000; fastcgi_index index.php; #### HERE ARE MY ATTEMPTS ##### #proxy_set_header HOST phabricator.localhost; #fastcgi_param SERVER_NAME phabricator.localhost; #fastcgi_pass_header […]

Docker最佳实践:容器的单个进程

Docker 最佳实践指南指出: “…你应该只在单个容器中运行一个进程…” Nginx和PHP-FPM应该在不同的容器中运行吗? 或者这是否意味着微服务体系结构只在一个容器中运行一个服务或“应用程序”? 将这些服务放在一个容器中似乎更容易部署和维护。

PHP-FPM + Laravel + Nginx + Ubuntu权限

我以前试过search一下这个问题,但是似乎没有什么地方可以详细解释,大多数情况下只有app/storage权限这样的问题没有被设置,所以webserver可以写文件,但是我的问题似乎更大更根本,我希望有人能够详细解释如何设置,最好不需要设置权限777 。 所以我的堆栈是Ubuntu 14.04 ,使用PHP-FPM的 PHP 5.6 ,因为我使用nginx 1.4.6 ,我使用Laravel 4.2作为框架,ow和一个以上的Git作为我的版本工具。 那么有什么必要的一步一步来允许以下几点: 设置最初的项目,Git和Nginx: 所以据我所知,Nginx设置为使用用户名www-data作为默认的权利? 这是否意味着我必须将我的用户(例如kevin分配给组www-data ? 当我初始化git时,使用composer创build项目,设置SSH公钥/私钥,我是否需要属于组www-data或者我必须是sudo或者什么? 在我的生产服务器上,我尝试用sudo来设置所有东西,这样做更容易,但这是否是最好的做法? 使app/storage可写入Web服务器: 我认为这是Laravel的第二个也是最重要的,因为除非这个工作Laravel不会运行,我的知识是这个文件夹必须可以由web服务器(nginx)写入,所以我需要设置为sudo chown -R www-data:www-data app/storage和sudo chmod -R 664 app/storage right? 但不知何故,这似乎并不一直工作,因为在我的发展有时它会告诉一个视图的caching不能写入app/storage文件夹,所以最后我必须将其设置为777或775 if我很幸运。 公用文件夹或我的资产的位置 这里我也有一些不一致的地方,我已经把它设置在777的末尾,以确保所有的文件都可以被nginx访问。 有时nginx会告诉我,我的资产文件夹中的某些图像似乎是被禁止的,如果我设置为777或将该组更改为www-data:www-data ,我只能更改权限,否则将只返回HTTP 200对于我从GIMP,Photoshop创build的每个图像,或者当我从Dropbox下载或从我的电子邮件中,当我的graphicsdevise师devise新的图标时组? 上传文件 因此,在某个时间段,人们可以上传例如他们的个人资料图片,或者当我发布博客我可以上传图片时,这意味着file upload脚本将在某个时刻将文件从/tmp文件夹移动到我的public文件夹,它可能只需要写入到一个public的子目录中,或者有时需要创build一个基于特定id的文件夹,并将文件移动到目录中,大部分时间我会得到一个错误,该目录似乎不在脚本执行期间是可写的或者一些权限错误。 这是否意味着PHP进程必须以某种权限运行? 或者这是否意味着该目录必须有一定的权限? 这个问题是否与Nginx服务相关,还是与PHP进程相关 ? 我有使用包如roumen/sitemap或jlapp/swaggervel ,他们似乎使用相同的Facade File ,但不知何故,他们没有任何问题的权限,我试图复制他们的代码行为,但我遇到了问题以上。 队列,工匠,其他基于命令行的执行脚本 最后,是基于命令行的执行脚本,这是否执行从与web服务器交互执行的脚本,如上面的file upload,还是我需要准备其他不一致? 谢谢,如果有人能向我解释这一点。 我想如果我弄清楚,我会创build一个博客文章或东西,感谢他们! :d

NGINX try_files不会传递给PHP

我有一个非常简单的PHP网站: . ├── about.php ├── index.php ├── project │ ├── project_one.php │ └── project_two.php └── projects.php 和下面的nginxconfiguration(只显示相关部分): location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/path/to/php.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_intercept_errors on; } location / { index index.php; try_files $uri $uri/ $uri.php =404; } 按预期击中/工作。 击中任何http://my.site.com/{projects | about | project/*} http://my.site.com/{projects | about | project/*} http://my.site.com/{projects […]

nginx阻止从caching加载

我更新我的网站后更新完成更新我的客户报告旧图像和脚本正在加载而不是新的。 我知道他们来自他们的浏览器caching,但有什么办法可以强制脚本不从服务器caching加载。 我正在用php-fpm使用nginx。