Difference between revisions of "PHP"
Plittlefield (talk | contribs) |
Plittlefield (talk | contribs) |
||
Line 118: | Line 118: | ||
sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -s remove | sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -s remove | ||
sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -y remove | sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -y remove | ||
− | sudo apt-get -s install php7.4-common php7.4-imagick php7.4-bcmath php7.4-cgi php7.4-cli php7.4-common php7.4-curl php7.4-gd php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-readline php7.4-xml php7.4-zip | + | sudo apt-get -s install php7.4-common php7.4-imagick php7.4-bcmath php7.4-cgi php7.4-cli php7.4-common php7.4-curl php7.4-gd php7.4-intl php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-readline php7.4-xml php7.4-zip |
− | sudo apt-get -y install php7.4-common php7.4-imagick php7.4-bcmath php7.4-cgi php7.4-cli php7.4-common php7.4-curl php7.4-gd php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-readline php7.4-xml php7.4-zip | + | sudo apt-get -y install php7.4-common php7.4-imagick php7.4-bcmath php7.4-cgi php7.4-cli php7.4-common php7.4-curl php7.4-gd php7.4-intl php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-readline php7.4-xml php7.4-zip |
'''7.3''' | '''7.3''' |
Revision as of 15:41, 11 April 2023
Switch PHP Versions
sudo update-alternatives --config php
Security
Hide PHP Version
Bitnami WordPress
sudo php -i | grep "Loaded Configuration File" sudo php -i | grep "expose_php" sudo nano /opt/bitnami/php/etc/php.ini expose_php => Off sudo /opt/bitnami/ctlscript.sh restart apache
How to hide the PHP version in nginX
php_info File
<?php phpinfo(); ?>
HOWTO: Fix Error: failed to execute shell
Error...
failed to execute shell: bash -c /usr/share/lighttpd/create-mime.assign.pl: No such file or directory failed to execute shell: bash -c /usr/share/lighttpd/include-conf-enabled.pl: No such file or directory
Reason...
Because the Ubuntu Release Upgrader has removed PHP during the upgrade process. God knows why.
Solution...
Reinstall the PHP CGI module and the PHP MySQL module.
Fix...
sudo apt-get install php-cgi php-mysql sudo lighty-enable-mod fastcgi-php sudo service lighttpd restart
FIX: Error: Unable to Load Dynamic Library
Error...
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/dom.so' - /usr/lib/php/20160303/dom.so: undefined symbol: php_libxml_node_free_list in Unknown on line 0
Fix...
sudo apt-get install --reinstall `dpkg -l | grep 'ii php7' | awk '{ printf($2" "); next}'`
openSSL Check
echo '<?php phpinfo(); ?>' | php 2>&1 |grep -i ssl
PEAR
Installation
sudo apt-get install php-pear
Error: requires PEAR Installer
requires PEAR Installer (version >= 1.10.1), installed version is 1.9.4
The fix is below...
Upgrade
sudo -i pear upgrade --force --alldeps http://pear.php.net/get/PEAR-1.10.1 pear clear-cache pear update-channels pear upgrade pear upgrade-all
Thanks - https://superuser.com/a/1129953/287000
HOWTO: Secure Tighten PHP
sudo nano /etc/php5/apache2/php.ini /etc/php5/cgi/php/ini
Change the following lines as the following :
display_errors = Off log_errors = On allow_url_fopen = Off safe_mode = On expose_php = Off enable_dl = Off disable_functions = system, show_source, symlink, exec, dl, shell_exec, passthru, phpinfo, escapeshellarg, escapeshellcmd
Thanks - http://secure-ubuntu-server.blogspot.co.uk/2009/07/howto-hardening-your-apache-and-php-on_07.html
HOWTO: Install Latest PHP 7.x On Ubuntu 20.04 LTS
php -v sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt list --installed php* sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -s remove sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -y remove sudo apt-get -s install php7.4-imagick php7.4-cgi php7.4-cli php7.4-common php7.4-curl php7.4-fpm php7.4-gd php7.4-intl php7.4-json php7.4-mysql php7.4-readline php7.4-xml php7.4-mbstring php7.4-zip sudo apt-get -y install php7.4-imagick php7.4-cgi php7.4-cli php7.4-common php7.4-curl php7.4-fpm php7.4-gd php7.4-intl php7.4-json php7.4-mysql php7.4-readline php7.4-xml php7.4-mbstring php7.4-zip
HOWTO: Upgrade To Latest PHP 7.x On Ubuntu 18.04 LTS
7.4
php -v sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt list --installed php* sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -s remove sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -y remove sudo apt-get -s install php7.4-common php7.4-imagick php7.4-bcmath php7.4-cgi php7.4-cli php7.4-common php7.4-curl php7.4-gd php7.4-intl php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-readline php7.4-xml php7.4-zip sudo apt-get -y install php7.4-common php7.4-imagick php7.4-bcmath php7.4-cgi php7.4-cli php7.4-common php7.4-curl php7.4-gd php7.4-intl php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-readline php7.4-xml php7.4-zip
7.3
php -v sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt list --installed php* sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -s remove sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -y remove sudo apt-get -s install php7.3-imagick php7.3-cgi php7.3-cli php7.3-common php7.3-curl php7.3-fpm php7.3-gd php7.3-json php7.3-mysql php7.3-readline php7.3-xml php7.3-mbstring php7.3-zip sudo apt-get -y install php7.3-imagick php7.3-cgi php7.3-cli php7.3-common php7.3-curl php7.3-fpm php7.3-gd php7.3-json php7.3-mysql php7.3-readline php7.3-xml php7.3-mbstring php7.3-zip
HOWTO: Upgrade To PHP 7.x On Ubuntu 16.04 LTS
7.4
php -v sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt list --installed php* sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -s remove sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -y remove sudo apt-get -s install php7.4-imagick php7.4-cgi php7.4-cli php7.4-common php7.4-curl php7.4-fpm php7.4-gd php7.4-json php7.4-mysql php7.4-readline php7.4-xml php7.4-mbstring php7.4-zip sudo apt-get -y install php7.4-imagick php7.4-cgi php7.4-cli php7.4-common php7.4-curl php7.4-fpm php7.4-gd php7.4-json php7.4-mysql php7.4-readline php7.4-xml php7.4-mbstring php7.4-zip
7.3
php -v sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt list --installed php* sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -s remove sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -y remove sudo apt-get -s install php7.3-imagick php7.3-cgi php7.3-cli php7.3-common php7.3-curl php7.3-fpm php7.3-gd php7.3-json php7.3-mysql php7.3-readline php7.3-xml php7.3-mbstring php7.3-zip sudo apt-get -y install php7.3-imagick php7.3-cgi php7.3-cli php7.3-common php7.3-curl php7.3-fpm php7.3-gd php7.3-json php7.3-mysql php7.3-readline php7.3-xml php7.3-mbstring php7.3-zip
HOWTO: Upgrade To PHP 7.2 On Ubuntu 14.04 LTS
THIS NO LONGER WORKS AS 14.04 IS END OF LIFE
php -v sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt list --installed php* sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -s remove sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -y remove sudo apt-get -s install php7.2-cgi php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-json php7.2-mysql php7.2-readline sudo apt-get -y install php7.2-cgi php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-json php7.2-mysql php7.2-readline
https://joshtronic.com/2017/03/26/upgrade-to-php-7x-on-ubunu-1404-lts
HOWTO: Upgrade To PHP 7.1 On Ubuntu 14.04 LTS
THIS NO LONGER WORKS AS 14.04 IS END OF LIFE
php -v sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt list --installed php* sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -s remove sudo apt list --installed php* 2>/dev/null | grep 'php' | sed 's/\/.*//' | xargs apt-get -y remove sudo apt-get -s install php7.1-cgi php7.1-cli php7.1-common php7.1-curl php7.1-gd php7.1-json php7.1-mysql php7.1-readline sudo apt-get -y install php7.1-cgi php7.1-cli php7.1-common php7.1-curl php7.1-gd php7.1-json php7.1-mysql php7.1-readline
https://joshtronic.com/2017/03/26/upgrade-to-php-7x-on-ubunu-1404-lts
HOWTO: Upgrade To PHP 5.6 On Ubuntu 14.04 LTS
THIS NO LONGER WORKS AS 14.04 IS END OF LIFE
php -v sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt list --installed php* sudo apt-get -s install php5.6-cgi php5.6-cli php5.6-common php5.6-curl php5.6-gd php5.6-json php5.6-mysql php5.6-readline sudo apt-get -y install php5.6-cgi php5.6-cli php5.6-common php5.6-curl php5.6-gd php5.6-json php5.6-mysql php5.6-readline sudo reboot php -v
HOWTO: Upgrade To PHP 5.5 On Ubuntu 12.04 LTS
sudo add-apt-repository ppa:ondrej/php5 sudo aptitude update sudo aptitude -v -s safe-upgrade sudo aptitude -v -y safe-upgrade php --version
Thanks - https://joshtronic.com/2013/12/30/upgrade-php-5-3-php-5-5-ubuntu-12-04-lts/
HOWTO: Upgrade PHP 5.3 To PHP 5.4 On Ubuntu 12.04 LTS
sudo add-apt-repository ppa:ondrej/php5-oldstable sudo aptitude update sudo aptitude -v -s safe-upgrade sudo aptitude -v -y safe-upgrade php --version
Thanks - http://www.nicovs.be/install-php-5-4-on-ubuntu-12-04-lts
HOWTO: Install Extensions
Centos
pecl install zip