vi /etc/php-fpm.d/www.conf
php_admin_value[error_reporting] = E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_DEPRECATED
Tag Archives: php
FastCGI: failed to connect to server connect() fail
/usr/sbin/php-fpm --daemonize --fpm-config /etc/php/fpm/php-fpm.conf
php-fpm check config
php-fpm -t
php-fpm -tt
nohup style php
$lock = fopen('/path/to/pid', 'c+');
if (!flock($lock, LOCK_EX | LOCK_NB)) {
die('already running');
}
switch ($pid = pcntl_fork()) {
case -1:
die('unable to fork');
case 0: // this is the child process
break;
default: // otherwise this is the parent process
fseek($lock, 0);
ftruncate($lock, 0);
fwrite($lock, $pid);
fflush($lock);
exit;
}
if (posix_setsid() === -1) {
die('could not setsid');
}
fclose(STDIN);
fclose(STDOUT);
fclose(STDERR);
$stdIn = fopen('/dev/null', 'r'); // set fd/0
$stdOut = fopen('/dev/null', 'w'); // set fd/1
$stdErr = fopen('php://stdout', 'w'); // a hack to duplicate fd/1 to 2
pcntl_signal(SIGTSTP, SIG_IGN);
pcntl_signal(SIGTTOU, SIG_IGN);
pcntl_signal(SIGTTIN, SIG_IGN);
pcntl_signal(SIGHUP, SIG_IGN);
// do some staff
// to kill the proccess
$lock = fopen(‘/path/to/pid’, ‘c+’);
if (flock($lock, LOCK_EX | LOCK_NB)) {
die(‘process not running’);
}
$pid = fgets($lock);
posix_kill($pid, SIGTERM);
Error: Call to undefined function posix_setsid()
yum install php-process
E: Unable to locate package pecl
apt-get install php-pear
ubuntu php 7.3
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
apt update
apt install php7.3 php7.3-cli php7.3-common
php -v
PHP 7.3.20-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jul 9 2020 16:33:48) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.20, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.20-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
laravel hacked database
Its serious security issue this default Laravel configuration. because .env file and database credentials are not protected. So you need to create a .htaccess file in same folder to protect it:
<Files .env> order allow,deny Deny from all </Files> <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*)$ public/$1 [L] </IfModule>
mod_fcgid: read data timeout in 31 seconds on Virtualmin/Webmin
mod_fcgid: read data timeout in 31 seconds
End of script output before headers: index.php, referer:
vi /etc/httpd/conf/httpd.conf
IPCCommTimeout 300
FcgidIOTimeout 300
vi home/username/etc/php5/php.ini
max_execution_time = 300
php mail from address not working
If local mail server accepted email, but your email was frozen and not delivered:
mail($to,$subject,$message,$headers,"-f [email protected]");
cloudlinux get user php version
Selectorctl find user PHP version:
for user in $(\ls -A /var/cpanel/users) ; do version=$(selectorctl -c -u $user | awk '{print $1}') ; echo $user $version ; done
yum install php without httpd
yum install php-cli
Installing:
php-cli x86_64 7.3.18-1.el6.remi remi-php73 4.4 M
Installing for dependencies:
libargon2 x86_64 20161029-7.el6.remi remi 21 k
php-common x86_64 7.3.18-1.el6.remi remi-php73 1.1 M
php-json x86_64 7.3.18-1.el6.remi remi-php73 65 k
Transaction Summary
Install 4 Package(s)
Total download size: 5.6 M
php smtp send mail
To send PHP mail via SMTP:
Using PHPmailer -> https://github.com/PHPMailer/PHPMailer/
Using the PEAR Mail package -> cPanel -> PHP PEAR Packages -> Mail
php enable hsts
<?php header("strict-transport-security: max-age=100");
Without https you will get NET::ERR_CERT_AUTHORITY_INVALID error:
You cannot visit website.com right now because the website uses HSTS. Network errors and attacks are usually temporary, so this page will probably work later.
ai-bolit segmentation fault
php -q ai-bolit.php
Segmentation fault
Fix to disable opcache:
php -n -d extension=/usr/lib64/php/modules/opcache.so -q /root/ai-bolit/ai-bolit.php /some/path/to/scan