<?php sleep(90); $time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]; echo "PHP was running $time seconds\n";
Tag Archives: php
ubuntu install php-newrelic
echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list
wget -O- https://download.newrelic.com/548C16BF.gpg | apt-key add -
apt install newrelic-php5
newrelic-install install
wddx php 7.4 pecl
wget https://github.com/php/pecl-text-wddx/archive/master.zip -O wddx.zip
unzip wddx.zip
cd pecl-text-wddx-master
phpize
./configure
make
make install
php check write permission folder
<?php $filename = 'test.txt'; if (is_writable($filename)) { echo 'The file is writable'; } else { echo 'The file is not writable'; } ?>
PHP-FPM get status
cat /etc/php/7.4/fpm/pool.d/www.conf | grep -v \; | awk 'NF' | tee /etc/php/7.4/fpm/pool.d/www.conf
vi /etc/php/7.4/fpm/pool.d/www.conf
pm.status_path=/status
ping.path=/ping
ping.response=pong
apt install fcgiwrap
ss -l | grep php
u_strLISTEN 0 511 /run/php/php7.4-fpm.sock 79744 * 0
SCRIPT_NAME=/status \
SCRIPT_FILENAME=/status \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect /run/php/php7.4-fpm.sock
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
Content-type: text/plain;charset=UTF-8
pool: www
process manager: dynamic
start time: 07/Feb/2021:13:44:50 +0200
start since: 382
accepted conn: 3
listen queue: 0
max listen queue: 0
listen queue len: 0
idle processes: 1
active processes: 1
total processes: 2
max active processes: 1
max children reached: 0
slow requests: 0
proxy_fcgi apache
apt install apache2 php7.4-fpm
a2enconf php7.4-fpm
a2enmod proxy proxy_fcgi
cat /etc/apache2/conf-enabled/php7.4-fpm.conf # Redirect to local php-fpm if mod_php is not available <IfModule !mod_php7.c> <IfModule proxy_fcgi_module> # Enable http authorization headers <IfModule setenvif_module> SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1 </IfModule> <FilesMatch ".+\.ph(ar|p|tml)$"> SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost" </FilesMatch> <FilesMatch ".+\.phps$"> # Deny access to raw php sources by default # To re-enable it's recommended to enable access to the files # only in specific virtual host or directory Require all denied </FilesMatch> # Deny access to files without filename (e.g. '.php') <FilesMatch "^\.ph(ar|p|ps|tml)$"> Require all denied </FilesMatch> </IfModule> </IfModule>
proxy_fcgi:error AH01071: Got error Primary script unknown
File not found.
This error message means there are no such file.
apache http_x_forwarded_for to remote_addr
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
AH01067: Failed to read FastCGI header timeout
AH01067: Failed to read FastCGI header timeout
(104)Connection reset by peer: [client xx.xx.xx.xx:37642] AH01075: Error dispatching request to
Check if request_terminate_timeout is not set to small value like a few seconds
php can not find php headers
yum install php-devel
remi php missing /usr/bin/php56
php
-bash: php: command not found
source /opt/remi/php56/enable
echo "source /opt/remi/php56/enable" | tee -a /root/.bashrc
php -v
PHP 5.6.40 (cli) (built: Sep 29 2020 11:31:13)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
cat /opt/remi/php56/enable
export PATH=/opt/remi/php56/root/usr/bin:/opt/remi/php56/root/usr/sbin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/opt/remi/php56/root/usr/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export MANPATH=/opt/remi/php56/root/usr/share/man:${MANPATH}
v1.diavolesa.lt:~$ cat /opt/remi/php56/enable
export PATH=/opt/remi/php56/root/usr/bin:/opt/remi/php56/root/usr/sbin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/opt/remi/php56/root/usr/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export MANPATH=/opt/remi/php56/root/usr/share/man:${MANPATH}
pecl another php version
pecl multiple php version
pecl install mcrypt
pecl/mcrypt is already installed and is the same as the released version 1.0.3
install failed
update-alternatives –config=php
update-alternatives –config=php-config
update-alternatives –config=phpize
pecl install -f pecl
Also can help config-set:
pecl config-set ext_dir /usr/lib/php/20201226
pecl config-set php_bin /usr/bin/php7.4
pecl config-set php_ini /etc/php/7.4/cli/php.ini
pear config-set ext_dir /usr/lib/php/20201226
pear config-set php_bin /usr/bin/php7.4
configure: error: mcrypt.h not found. Please reinstall libmcrypt
pecl install mcrypt
configure: error: mcrypt.h not found. Please reinstall libmcrypt
ERROR: `/tmp/pear/temp/mcrypt/configure --with-php-config=/usr/bin/php-config --with-mcrypt' failed
apt install libmcrypt-dev
nginx allow only index.php
upstream _php {
server unix:/var/run/php-fpm/php-fpm.sock;
}
server {
server_name 192.168.1.100;
root /path/to/root;
index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
location / { deny all; }
location = / { }
location = /index.php { fastcgi_pass _php; }
location /phpmyadmin/ { }
location ~ ^/phpmyadmin/.*\.php$ { fastcgi_pass _php; }
}
php-fpm disable warnings
vi /etc/php-fpm.d/www.conf
php_admin_value[error_reporting] = E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_DEPRECATED