PHP
PHP avec nginx
Dans le fichier /etc/php/7.3/fpm/pool.d/www.conf, remplacer ;listen = /run/php/php7.3-fpm.sock par listen = 127.0.0.1:9000
Exemple de conf nginx
server {
listen 80;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
location /projet2 {
try_files $uri $uri/ /projet2/index.php;
}
location /projet1 {
try_files $uri $uri/ /projet1/index.php;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass 127.0.0.1:9000;
}
}
Erreur php
Passer display_errors à On dans le fichier subl /etc/php/7.3/fpm/php.ini display_errors = On
Pretty var_dump !
sudo apt install php-xdebug
Add line at the end of /etc/php/7.3/fpm/conf.d/20-xdebug.ini
xdebug.cli_color=1
Installer composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
Lire dans le terminale
function readline_terminal($prompt = '', $enable = true)
{
$prompt && print $prompt;
if(!$enable) system('stty -echo');
$terminal_device = '/dev/tty';
$h = fopen($terminal_device, 'r');
if ($h === false) {
#throw new RuntimeException("Failed to open terminal device $terminal_device");
return false; # probably not running in a terminal.
}
$line = rtrim(fgets($h),"\r\n");
fclose($h);
if(!$enable)
{
system('stty echo');
echo "\n";
}
return $line;
}
Les sockets avec php
Client
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($socket, '127.0.0.1', 8001);
$string = "1:test\0\n";
socket_write($socket, $string, strlen($string));
$string = socket_read($socket, 100000);
echo $string;
Serveur
Comming soon…
Installer php7.3 (old)
Sur debian < 10 Ubuntu Mint… On a pas accès à la version 7.3 de php pour l’installer il faut ajouter des depot particulier.
add-apt-repository ppa:ondrej/php
apt update
apt install php7.3-fpm