我想确保组的成员可以读取所有日志,并且 php-fpm 进程在记录下时adm会出现异常php5-fpm.logroot:rootu=r+w
我找不到实现此目标的方法。我考虑过使用syslog.facility指令,但我宁愿保留一个专用的日志文件。
我想知道是否有关于如何设置 Apache + SuExec + php-fpm 的好指南?我有一个服务器,我将使用几个单独的网站。所以,我需要 php 作为站点所有者用户运行。如我所见,php-fpm 与 php-fcgi 略有不同。在这种情况下是否需要来自 Apache 的 mod_fcgid?如何设置这一切?
现在我的网站正在运行 Apache + mod_suphp + php-cgi,所以...很好,但有点慢。我想保持安全并获得使用 APC 的能力。
我正在努力为 php-fpm 找到一个有效的 monit 配置。
这是我尝试过的:
### Monitoring php-fpm: the parent process.
check process php-fpm with pidfile /var/run/php-fpm/php-fpm.pid
group phpcgi # phpcgi group
start program = "/etc/init.d/php-fpm start"
stop program = "/etc/init.d/php-fpm stop"
## Test the UNIX socket. Restart if down.
if failed unixsocket /var/run/php-fpm.sock then restart
## If the restarts attempts fail then alert.
if 3 restarts within 5 cycles then timeout
depends on php-fpm_bin
depends on php-fpm_init
## Test the php-fpm binary.
check file php-fpm_bin with path /usr/sbin/php-fpm …Run Code Online (Sandbox Code Playgroud) 这是我的 nginx 配置文件的一部分:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/$fastcgi_script_name;
include fastcgi_params;
}
Run Code Online (Sandbox Code Playgroud)
几乎网站会加载,因为 / 的位置也在此配置文件中设置为 /var/www。
location / {
root /var/www;
index index.php index.html index.htm;
}
Run Code Online (Sandbox Code Playgroud)
当我使用 phpinfo() 并读取 PHP 变量表时,我注意到了这一点:
_SERVER["DOCUMENT_ROOT"] /usr/share/nginx/html
Run Code Online (Sandbox Code Playgroud)
其他变量(大部分在 nginx.conf 中配置)如服务器名称、脚本文件名等,被发送到 php。因此,nginx 不会将此变量发送给 PHP。我必须做什么?
我使用的是 PHP 5.3.8 和 nginx 0.8
我有 2 sites-enabled,server_name如下:
server_name www.mysite.com mysite.com
Run Code Online (Sandbox Code Playgroud)
和
server_name dev.mysite.com
Run Code Online (Sandbox Code Playgroud)
问题:当我通过其 IP 地址访问该网站时,通过查看访问/错误日志,似乎 nginx 正在root使用dev.mysite.com.
nginx 如何决定服务哪个?我们可以迫使它服务过root的www.mysite.com时,该网站正在使用的IP地址访问?
配置文件
server {
listen 80;
server_name www.mysite.com mysite.com;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /var/www/mysite/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args ;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_read_timeout 300;
}
}
Run Code Online (Sandbox Code Playgroud) 当我使用 apache/mod_php 时,PHP 错误会出现在 apache 的错误日志中。
现在,我通过 fcgi 将 php-fpm 与 nginx 一起使用,是否有可能在 nginx 错误日志中也有 PHP 错误日志?
到目前为止,唯一的解决方案是使用 php.ini 中定义的外部文件
error_log = /tmp/php_errors.log
Run Code Online (Sandbox Code Playgroud)
但为了便于维护,我希望它们在 nginx 错误日志中。
我正在使用 fpm php 5.5 运行 Ubuntu nginx 1.8,在一个站点上,我能够使缓存工作(带有简单的时间输出)<?php echo time();?>显示:
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html
Date:Fri, 08 Jan 2016 14:04:00 GMT
Fastcgi-Cache:HIT
Server:nginx/1.8.0
Transfer-Encoding:chunked
X-Powered-By:PHP/5.5.9-1ubuntu4.14
Run Code Online (Sandbox Code Playgroud)
但是对于 WordPress 站点,标题始终显示(即使注销并隐身):
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html; charset=UTF-8
Date:Fri, 08 Jan 2016 14:02:42 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Fastcgi-Cache:BYPASS
Link:<http://mywpsite.com/wp-json/>; rel="https://api.w.org/"
Link:<http://mywpsite.com/>; rel=shortlink
Pragma:no-cache
Server:nginx/1.8.0
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Powered-By:PHP/5.5.9-1ubuntu4.14
Run Code Online (Sandbox Code Playgroud)
从 wiki 中,我尝试了不同的设置并压缩到以下单个文件(tester.com 有效,而 mywpsite.com 无效-这些是我在主机文件中设置的别名,并且肯定命中了正确的服务器)https://codex .wordpress.org/Nginx。
cat /etc/nginx/nginx.conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 1024; …Run Code Online (Sandbox Code Playgroud) 我使用本指南成功创建了一些 LE SSL 证书。
但是,当我更新我的 nginx 配置以使用证书并将所有端口 80 流量重定向到 443 时。http 成功重定向到 https,该站点不会加载。浏览器检测到我有一个有效的证书,但说我没有安全连接。这是我在我的/var/log/nginx/error.log:
2016/03/08 00:11:49 [error] 7301#0: *14 no "ssl_certificate" is defined in server listening on SSL port while SSL handshaking, client: 55.555.55.555, server: 0.0.0.0:443
Run Code Online (Sandbox Code Playgroud)
错误说我没有定义 SSL 证书,尽管我这样做了。这是我的配置:
server {
listen 443 ssl;
server_name cooldomain.pizza www.cooldomain.pizza
ssl_certificate /etc/letsencrypt/live/cooldomain.pizza/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/cooldomain.pizza/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
root /home/ubuntu/www/cooldomain-pizza;
index index.php index.html index.htm;
server_name cooldomain.pizza www.cooldomain.pizza;
charset utf-8;
location / {
try_files $uri $uri/ =404; …Run Code Online (Sandbox Code Playgroud) 我设置pm.status_path = /status选项:
ubuntu:~$ cat /etc/php/7.1/fpm/pool.d/www.conf | egrep 'listen|status'
listen = /run/php/php7.1-fpm.sock
listen.owner = www-data
listen.group = www-data
pm.status_path = /status
Run Code Online (Sandbox Code Playgroud)
套接字是正确的(和站点工作):
ubuntu:~$ sudo ls -la /run/php/php7.1-fpm.sock
srw-rw---- 1 www-data www-data 0 Feb 9 07:58 /run/php/php7.1-fpm.sock
Run Code Online (Sandbox Code Playgroud)
但我无法收到此状态页面:
ubuntu:~$ SCRIPT_NAME=/status SCRIPT_FILENAME=/status \
> REQUEST_METHOD=GET sudo cgi-fcgi -bind -connect /run/php/php7.1-fpm.sock
Content-type: text/html; charset=UTF-8
Run Code Online (Sandbox Code Playgroud)
或者使用 nginx 配置:
server {
listen 80;
server_name localhost;
location /status {
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
}
}
Run Code Online (Sandbox Code Playgroud)
curl http://localhost/status为空,状态代码为 200。
curl http://localhost/something按预期返回错误 404。
我应该怎么做才能解决这种情况?要检查什么?
我一直在努力让 PHP 通过 PHP-FPM 工作。我们的一台服务器被slowloris 攻击是apache 无法处理它。
我让 NGINX 运行正常并将数据传回 apache,但现在我试图至少对大多数东西使用纯 NGINX。我从源代码安装了 PHP-5.2.14 并用 PHP-FPM 修补了 5.14 并配置了 ff:
'./configure' '-enable-fastcgi' '--enable-fpm' '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib64' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--with-pear=/usr/share/pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-zlib' '--with-zlib-dir=/usr/include' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' …