我正在创建一个免费的共享托管服务,用于娱乐和学习。我制作了一个简单的表单,用户在其中输入子域和 ftp 密码。当用户点击提交时,脚本会生成一个 Linux 用户,使用 crypt() 加密输入的密码,然后将数据发送到 Linux 脚本。以下是完整脚本的错误部分:
echo "[$1]
user = $1
group = $1
listen = /var/run/sock_$1.sock
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
php_value[disable_functions] = \"phpinfo, system, exec, shell_exec, passthru , ini_alter, dl, pfsockopen, openlog, syslog, readlink, symlink, link, leak, fsockopen, popen, escapeshellcmd, apache_child_terminate apache_get_modules, apache_get_version, apache_getenv, apache_note,apache_setenv,virtual\"
php_value[open_basedir] = \"/home/$1:/home/$1/tmp\"" | sudo /usr/bin/tee /etc/php5/fpm/pool.d/$1.conf;
sudo /usr/sbin/service php5-fpm reload;
如您所见,它创建了一个 PHP-FPM 池,然后重新加载服务。当我手动创建池并手动重新加载 FPM 时,它工作正常,新网站加载没有问题。我注意到的问题是,如果我注释掉重新加载行,它会创建池,因此文件写入没有问题,但重新加载有问题。
因此,当我提交包含所有数据的帖子时,出现内部服务器错误 500。
Apache 日志:
[Thu Aug 08 01:43:44 2013] [error] [client xxx.xxx.xxx.xxx] (104)Connection reset by peer: FastCGI: comm with server "/vhost_asd_tld" aborted: read failed, referer: http://asd.tld/
[Thu Aug 08 01:43:44 2013] [error] [client xxx.xxx.xxx.xxx] FastCGI: incomplete headers (0 bytes) received from server "/vhost_asd_tld", referer: http://asd.tld/
asd.tld 池:
[asd_tld]
user = asd_tld
group = asd_tld
listen = /var/run/sock_asd_tld.sock
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
asd.tld 虚拟主机:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName asd.tld
DocumentRoot /var/www
<Directory /var/www>
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
ErrorLog "/var/www/log/asd.tld-error.log"
CustomLog "/var/www/log/asd.tld-access.log" combined
CustomLog "/var/www/log/asd.tld-bandwidth.log" common
<IfModule mod_fastcgi.c>
<FilesMatch \.php$>
SetHandler php-script
</FilesMatch>
Action php-script /php5-fpm-handler
Alias /php5-fpm-handler /vhost_asd_tld
FastCGIExternalServer /vhost_asd_tld -socket /var/run/sock_asd_tld.sock
</IfModule>
</VirtualHost>
操作系统:Ubuntu 桌面 13.04
有什么想法吗?提前致谢!
答案1
重新加载 php-fpm 会中断活动连接,例如您在这种情况下的连接。如果可能,您应该避免这样做,如果不能,请在将数据发送到浏览器后异步执行。